xref: /titanic_44/usr/src/lib/libc/Makefile (revision f808c858fa61e7769218966759510a8b1190dfcf)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
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
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
57
58VAR1_DYNLIB =	$(LIBRARY:%.a=%_$(VAR1).so$(VERS))
59VAR1_BLDDIR =	$(MACH)_$(VAR1)
60VAR2_DYNLIB =	$(LIBRARY:%.a=%_$(VAR2).so$(VERS))
61VAR2_BLDDIR =	$(MACH)_$(VAR2)
62
63i386_VARIANTS=	$(VAR1) $(VAR2)
64sparc_VARIANTS=
65
66i386_ETC=	$(MACH)/etc
67sparc_ETC=
68
69VARIANTS=	$($(MACH)_VARIANTS)
70VARIANT_SUBDIRS	= $(VARIANTS:%=$(MACH)_%)
71
72SUBDIRS=	$(MACH) $(MACH_ETC) $(VARIANT_SUBDIRS)
73$(BUILD64)SUBDIRS += $(MACH64)
74
75LIBS =		$(DYNLIB) $(LINTLIB)
76
77ROOTLIBS64=	$(ROOTLIBDIR64)/$(DYNLIB) $(ROOTLIBDIR64)/$(LINTLIB)
78MACHLIBS64=	$(MACH64)/$(DYNLIB) $(MACH64)/$(LINTLIB)
79VARIANTLIBS=	$(VARIANTS:%=$(MACH)_%/$(LIBBASENAME)_%.so.1)
80ROOTVARIANTLIBS= $(VARIANTS:%=$(ROOTVARIANTDIR)/$(LIBBASENAME)_%.so.1)
81
82# definitions for install_h target
83BASEHDRS=	getxby_door.h
84CHECKHDRS=	$(BASEHDRS:%.h=port/gen/%.check)
85HDRS=		$(BASEHDRS)
86
87# install rules for install_h target
88$(ROOTHDRDIR)/%: port/gen/%
89	$(INS.file)
90
91$(ROOTLIBDIR)/$(DYNLIB)	:=	FILEMODE = 755
92$(ROOTLIBDIR64)/$(DYNLIB) :=	FILEMODE = 755
93$(ROOTFS_LIBDIR)/$(DYNLIB)	:=	FILEMODE = 755
94$(ROOTFS_LIBDIR64)/$(DYNLIB)	:=	FILEMODE = 755
95
96$(ROOTVARIANTDIR)			:= FILEMODE= 755
97$(ROOTVARIANTDIR)/$(VAR1_DYNLIB)	:= FILEMODE= 755
98$(ROOTVARIANTDIR)/$(VAR2_DYNLIB)	:= FILEMODE= 755
99
100.KEEP_STATE:
101
102all:	check_i18n .WAIT lib32 $(BUILD64) .WAIT lib64 .WAIT etc
103
104check_i18n:
105	@if [ ! -f $(ROOTFS_LIBDIR)/libc_i18n.a -o \
106	    ! -f $(ROOTFS_LIBDIR64)/libc_i18n.a ]; then \
107		if [ "$$CLOSED_IS_PRESENT" = no ]; then \
108			$(ECHO) "Warning: closed binaries not" \
109			    "properly unpacked." >&2;\
110			$(ECHO) "Missing libc_i18n.a" >&2; \
111			exit 1; \
112		else \
113			$(ECHO) "Warning: libc_i18n.a must be built" \
114			    "before libc can be built." >&2; \
115			exit 1; \
116		fi \
117	fi
118
119etc:	$($(MACH)_ETC)
120
121lib32:	$(MACHLIBS) $(MACH)/$(LIB_PIC) $(VARIANTLIBS)
122	mkdir -p $(MACH)/i18n_pics
123	cd $(MACH)/i18n_pics ; $(AR) -x $(ROOTFS_LIBDIR)/libc_i18n.a
124	$(CHECK_FNAMES) -s $(C_SYNONYMS_H) -l $(MACH)/$(DYNLIB) \
125		$(MACH)/pics/*.o $(MACH)/i18n_pics/*.o
126
127lib64:	$(MACHLIBS64) $(MACH64)/$(LIB_PIC) $(VARIANTLIBS)
128	mkdir -p $(MACH64)/i18n_pics
129	cd $(MACH64)/i18n_pics ; $(AR) -x $(ROOTFS_LIBDIR64)/libc_i18n.a
130	$(CHECK_FNAMES) -s $(C_SYNONYMS_H) -l $(MACH64)/$(DYNLIB) \
131		$(MACH64)/pics/*.o $(MACH64)/i18n_pics/*.o
132
133$(VARIANTLIBS): FRC
134	@cd $(@D); pwd; VERSION='$(VERSION)' $(MAKE) $(@F)
135	$(CHECK_FNAMES) -s $(C_SYNONYMS_H) -l $(@D)/$(@F) $(@D)/pics/*.o
136
137$($(MACH)_ETC): FRC
138	@cd $(@); pwd; $(MAKE) $(TARGET)
139
140install:	all			\
141		etc			\
142		inslib32		\
143		$(BUILD64) inslib64
144
145inslib32:	$(ROOTFS_LIBS) $(ROOTFS_LINKS) $(ROOTFS_LINT) \
146		$(ROOTFS_LINTLIB) \
147		$(ROOTVARIANTLIBS)
148
149inslib64:	$(ROOTFS_LIBS64) $(ROOTFS_LINKS64) \
150		$(ROOTFS_LINTLIB64)
151
152install_h: $(ROOTHDRS)
153
154check:	$(CHECKHDRS)
155
156$(ROOTFS_LIB)/%: $(MACH)/%
157	$(INS.file)
158$(ROOTFS_LIBDIR)/$(LIBLINKS): $(ROOTFS_LIBDIR)/$(LIBLINKS)$(VERS)
159	$(INS.liblink)
160$(ROOTFS_LIB64)/%: $(MACH64)/%
161	$(INS.file)
162$(ROOTFS_LIBDIR64)/$(LIBLINKS): $(ROOTFS_LIBDIR64)/$(LIBLINKS)$(VERS)
163	$(INS.liblink)
164
165$(ROOTVARIANTDIR): $(ROOTLIB)
166	$(INS.dir)
167$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR1_BLDDIR)/%
168	$(INS.file)
169$(ROOTVARIANTDIR)/%: $(ROOTVARIANTDIR) $(VAR2_BLDDIR)/%
170	$(INS.file)
171
172# install rule for lint library target
173$(ROOTFS_LINTDIR)/%: port/%
174	$(INS.file)
175$(ROOTFS_LINTDIR64)/%: port/%
176	$(INS.file)
177$(ROOTFS_LINTDIR)/%: $(MACH)/%
178	$(INS.file)
179$(ROOTFS_LINTDIR64)/%: $(MACH64)/%
180	$(INS.file)
181
182$(LINTLIB):
183	@cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $@
184$(LINTLIB64):
185	@cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $@
186
187$(MACH)/$(LIB_PIC): FRC
188	@cd $(MACH); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
189$(MACH64)/$(LIB_PIC): FRC
190	@cd $(MACH64); pwd; VERSION='$(VERSION)' $(MAKE) $(LIB_PIC)
191
192all	:=	TARGET= all
193install	:=	TARGET= install
194clean	:=	TARGET= clean
195clobber	:=	TARGET= clobber
196lint	:=	TARGET= lint
197
198.PARALLEL:	$(SUBDIRS)
199
200$(SUBDIRS): FRC
201	@cd $@; pwd; VERSION='$(VERSION)' $(MAKE) $(TARGET)
202
203clean clobber: $(SUBDIRS)
204	$(RM) -r $(MACH)/i18n_pics
205	$(BUILD64)$(RM) -r $(MACH64)/i18n_pics
206
207lint: $(SUBDIRS)
208
209_msg:	$(MSGDOMAIN) catalog
210
211catalog:
212	sh ./makelibccatalog.sh $(MSGDOMAIN)
213
214$(MSGDOMAIN):
215	$(INS.dir)
216
217cscope.out tags: FRC
218	$(XREF) -x $@
219
220FRC:
221# include MACH-specific library targets
222include ../Makefile.mach
223