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