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