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