xref: /illumos-gate/usr/src/lib/libc/Makefile (revision 0fb96ba1f1ce26ff8b286f8f928769a6afcb00a6)
17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# CDDL HEADER START
37c478bd9Sstevel@tonic-gate#
47c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
5f808c858Sraf# Common Development and Distribution License (the "License").
680ab886dSwesolows# You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate#
87c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate# and limitations under the License.
127c478bd9Sstevel@tonic-gate#
137c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate#
197c478bd9Sstevel@tonic-gate# CDDL HEADER END
207c478bd9Sstevel@tonic-gate#
217c478bd9Sstevel@tonic-gate#
221e49577aSRod Evans# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
237c478bd9Sstevel@tonic-gate#
244297a3b0SGarrett D'Amore# Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
254297a3b0SGarrett D'Amore# Use is subject to license terms.
2609e2ab34SAndy Fiddaman# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
277c478bd9Sstevel@tonic-gate#
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gateLIBBASENAME=	libc
307c478bd9Sstevel@tonic-gateLIBRARY=	$(LIBBASENAME:%=%.a)
317c478bd9Sstevel@tonic-gateVERS=		.1
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate# Note that we build libc_pic.a for the benefit of building
347c478bd9Sstevel@tonic-gate# ld.so.1, but we do not install it.  Only ld.so.1 needs it
357c478bd9Sstevel@tonic-gate# and it must be built in the same workspace as libc.
367c478bd9Sstevel@tonic-gateLIB_PIC= libc_pic.a
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gateROOTLIB=	$(ROOT)/usr/lib
397c478bd9Sstevel@tonic-gateROOTFS_LIB=	$(ROOT)/lib
407c478bd9Sstevel@tonic-gateROOTLIB64=	$(ROOTLIB)/$(MACH64)
417c478bd9Sstevel@tonic-gateROOTFS_LIB64=	$(ROOTFS_LIB)/$(MACH64)
427c478bd9Sstevel@tonic-gate
437c478bd9Sstevel@tonic-gateROOTVARIANTDIR=	$(ROOTLIB)/libc
44b1593d50SJason BeloroROOTVARIANTDIR64=	$(ROOTLIB64)/libc
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate# include common library definitions
477c478bd9Sstevel@tonic-gateinclude ../Makefile.lib
48cd61ae21SRichard Loweinclude ../Makefile.rootfs
497c478bd9Sstevel@tonic-gate
507c478bd9Sstevel@tonic-gate#
517c478bd9Sstevel@tonic-gate# on some architectures, we build multiple libc variants
527c478bd9Sstevel@tonic-gate#
537c478bd9Sstevel@tonic-gateVAR1 =		hwcap1
547c478bd9Sstevel@tonic-gateVAR2 =		hwcap2
55843e1988SjohnlevVAR3 =		hwcap3
567c478bd9Sstevel@tonic-gate
57b1593d50SJason BeloroVARBLD_1=	$(MACH:sparc=sparc)
58b1593d50SJason BeloroVARBLD=		$(VARBLD_1:i386=)
59b1593d50SJason Beloro
60b1593d50SJason BeloroVARBLD64_1=	$(MACH:sparc=sparcv9)
61b1593d50SJason BeloroVARBLD64=	$(VARBLD64_1:i386=)
62b1593d50SJason Beloro
637c478bd9Sstevel@tonic-gateVAR1_DYNLIB =	$(LIBRARY:%.a=%_$(VAR1).so$(VERS))
64b1593d50SJason BeloroVAR1_BLDDIR =	$(MACH)_$(VAR1)/$(VARBLD)
657c478bd9Sstevel@tonic-gateVAR2_DYNLIB =	$(LIBRARY:%.a=%_$(VAR2).so$(VERS))
66b1593d50SJason BeloroVAR2_BLDDIR =	$(MACH)_$(VAR2)/$(VARBLD)
67843e1988SjohnlevVAR3_DYNLIB =	$(LIBRARY:%.a=%_$(VAR3).so$(VERS))
68b1593d50SJason BeloroVAR3_BLDDIR =	$(MACH)_$(VAR3)/$(VARBLD)
69b1593d50SJason Beloro
70b1593d50SJason BeloroVAR1_DYNLIB64 =	$(LIBRARY:%.a=%_$(VAR1).so$(VERS))
71b1593d50SJason BeloroVAR1_BLDDIR64 =	$(MACH)_$(VAR1)/$(VARBLD64)
727c478bd9Sstevel@tonic-gate
73843e1988Sjohnlevi386_VARIANTS=	$(VAR1) $(VAR2) $(VAR3)
741e49577aSRod Evanssparc_VARIANTS=
751e49577aSRod Evanssparcv9_VARIANTS=
761e49577aSRod Evans
771e49577aSRod Evansi386_COMP=
781e49577aSRod Evanssparc_COMP=	capabilities
791e49577aSRod Evans
801e49577aSRod EvansMACH_COMP=	$($(MACH)_COMP)
817c478bd9Sstevel@tonic-gate
82a7123019Skucharski386_ETC=	$(MACH)/etc
83a7123019Skucharsksparc_ETC=
84a7123019Skucharsk
857c478bd9Sstevel@tonic-gateVARIANTS=	$($(MACH)_VARIANTS)
86b1593d50SJason BeloroVARIANT_SUBDIRS	= $(VARIANTS:%=$(MACH)_%/$(VARBLD))
87b1593d50SJason Beloro
88b1593d50SJason BeloroVARIANTS64=	$($(MACH64)_VARIANTS)
89b1593d50SJason BeloroVARIANT_SUBDIRS64	= $(VARIANTS64:%=$(MACH)_%/$(VARBLD64))
907c478bd9Sstevel@tonic-gate
911e49577aSRod EvansSUBDIRS=	$(MACH_CAP) $(MACH) $(MACH_ETC) $(VARIANT_SUBDIRS)
92c242ec1bSRoger A. Faulkner$(BUILD64)SUBDIRS += $(MACH64) $(VARIANT_SUBDIRS64)
937c478bd9Sstevel@tonic-gate
9409e2ab34SAndy FiddamanLIBS =		$(DYNLIB)
957c478bd9Sstevel@tonic-gate
96cd61ae21SRichard LoweROOTLIBS64=	$(ROOTLIB64)/$(DYNLIB)
9709e2ab34SAndy FiddamanMACHLIBS64=	$(MACH64)/$(DYNLIB)
98b1593d50SJason BeloroVARIANTLIBS=	$(VARIANTS:%=$(MACH)_%/$(VARBLD)/$(LIBBASENAME)_%.so.1)
99b1593d50SJason BeloroVARIANTLIBS64=	$(VARIANTS64:%=$(MACH)_%/$(VARBLD64)/$(LIBBASENAME)_%.so.1)
1007c478bd9Sstevel@tonic-gateROOTVARIANTLIBS= $(VARIANTS:%=$(ROOTVARIANTDIR)/$(LIBBASENAME)_%.so.1)
101b1593d50SJason BeloroROOTVARIANTLIBS64= $(VARIANTS64:%=$(ROOTVARIANTDIR64)/$(LIBBASENAME)_%.so.1)
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate# definitions for install_h target
1047c478bd9Sstevel@tonic-gateBASEHDRS=	getxby_door.h
1057c478bd9Sstevel@tonic-gateCHECKHDRS=	$(BASEHDRS:%.h=port/gen/%.check)
1067c478bd9Sstevel@tonic-gateHDRS=		$(BASEHDRS)
1077c478bd9Sstevel@tonic-gate
108b6805bf7SGordon RossCLOBBERFILES += THIRDPARTYLICENSE extract-copyright
109b6805bf7SGordon Ross
1107c478bd9Sstevel@tonic-gate# install rules for install_h target
1117c478bd9Sstevel@tonic-gate$(ROOTHDRDIR)/%: port/gen/%
1127c478bd9Sstevel@tonic-gate	$(INS.file)
1137c478bd9Sstevel@tonic-gate
114cd61ae21SRichard Lowe$(ROOTLIB)/$(DYNLIB)	:=	FILEMODE = 755
115cd61ae21SRichard Lowe$(ROOTLIB64)/$(DYNLIB) :=	FILEMODE = 755
1167c478bd9Sstevel@tonic-gate$(ROOTFS_LIBDIR)/$(DYNLIB)	:=	FILEMODE = 755
1177c478bd9Sstevel@tonic-gate$(ROOTFS_LIBDIR64)/$(DYNLIB)	:=	FILEMODE = 755
1187c478bd9Sstevel@tonic-gate
1197c478bd9Sstevel@tonic-gate$(ROOTVARIANTDIR)			:= FILEMODE= 755
1207c478bd9Sstevel@tonic-gate$(ROOTVARIANTDIR)/$(VAR1_DYNLIB)	:= FILEMODE= 755
1217c478bd9Sstevel@tonic-gate$(ROOTVARIANTDIR)/$(VAR2_DYNLIB)	:= FILEMODE= 755
122843e1988Sjohnlev$(ROOTVARIANTDIR)/$(VAR3_DYNLIB)	:= FILEMODE= 755
1237c478bd9Sstevel@tonic-gate
124b1593d50SJason Beloro$(ROOTVARIANTDIR64)			:= FILEMODE= 755
125b1593d50SJason Beloro$(ROOTVARIANTDIR64)/$(VAR1_DYNLIB64)	:= FILEMODE= 755
126b1593d50SJason Beloro
1277c478bd9Sstevel@tonic-gate.KEEP_STATE:
1287c478bd9Sstevel@tonic-gate
1296a3e8e86SRichard Loweall:	all_h lib32 $(BUILD64) .WAIT lib64 .WAIT etc THIRDPARTYLICENSE
1306b5e5868SGarrett D'Amore
1316b5e5868SGarrett D'AmoreTHIRDPARTYLICENSE: extract-copyright
1326b5e5868SGarrett D'Amore	$(RM) $@
1336b5e5868SGarrett D'Amore	./extract-copyright . > $@
134a7123019Skucharsk
135a7123019Skucharsketc:	$($(MACH)_ETC)
1367c478bd9Sstevel@tonic-gate
1371e49577aSRod Evanslib32:	$(MACH_COMP) $(MACHLIBS) $(MACH)/$(LIB_PIC) $(VARIANTLIBS)
13859f081edSraf	@if $(ELFDUMP) -r $(MACH)/$(DYNLIB) | $(GREP) -w environ ; then \
13959f081edSraf		$(ECHO) "Error: Invalid reference to environ" ; \
14059f081edSraf		$(ECHO) "Error: See comments in port/gen/env_data.c" ; \
14159f081edSraf		exit 1; \
14259f081edSraf	fi
1437c478bd9Sstevel@tonic-gate
1441e49577aSRod Evanslib64:	$(MACH_COMP) $(MACHLIBS64) $(MACH64)/$(LIB_PIC) $(VARIANTLIBS64)
14559f081edSraf	@if $(ELFDUMP) -r $(MACH64)/$(DYNLIB) | $(GREP) -w environ ; then \
14659f081edSraf		$(ECHO) "Error: Invalid reference to environ" ; \
14759f081edSraf		$(ECHO) "Error: See comments in port/gen/env_data.c" ; \
14859f081edSraf		exit 1; \
14959f081edSraf	fi
1507c478bd9Sstevel@tonic-gate
1516c1891eaSGarrett D'Amore$(MACH)/assym.h $(MACH64)/assym.h:
1526c1891eaSGarrett D'Amore	@cd $(@D); $(MAKE) assym.h
1530b54b18cSChristopher Kiick
1547c478bd9Sstevel@tonic-gate$(VARIANTLIBS): FRC
1557c478bd9Sstevel@tonic-gate	@cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F)
1567c478bd9Sstevel@tonic-gate
157b1593d50SJason Beloro$(VARIANTLIBS64): FRC
158b1593d50SJason Beloro	@cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F)
159b1593d50SJason Beloro
160a7123019Skucharsk$($(MACH)_ETC): FRC
161a7123019Skucharsk	@cd $(@); pwd; $(MAKE) $(TARGET)
162a7123019Skucharsk
1631e49577aSRod Evans$($(MACH)_COMP): FRC
1641e49577aSRod Evans	@cd $(@); pwd; $(MAKE) $(TARGET)
1651e49577aSRod Evans
1667c478bd9Sstevel@tonic-gateinstall:	all			\
167a7123019Skucharsk		etc			\
1687c478bd9Sstevel@tonic-gate		inslib32		\
169cd61ae21SRichard Lowe		$(ROOTCOMPATLINKS)
170cd61ae21SRichard Lowe
171cd61ae21SRichard Lowe$(BUILD64)install: inslib64 $(ROOTCOMPATLINKS64)
1727c478bd9Sstevel@tonic-gate
17309e2ab34SAndy Fiddamaninslib32:	$(ROOTFS_LIBS) $(ROOTFS_LINKS) $(ROOTVARIANTLIBS)
1747c478bd9Sstevel@tonic-gate
17509e2ab34SAndy Fiddamaninslib64:	$(ROOTFS_LIBS64) $(ROOTFS_LINKS64) $(ROOTVARIANTLIBS64)
1767c478bd9Sstevel@tonic-gate
177ac823a0fSJon Tibbleinstall_h: all_h $(ROOTHDRS)
178ac823a0fSJon Tibble
179ac823a0fSJon Tibbleall_h:	$(MACH)/assym.h $(MACH64)/assym.h
1807c478bd9Sstevel@tonic-gate
1817c478bd9Sstevel@tonic-gatecheck:	$(CHECKHDRS)
1827c478bd9Sstevel@tonic-gate
1837c478bd9Sstevel@tonic-gate$(ROOTVARIANTDIR): $(ROOTLIB)
1847c478bd9Sstevel@tonic-gate	$(INS.dir)
1857c478bd9Sstevel@tonic-gate$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR1_BLDDIR)/%
1867c478bd9Sstevel@tonic-gate	$(INS.file)
1877c478bd9Sstevel@tonic-gate$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR2_BLDDIR)/%
1887c478bd9Sstevel@tonic-gate	$(INS.file)
189843e1988Sjohnlev$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR3_BLDDIR)/%
190843e1988Sjohnlev	$(INS.file)
1917c478bd9Sstevel@tonic-gate
192b1593d50SJason Beloro$(ROOTVARIANTDIR64): $(ROOTLIB64)
193b1593d50SJason Beloro	$(INS.dir)
194b1593d50SJason Beloro$(ROOTVARIANTDIR64)/%: $(ROOTVARIANTDIR64) $(VAR1_BLDDIR64)/%
195b1593d50SJason Beloro	$(INS.file)
196b1593d50SJason Beloro
1977c478bd9Sstevel@tonic-gate$(MACH)/$(LIB_PIC): FRC
1987c478bd9Sstevel@tonic-gate	@cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
1997c478bd9Sstevel@tonic-gate$(MACH64)/$(LIB_PIC): FRC
2007c478bd9Sstevel@tonic-gate	@cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
2017c478bd9Sstevel@tonic-gate
2027c478bd9Sstevel@tonic-gateall	:=	TARGET= all
2037c478bd9Sstevel@tonic-gateinstall	:=	TARGET= install
2047c478bd9Sstevel@tonic-gateclean	:=	TARGET= clean
2057c478bd9Sstevel@tonic-gateclobber	:=	TARGET= clobber
2067c478bd9Sstevel@tonic-gate
2077c478bd9Sstevel@tonic-gate.PARALLEL:	$(SUBDIRS)
2087c478bd9Sstevel@tonic-gate
209f808c858Sraf$(SUBDIRS): FRC
2107c478bd9Sstevel@tonic-gate	@cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET)
2117c478bd9Sstevel@tonic-gate
212b6805bf7SGordon Rossclean: $(SUBDIRS)
213b6805bf7SGordon Rossclobber: $(SUBDIRS) etc clobber_local
214b6805bf7SGordon Rossclobber_local:
215b6805bf7SGordon Ross	$(RM) $(CLOBBERFILES)
2167c478bd9Sstevel@tonic-gate
217*0fb96ba1SBill SommerfeldFRC:
2187c478bd9Sstevel@tonic-gate
2197c478bd9Sstevel@tonic-gate_msg:	$(MSGDOMAIN) catalog
2207c478bd9Sstevel@tonic-gate
2217c478bd9Sstevel@tonic-gatecatalog:
2227c478bd9Sstevel@tonic-gate	sh ./makelibccatalog.sh $(MSGDOMAIN)
2237c478bd9Sstevel@tonic-gate
2247c478bd9Sstevel@tonic-gate$(MSGDOMAIN):
2257c478bd9Sstevel@tonic-gate	$(INS.dir)
2267c478bd9Sstevel@tonic-gate
227*0fb96ba1SBill Sommerfeldinclude ../../Makefile.xref
228cd61ae21SRichard Lowe
2297c478bd9Sstevel@tonic-gate# include MACH-specific library targets
2307c478bd9Sstevel@tonic-gateinclude ../Makefile.mach
231