Home | History | Annotate | Download | only in libc
      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 2008 Sun Microsystems, Inc.  All rights reserved.
     23 # Use is subject to license terms.
     24 #
     25 # ident	"%Z%%M%	%I%	%E% SMI"
     26 #
     27 
     28 LIBBASENAME=	libc
     29 LIBRARY=	$(LIBBASENAME:%=%.a)
     30 VERS=		.1
     31 
     32 # Note that we build libc_pic.a for the benefit of building
     33 # ld.so.1, but we do not install it.  Only ld.so.1 needs it
     34 # and it must be built in the same workspace as libc.
     35 LIB_PIC= libc_pic.a
     36 
     37 ROOTLIB=	$(ROOT)/usr/lib
     38 ROOTFS_LIB=	$(ROOT)/lib
     39 ROOTLIB64=	$(ROOTLIB)/$(MACH64)
     40 ROOTFS_LIB64=	$(ROOTFS_LIB)/$(MACH64)
     41 
     42 ROOTVARIANTDIR=	$(ROOTLIB)/libc
     43 
     44 ROOTFS_LINTDIR=		$(ROOTFS_LIB)
     45 ROOTFS_LINTDIR64=	$(ROOTFS_LIB64)
     46 ROOTFS_LINTLIB=		$(ROOTFS_LINTDIR)/$(LINTLIB)
     47 ROOTFS_LINTLIB64=	$(ROOTFS_LINTDIR64)/$(LINTLIB)
     48 
     49 # include common library definitions
     50 include ../Makefile.lib
     51 
     52 #
     53 # on some architectures, we build multiple libc variants
     54 #
     55 VAR1 =		hwcap1
     56 VAR2 =		hwcap2
     57 VAR3 =		hwcap3
     58 
     59 VAR1_DYNLIB =	$(LIBRARY:%.a=%_$(VAR1).so$(VERS))
     60 VAR1_BLDDIR =	$(MACH)_$(VAR1)
     61 VAR2_DYNLIB =	$(LIBRARY:%.a=%_$(VAR2).so$(VERS))
     62 VAR2_BLDDIR =	$(MACH)_$(VAR2)
     63 VAR3_DYNLIB =	$(LIBRARY:%.a=%_$(VAR3).so$(VERS))
     64 VAR3_BLDDIR =	$(MACH)_$(VAR3)
     65 
     66 i386_VARIANTS=	$(VAR1) $(VAR2) $(VAR3)
     67 sparc_VARIANTS=
     68 
     69 i386_ETC=	$(MACH)/etc
     70 sparc_ETC=
     71 
     72 VARIANTS=	$($(MACH)_VARIANTS)
     73 VARIANT_SUBDIRS	= $(VARIANTS:%=$(MACH)_%)
     74 
     75 SUBDIRS=	$(MACH) $(MACH_ETC) $(VARIANT_SUBDIRS)
     76 $(BUILD64)SUBDIRS += $(MACH64)
     77 
     78 LIBS =		$(DYNLIB) $(LINTLIB)
     79 
     80 ROOTLIBS64=	$(ROOTLIBDIR64)/$(DYNLIB) $(ROOTLIBDIR64)/$(LINTLIB)
     81 MACHLIBS64=	$(MACH64)/$(DYNLIB) $(MACH64)/$(LINTLIB)
     82 VARIANTLIBS=	$(VARIANTS:%=$(MACH)_%/$(LIBBASENAME)_%.so.1)
     83 ROOTVARIANTLIBS= $(VARIANTS:%=$(ROOTVARIANTDIR)/$(LIBBASENAME)_%.so.1)
     84 
     85 # definitions for install_h target
     86 BASEHDRS=	getxby_door.h 
     87 CHECKHDRS=	$(BASEHDRS:%.h=port/gen/%.check)
     88 HDRS=		$(BASEHDRS)
     89 
     90 # install rules for install_h target
     91 $(ROOTHDRDIR)/%: port/gen/%
     92 	$(INS.file)
     93 
     94 $(ROOTLIBDIR)/$(DYNLIB)	:=	FILEMODE = 755
     95 $(ROOTLIBDIR64)/$(DYNLIB) :=	FILEMODE = 755
     96 $(ROOTFS_LIBDIR)/$(DYNLIB)	:=	FILEMODE = 755
     97 $(ROOTFS_LIBDIR64)/$(DYNLIB)	:=	FILEMODE = 755
     98 
     99 $(ROOTVARIANTDIR)			:= FILEMODE= 755
    100 $(ROOTVARIANTDIR)/$(VAR1_DYNLIB)	:= FILEMODE= 755
    101 $(ROOTVARIANTDIR)/$(VAR2_DYNLIB)	:= FILEMODE= 755
    102 $(ROOTVARIANTDIR)/$(VAR3_DYNLIB)	:= FILEMODE= 755
    103 
    104 .KEEP_STATE:
    105 
    106 all:	check_i18n .WAIT lib32 $(BUILD64) .WAIT lib64 .WAIT etc
    107 
    108 check_i18n:
    109 	@if [ ! -f $(ROOTFS_LIBDIR)/libc_i18n.a -o \
    110 	    ! -f $(ROOTFS_LIBDIR64)/libc_i18n.a ]; then \
    111 		if [ "$$CLOSED_IS_PRESENT" = no ]; then \
    112 			$(ECHO) "Warning: closed binaries not" \
    113 			    "properly unpacked." >&2;\
    114 			$(ECHO) "Missing libc_i18n.a" >&2; \
    115 			exit 1; \
    116 		else \
    117 			$(ECHO) "Warning: libc_i18n.a must be built" \
    118 			    "before libc can be built." >&2; \
    119 			exit 1; \
    120 		fi \
    121 	fi
    122 
    123 etc:	$($(MACH)_ETC)
    124 
    125 lib32:	$(MACHLIBS) $(MACH)/$(LIB_PIC) $(VARIANTLIBS)
    126 	mkdir -p $(MACH)/i18n_pics
    127 	cd $(MACH)/i18n_pics ; $(AR) -x $(ROOTFS_LIBDIR)/libc_i18n.a
    128 	@if $(ELFDUMP) -r $(MACH)/$(DYNLIB) | $(GREP) -w environ ; then \
    129 		$(ECHO) "Error: Invalid reference to environ" ; \
    130 		$(ECHO) "Error: See comments in port/gen/env_data.c" ; \
    131 		exit 1; \
    132 	fi
    133 
    134 lib64:	$(MACHLIBS64) $(MACH64)/$(LIB_PIC) $(VARIANTLIBS)
    135 	mkdir -p $(MACH64)/i18n_pics
    136 	cd $(MACH64)/i18n_pics ; $(AR) -x $(ROOTFS_LIBDIR64)/libc_i18n.a
    137 	@if $(ELFDUMP) -r $(MACH64)/$(DYNLIB) | $(GREP) -w environ ; then \
    138 		$(ECHO) "Error: Invalid reference to environ" ; \
    139 		$(ECHO) "Error: See comments in port/gen/env_data.c" ; \
    140 		exit 1; \
    141 	fi
    142 
    143 $(VARIANTLIBS): FRC
    144 	@cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F)
    145 
    146 $($(MACH)_ETC): FRC
    147 	@cd $(@); pwd; $(MAKE) $(TARGET)
    148 
    149 install:	all			\
    150 		etc			\
    151 		inslib32		\
    152 		$(BUILD64) inslib64
    153 
    154 inslib32:	$(ROOTFS_LIBS) $(ROOTFS_LINKS) $(ROOTFS_LINT) \
    155 		$(ROOTFS_LINTLIB) \
    156 		$(ROOTVARIANTLIBS)
    157 
    158 inslib64:	$(ROOTFS_LIBS64) $(ROOTFS_LINKS64) \
    159 		$(ROOTFS_LINTLIB64)
    160 
    161 install_h: $(ROOTHDRS)
    162 
    163 check:	$(CHECKHDRS)
    164 
    165 $(ROOTFS_LIB)/%: $(MACH)/%
    166 	$(INS.file)
    167 $(ROOTFS_LIBDIR)/$(LIBLINKS): $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
    168 	$(INS.liblink)
    169 $(ROOTFS_LIB64)/%: $(MACH64)/%
    170 	$(INS.file)
    171 $(ROOTFS_LIBDIR64)/$(LIBLINKS): $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
    172 	$(INS.liblink)
    173 
    174 $(ROOTVARIANTDIR): $(ROOTLIB)
    175 	$(INS.dir)
    176 $(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR1_BLDDIR)/%
    177 	$(INS.file)
    178 $(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR2_BLDDIR)/%
    179 	$(INS.file)
    180 $(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR3_BLDDIR)/%
    181 	$(INS.file)
    182 
    183 # install rule for lint library target
    184 $(ROOTFS_LINTDIR)/%: port/%
    185 	$(INS.file)
    186 $(ROOTFS_LINTDIR64)/%: port/%
    187 	$(INS.file)
    188 $(ROOTFS_LINTDIR)/%: $(MACH)/%
    189 	$(INS.file)
    190 $(ROOTFS_LINTDIR64)/%: $(MACH64)/%
    191 	$(INS.file)
    192 
    193 $(LINTLIB):
    194 	@cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $@
    195 $(LINTLIB64):
    196 	@cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $@
    197 
    198 $(MACH)/$(LIB_PIC): FRC
    199 	@cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
    200 $(MACH64)/$(LIB_PIC): FRC
    201 	@cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
    202 
    203 all	:=	TARGET= all
    204 install	:=	TARGET= install
    205 clean	:=	TARGET= clean
    206 clobber	:=	TARGET= clobber
    207 lint	:=	TARGET= lint
    208 
    209 .PARALLEL:	$(SUBDIRS)
    210 
    211 $(SUBDIRS): FRC
    212 	@cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET)
    213 
    214 clean clobber: $(SUBDIRS)
    215 	$(RM) -r $(MACH)/i18n_pics
    216 	$(BUILD64)$(RM) -r $(MACH64)/i18n_pics
    217 
    218 lint: $(SUBDIRS)
    219 
    220 _msg:	$(MSGDOMAIN) catalog
    221 
    222 catalog:
    223 	sh ./makelibccatalog.sh $(MSGDOMAIN)
    224 
    225 $(MSGDOMAIN):
    226 	$(INS.dir)
    227 
    228 cscope.out tags: FRC
    229 	$(XREF) -x $@
    230 
    231 FRC:
    232 # include MACH-specific library targets
    233 include ../Makefile.mach
    234