xref: /illumos-gate/usr/src/lib/libc/Makefile (revision 73b80b821da76082173547dd650e417f6916eb8b)
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# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
27#
28
29LIBBASENAME=	libc
30LIBRARY=	$(LIBBASENAME:%=%.a)
31VERS=		.1
32
33# Note that we build libc_pic.a for the benefit of building
34# ld.so.1, but we do not install it.  Only ld.so.1 needs it
35# and it must be built in the same workspace as libc.
36LIB_PIC= libc_pic.a
37
38ROOTLIB=	$(ROOT)/usr/lib
39ROOTFS_LIB=	$(ROOT)/lib
40ROOTLIB64=	$(ROOTLIB)/$(MACH64)
41ROOTFS_LIB64=	$(ROOTFS_LIB)/$(MACH64)
42
43ROOTVARIANTDIR=	$(ROOTLIB)/libc
44ROOTVARIANTDIR64=	$(ROOTLIB64)/libc
45
46# include common library definitions
47include ../Makefile.lib
48include ../Makefile.rootfs
49
50#
51# on some architectures, we build multiple libc variants
52#
53VAR1 =		hwcap1
54VAR2 =		hwcap2
55VAR3 =		hwcap3
56
57VARBLD_1=	$(MACH:sparc=sparc)
58VARBLD=		$(VARBLD_1:i386=)
59
60VARBLD64_1=	$(MACH:sparc=sparcv9)
61VARBLD64=	$(VARBLD64_1:i386=)
62
63VAR1_DYNLIB =	$(LIBRARY:%.a=%_$(VAR1).so$(VERS))
64VAR1_BLDDIR =	$(MACH)_$(VAR1)/$(VARBLD)
65VAR2_DYNLIB =	$(LIBRARY:%.a=%_$(VAR2).so$(VERS))
66VAR2_BLDDIR =	$(MACH)_$(VAR2)/$(VARBLD)
67VAR3_DYNLIB =	$(LIBRARY:%.a=%_$(VAR3).so$(VERS))
68VAR3_BLDDIR =	$(MACH)_$(VAR3)/$(VARBLD)
69
70VAR1_DYNLIB64 =	$(LIBRARY:%.a=%_$(VAR1).so$(VERS))
71VAR1_BLDDIR64 =	$(MACH)_$(VAR1)/$(VARBLD64)
72
73i386_VARIANTS=	$(VAR1) $(VAR2) $(VAR3)
74sparc_VARIANTS=
75sparcv9_VARIANTS=
76
77i386_COMP=
78sparc_COMP=	capabilities
79
80MACH_COMP=	$($(MACH)_COMP)
81
82i386_ETC=	$(MACH)/etc
83sparc_ETC=
84
85VARIANTS=	$($(MACH)_VARIANTS)
86VARIANT_SUBDIRS	= $(VARIANTS:%=$(MACH)_%/$(VARBLD))
87
88VARIANTS64=	$($(MACH64)_VARIANTS)
89VARIANT_SUBDIRS64	= $(VARIANTS64:%=$(MACH)_%/$(VARBLD64))
90
91SUBDIRS=	$(MACH_CAP) $(MACH) $(MACH_ETC) $(VARIANT_SUBDIRS)
92$(BUILD64)SUBDIRS += $(MACH64) $(VARIANT_SUBDIRS64)
93
94LIBS =		$(DYNLIB)
95
96ROOTLIBS64=	$(ROOTLIB64)/$(DYNLIB)
97MACHLIBS64=	$(MACH64)/$(DYNLIB)
98VARIANTLIBS=	$(VARIANTS:%=$(MACH)_%/$(VARBLD)/$(LIBBASENAME)_%.so.1)
99VARIANTLIBS64=	$(VARIANTS64:%=$(MACH)_%/$(VARBLD64)/$(LIBBASENAME)_%.so.1)
100ROOTVARIANTLIBS= $(VARIANTS:%=$(ROOTVARIANTDIR)/$(LIBBASENAME)_%.so.1)
101ROOTVARIANTLIBS64= $(VARIANTS64:%=$(ROOTVARIANTDIR64)/$(LIBBASENAME)_%.so.1)
102
103# definitions for install_h target
104BASEHDRS=	getxby_door.h
105CHECKHDRS=	$(BASEHDRS:%.h=port/gen/%.check)
106HDRS=		$(BASEHDRS)
107
108CLOBBERFILES += THIRDPARTYLICENSE extract-copyright
109
110# install rules for install_h target
111$(ROOTHDRDIR)/%: port/gen/%
112	$(INS.file)
113
114$(ROOTLIB)/$(DYNLIB)	:=	FILEMODE = 755
115$(ROOTLIB64)/$(DYNLIB) :=	FILEMODE = 755
116$(ROOTFS_LIBDIR)/$(DYNLIB)	:=	FILEMODE = 755
117$(ROOTFS_LIBDIR64)/$(DYNLIB)	:=	FILEMODE = 755
118
119$(ROOTVARIANTDIR)			:= FILEMODE= 755
120$(ROOTVARIANTDIR)/$(VAR1_DYNLIB)	:= FILEMODE= 755
121$(ROOTVARIANTDIR)/$(VAR2_DYNLIB)	:= FILEMODE= 755
122$(ROOTVARIANTDIR)/$(VAR3_DYNLIB)	:= FILEMODE= 755
123
124$(ROOTVARIANTDIR64)			:= FILEMODE= 755
125$(ROOTVARIANTDIR64)/$(VAR1_DYNLIB64)	:= FILEMODE= 755
126
127.KEEP_STATE:
128
129all:	all_h lib32 $(BUILD64) .WAIT lib64 .WAIT etc THIRDPARTYLICENSE
130
131THIRDPARTYLICENSE: extract-copyright
132	$(RM) $@
133	./extract-copyright . > $@
134
135etc:	$($(MACH)_ETC)
136
137lib32:	$(MACH_COMP) $(MACHLIBS) $(MACH)/$(LIB_PIC) $(VARIANTLIBS)
138	@if $(ELFDUMP) -r $(MACH)/$(DYNLIB) | $(GREP) -w environ ; then \
139		$(ECHO) "Error: Invalid reference to environ" ; \
140		$(ECHO) "Error: See comments in port/gen/env_data.c" ; \
141		exit 1; \
142	fi
143
144lib64:	$(MACH_COMP) $(MACHLIBS64) $(MACH64)/$(LIB_PIC) $(VARIANTLIBS64)
145	@if $(ELFDUMP) -r $(MACH64)/$(DYNLIB) | $(GREP) -w environ ; then \
146		$(ECHO) "Error: Invalid reference to environ" ; \
147		$(ECHO) "Error: See comments in port/gen/env_data.c" ; \
148		exit 1; \
149	fi
150
151$(MACH)/assym.h $(MACH64)/assym.h:
152	@cd $(@D); $(MAKE) assym.h
153
154$(VARIANTLIBS): FRC
155	@cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F)
156
157$(VARIANTLIBS64): FRC
158	@cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F)
159
160$($(MACH)_ETC): FRC
161	@cd $(@); pwd; $(MAKE) $(TARGET)
162
163$($(MACH)_COMP): FRC
164	@cd $(@); pwd; $(MAKE) $(TARGET)
165
166install:	all			\
167		etc			\
168		inslib32		\
169		$(ROOTCOMPATLINKS)
170
171$(BUILD64)install: inslib64 $(ROOTCOMPATLINKS64)
172
173inslib32:	$(ROOTFS_LIBS) $(ROOTFS_LINKS) $(ROOTVARIANTLIBS)
174
175inslib64:	$(ROOTFS_LIBS64) $(ROOTFS_LINKS64) $(ROOTVARIANTLIBS64)
176
177install_h: all_h $(ROOTHDRS)
178
179all_h:	$(MACH)/assym.h $(MACH64)/assym.h
180
181check:	$(CHECKHDRS)
182
183$(ROOTVARIANTDIR): $(ROOTLIB)
184	$(INS.dir)
185$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR1_BLDDIR)/%
186	$(INS.file)
187$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR2_BLDDIR)/%
188	$(INS.file)
189$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR3_BLDDIR)/%
190	$(INS.file)
191
192$(ROOTVARIANTDIR64): $(ROOTLIB64)
193	$(INS.dir)
194$(ROOTVARIANTDIR64)/%: $(ROOTVARIANTDIR64) $(VAR1_BLDDIR64)/%
195	$(INS.file)
196
197$(MACH)/$(LIB_PIC): FRC
198	@cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
199$(MACH64)/$(LIB_PIC): FRC
200	@cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
201
202all	:=	TARGET= all
203install	:=	TARGET= install
204clean	:=	TARGET= clean
205clobber	:=	TARGET= clobber
206
207.PARALLEL:	$(SUBDIRS)
208
209$(SUBDIRS): FRC
210	@cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET)
211
212clean: $(SUBDIRS)
213clobber: $(SUBDIRS) etc clobber_local
214clobber_local:
215	$(RM) $(CLOBBERFILES)
216
217
218_msg:	$(MSGDOMAIN) catalog
219
220catalog:
221	sh ./makelibccatalog.sh $(MSGDOMAIN)
222
223$(MSGDOMAIN):
224	$(INS.dir)
225
226cscope.out tags: FRC
227	$(XREF) -x $@
228
229FRC:
230
231# include MACH-specific library targets
232include ../Makefile.mach
233