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