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