1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 #
  22 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  23 #
  24 # Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # Copyright 2014 Andrew Stormont.
  28 #
  29 
  30 LIBBASENAME=    libc
  31 LIBRARY=        $(LIBBASENAME:%=%.a)
  32 VERS=           .1
  33 
  34 # Note that we build libc_pic.a for the benefit of building
  35 # ld.so.1, but we do not install it.  Only ld.so.1 needs it
  36 # and it must be built in the same workspace as libc.
  37 LIB_PIC= libc_pic.a
  38 
  39 ROOTLIB=        $(ROOT)/usr/lib
  40 ROOTFS_LIB=     $(ROOT)/lib
  41 ROOTLIB64=      $(ROOTLIB)/$(MACH64)
  42 ROOTFS_LIB64=   $(ROOTFS_LIB)/$(MACH64)
  43 
  44 ROOTVARIANTDIR= $(ROOTLIB)/libc
  45 ROOTVARIANTDIR64=       $(ROOTLIB64)/libc
  46 
  47 ROOTFS_LINTDIR=         $(ROOTFS_LIB)
  48 ROOTFS_LINTDIR64=       $(ROOTFS_LIB64)
  49 ROOTFS_LINTLIB=         $(ROOTFS_LINTDIR)/$(LINTLIB)
  50 ROOTFS_LINTLIB64=       $(ROOTFS_LINTDIR64)/$(LINTLIB)
  51 
  52 # include common library definitions
  53 include ../Makefile.lib
  54 
  55 #
  56 # on some architectures, we build multiple libc variants
  57 #
  58 VAR1 =          hwcap1
  59 VAR2 =          hwcap2
  60 VAR3 =          hwcap3
  61 
  62 VARBLD_1=       $(MACH:sparc=sparc)
  63 VARBLD=         $(VARBLD_1:i386=)
  64 
  65 VARBLD64_1=     $(MACH:sparc=sparcv9)
  66 VARBLD64=       $(VARBLD64_1:i386=)
  67 
  68 VAR1_DYNLIB =   $(LIBRARY:%.a=%_$(VAR1).so$(VERS))
  69 VAR1_BLDDIR =   $(MACH)_$(VAR1)/$(VARBLD)
  70 VAR2_DYNLIB =   $(LIBRARY:%.a=%_$(VAR2).so$(VERS))
  71 VAR2_BLDDIR =   $(MACH)_$(VAR2)/$(VARBLD)
  72 VAR3_DYNLIB =   $(LIBRARY:%.a=%_$(VAR3).so$(VERS))
  73 VAR3_BLDDIR =   $(MACH)_$(VAR3)/$(VARBLD)
  74 
  75 VAR1_DYNLIB64 = $(LIBRARY:%.a=%_$(VAR1).so$(VERS))
  76 VAR1_BLDDIR64 = $(MACH)_$(VAR1)/$(VARBLD64)
  77 
  78 i386_VARIANTS=  $(VAR1) $(VAR2) $(VAR3)
  79 sparc_VARIANTS=
  80 sparcv9_VARIANTS=
  81 
  82 i386_COMP=
  83 sparc_COMP=     capabilities
  84 
  85 MACH_COMP=      $($(MACH)_COMP)
  86 
  87 i386_ETC=       $(MACH)/etc
  88 sparc_ETC=
  89 
  90 VARIANTS=       $($(MACH)_VARIANTS)
  91 VARIANT_SUBDIRS = $(VARIANTS:%=$(MACH)_%/$(VARBLD))
  92 
  93 VARIANTS64=     $($(MACH64)_VARIANTS)
  94 VARIANT_SUBDIRS64       = $(VARIANTS64:%=$(MACH)_%/$(VARBLD64))
  95 
  96 SUBDIRS=        $(MACH_CAP) $(MACH) $(MACH_ETC) $(VARIANT_SUBDIRS)
  97 $(BUILD64)SUBDIRS += $(MACH64) $(VARIANT_SUBDIRS64)
  98 
  99 LIBS =          $(DYNLIB) $(LINTLIB)
 100 
 101 ROOTLIBS64=     $(ROOTLIBDIR64)/$(DYNLIB) $(ROOTLIBDIR64)/$(LINTLIB)
 102 MACHLIBS64=     $(MACH64)/$(DYNLIB) $(MACH64)/$(LINTLIB)
 103 VARIANTLIBS=    $(VARIANTS:%=$(MACH)_%/$(VARBLD)/$(LIBBASENAME)_%.so.1)
 104 VARIANTLIBS64=  $(VARIANTS64:%=$(MACH)_%/$(VARBLD64)/$(LIBBASENAME)_%.so.1)
 105 ROOTVARIANTLIBS= $(VARIANTS:%=$(ROOTVARIANTDIR)/$(LIBBASENAME)_%.so.1)
 106 ROOTVARIANTLIBS64= $(VARIANTS64:%=$(ROOTVARIANTDIR64)/$(LIBBASENAME)_%.so.1)
 107 
 108 # definitions for install_h target
 109 BASEHDRS=       getxby_door.h 
 110 CHECKHDRS=      $(BASEHDRS:%.h=port/gen/%.check)
 111 HDRS=           $(BASEHDRS)
 112 
 113 CLOBBERFILES += THIRDPARTYLICENSE extract-copyright
 114 
 115 # install rules for install_h target
 116 $(ROOTHDRDIR)/%: port/gen/%
 117         $(INS.file)
 118 
 119 $(ROOTLIBDIR)/$(DYNLIB) :=      FILEMODE = 755
 120 $(ROOTLIBDIR64)/$(DYNLIB) :=    FILEMODE = 755
 121 $(ROOTFS_LIBDIR)/$(DYNLIB)      :=      FILEMODE = 755
 122 $(ROOTFS_LIBDIR64)/$(DYNLIB)    :=      FILEMODE = 755
 123 
 124 $(ROOTVARIANTDIR)                       := FILEMODE= 755
 125 $(ROOTVARIANTDIR)/$(VAR1_DYNLIB)        := FILEMODE= 755
 126 $(ROOTVARIANTDIR)/$(VAR2_DYNLIB)        := FILEMODE= 755
 127 $(ROOTVARIANTDIR)/$(VAR3_DYNLIB)        := FILEMODE= 755
 128 
 129 $(ROOTVARIANTDIR64)                     := FILEMODE= 755
 130 $(ROOTVARIANTDIR64)/$(VAR1_DYNLIB64)    := FILEMODE= 755
 131 
 132 .KEEP_STATE:
 133 
 134 all:    all_h lib .WAIT etc THIRDPARTYLICENSE
 135 
 136 THIRDPARTYLICENSE: extract-copyright
 137         $(RM) $@
 138         ./extract-copyright . > $@
 139 
 140 etc:    $($(MACH)_ETC)
 141 
 142 lib32:  $(MACH_COMP) $(MACHLIBS) $(MACH)/$(LIB_PIC) $(VARIANTLIBS)
 143         @if $(ELFDUMP) -r $(MACH)/$(DYNLIB) | $(GREP) -w environ ; then \
 144                 $(ECHO) "Error: Invalid reference to environ" ; \
 145                 $(ECHO) "Error: See comments in port/gen/env_data.c" ; \
 146                 exit 1; \
 147         fi
 148 
 149 lib64:  $(MACH_COMP) $(MACHLIBS64) $(MACH64)/$(LIB_PIC) $(VARIANTLIBS64)
 150         @if $(ELFDUMP) -r $(MACH64)/$(DYNLIB) | $(GREP) -w environ ; then \
 151                 $(ECHO) "Error: Invalid reference to environ" ; \
 152                 $(ECHO) "Error: See comments in port/gen/env_data.c" ; \
 153                 exit 1; \
 154         fi
 155 
 156 lib: lib32 $(BUILD64) .WAIT lib64
 157 
 158 $(MACH)/assym.h $(MACH64)/assym.h:
 159         @cd $(@D); $(MAKE) assym.h
 160 
 161 $(VARIANTLIBS): FRC
 162         @cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F)
 163 
 164 $(VARIANTLIBS64): FRC
 165         @cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F)
 166 
 167 $($(MACH)_ETC): FRC
 168         @cd $(@); pwd; $(MAKE) $(TARGET)
 169 
 170 $($(MACH)_COMP): FRC
 171         @cd $(@); pwd; $(MAKE) $(TARGET)
 172 
 173 install:        all etc inslib
 174 
 175 inslib32:       $(ROOTFS_LIBS) $(ROOTFS_LINKS) $(ROOTFS_LINT) \
 176                 $(ROOTFS_LINTLIB) \
 177                 $(ROOTVARIANTLIBS)
 178 
 179 inslib64:       $(ROOTFS_LIBS64) $(ROOTFS_LINKS64) \
 180                 $(ROOTFS_LINTLIB64) \
 181                 $(ROOTVARIANTLIBS64)
 182 
 183 inslib: inslib32 $(BUILD64) inslib64
 184 
 185 install_h: all_h $(ROOTHDRS)
 186 
 187 all_h:  $(MACH)/assym.h $(BUILD64) $(MACH64)/assym.h
 188 
 189 check:  $(CHECKHDRS)
 190 
 191 $(ROOTFS_LIB)/%: $(MACH)/%
 192         $(INS.file)
 193 $(ROOTFS_LIBDIR)/$(LIBLINKS): $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
 194         $(INS.liblink)
 195 $(ROOTFS_LIB64)/%: $(MACH64)/%
 196         $(INS.file)
 197 $(ROOTFS_LIBDIR64)/$(LIBLINKS): $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
 198         $(INS.liblink)
 199 
 200 $(ROOTVARIANTDIR): $(ROOTLIB)
 201         $(INS.dir)
 202 $(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR1_BLDDIR)/%
 203         $(INS.file)
 204 $(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR2_BLDDIR)/%
 205         $(INS.file)
 206 $(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR3_BLDDIR)/%
 207         $(INS.file)
 208 
 209 $(ROOTVARIANTDIR64): $(ROOTLIB64)
 210         $(INS.dir)
 211 $(ROOTVARIANTDIR64)/%: $(ROOTVARIANTDIR64) $(VAR1_BLDDIR64)/%
 212         $(INS.file)
 213 
 214 # install rule for lint library target
 215 $(ROOTFS_LINTDIR)/%: port/%
 216         $(INS.file)
 217 $(ROOTFS_LINTDIR64)/%: port/%
 218         $(INS.file)
 219 $(ROOTFS_LINTDIR)/%: $(MACH)/%
 220         $(INS.file)
 221 $(ROOTFS_LINTDIR64)/%: $(MACH64)/%
 222         $(INS.file)
 223 
 224 $(LINTLIB):
 225         @cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $@
 226 $(LINTLIB64):
 227         @cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $@
 228 
 229 $(MACH)/$(LIB_PIC): FRC
 230         @cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
 231 $(MACH64)/$(LIB_PIC): FRC
 232         @cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
 233 
 234 all     :=      TARGET= all
 235 install :=      TARGET= install
 236 clean   :=      TARGET= clean
 237 clobber :=      TARGET= clobber
 238 lint    :=      TARGET= lint
 239 
 240 .PARALLEL:      $(SUBDIRS)
 241 
 242 $(SUBDIRS): FRC
 243         @cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET)
 244 
 245 clean: $(SUBDIRS)
 246 clobber: $(SUBDIRS) etc clobber_local
 247 clobber_local:
 248         $(RM) $(CLOBBERFILES)
 249 
 250 lint: $(SUBDIRS)
 251 
 252 _msg:   $(MSGDOMAIN) catalog
 253 
 254 catalog:
 255         sh ./makelibccatalog.sh $(MSGDOMAIN)
 256 
 257 $(MSGDOMAIN):
 258         $(INS.dir)
 259 
 260 cscope.out tags: FRC
 261         $(XREF) -x $@
 262 
 263 FRC:
 264 # include MACH-specific library targets
 265 include ../Makefile.mach