xref: /titanic_41/usr/src/lib/Makefile.lib (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
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 2004 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
27#
28# Definitions common to libraries.
29#
30# include global definitions; SRC should be defined in the shell.
31# SRC is needed until RFE 1026993 is implemented.
32
33include		$(SRC)/Makefile.master
34
35LORDER=		lorder
36TSORT=		tsort
37AWK=		awk
38
39MAPFILE-FLTR=	$(SRC)/lib/common/mapfile-filter
40
41NX_MAP_i386=	$(SRC)/cmd/mapfile_noexdata
42NX_MAP_sparc=
43
44NX_MAP=		$(NX_MAP_$(MACH))
45
46#
47# If HDRDIR is left unset, then it's possible for the $(ROOTHDRDIR)/%
48# install rule in lib/Makefile.targ to generate false matches if there
49# are any common directory names between / and /usr/include (`xfn' is
50# one common example).  To prevent this, we set HDRDIR to a directory
51# name that will almost surely not exist on the build machine.
52#
53HDRDIR=		/__nonexistent_directory__
54SRCDIR=		.
55#
56# We don't build archive (*.a) libraries by default anymore.
57# If a component of the build needs to build an archive library
58# for its own internal purposes, it can define LIBS for itself
59# after including Makefile.lib, like this:
60# 	LIBS = $(LIBRARY)
61# or:
62# 	LIBS = $(LIBRARYCCC)
63# Archive libraries must not be installed in the proto area.
64#
65LIBS=
66MACHLIBS=	$(LIBS:%=$(MACH)/%)
67MACHLIBS64=	$(LIBS:%=$(MACH64)/%)
68DYNLIB=		$(LIBRARY:.a=.so$(VERS))
69DYNLIBPSR=	$(LIBRARY:.a=_psr.so$(VERS))
70DYNLIBCCC=	$(LIBRARYCCC:.a=.so$(VERS))
71LIBLINKS=	$(LIBRARY:.a=.so)
72LIBLINKSCCC=	$(LIBRARYCCC:.a=.so)
73LIBNAME=	$(LIBRARY:lib%.a=%)
74LIBLINKPATH=
75LIBNULL=	null.a
76ROOTHDRDIR=	$(ROOT)/usr/include
77ROOTLIBDIR=	$(ROOT)/usr/lib
78ROOTLIBDIR64=	$(ROOT)/usr/lib/$(MACH64)
79ROOTFS_LIBDIR=	$(ROOT)/lib
80ROOTFS_LIBDIR64=	$(ROOT)/lib/$(MACH64)
81ROOTLINTDIR=	$(ROOTLIBDIR)
82ROOTFS_LINTDIR=	$(ROOTFS_LIBDIR)
83ROOTFS_LINTDIR64=	$(ROOTFS_LIBDIR64)
84ROOTHDRS=	$(HDRS:%=$(ROOTHDRDIR)/%)
85HDRSRCS=	$(HDRS:%=$(HDRDIR)/%)
86CHECKHDRS=	$(HDRSRCS:%.h=%.check)
87ROOTLIBS=	$(LIBS:%=$(ROOTLIBDIR)/%)
88ROOTLIBS64=	$(LIBS:%=$(ROOTLIBDIR64)/%)
89ROOTFS_LIBS=	$(DYNLIB:%=$(ROOTFS_LIBDIR)/%)
90ROOTFS_LIBS64=	$(DYNLIB:%=$(ROOTFS_LIBDIR64)/%)
91ROOTLINKS=	$(ROOTLIBDIR)/$(LIBLINKS)
92ROOTLINKS64=	$(ROOTLIBDIR64)/$(LIBLINKS)
93ROOTFS_LINKS=	$(ROOTFS_LIBDIR)/$(LIBLINKS)
94ROOTFS_LINKS64=	$(ROOTFS_LIBDIR64)/$(LIBLINKS)
95ROOTLINKSCCC=	$(ROOTLIBDIR)/$(LIBLINKSCCC)
96ROOTLINKSCCC64=	$(ROOTLIBDIR64)/$(LIBLINKSCCC)
97ROOTFS_LINKSCCC=	$(ROOTFS_LIBDIR)/$(LIBLINKSCCC)
98ROOTFS_LINKSCCC64=	$(ROOTFS_LIBDIR64)/$(LIBLINKSCCC)
99ROOTLINT=	$(LINTSRC:%=$(ROOTLINTDIR)/%)
100ROOTFS_LINT=	$(LINTSRC:%=$(ROOTFS_LINTDIR)/%)
101ROOTFS_LINT64=	$(LINTSRC:%=$(ROOTFS_LINTDIR64)/%)
102ROOTMAN3=     $(ROOT)/usr/share/man/man3
103ROOTMAN3FILES=        $(MAN3FILES:%=$(ROOTMAN3)/%)
104$(ROOTMAN3FILES) := FILEMODE= 444
105$(ROOTMAN3FILES) := OWNER= root
106$(ROOTMAN3FILES) := GROUP= bin
107
108#
109# Begin /usr/sfw freeware rules for freeware that has "External"
110# taxonomy stability level.
111#
112ROOTSFW=	$(ROOT)/usr/sfw
113ROOTSFWBIN=	$(ROOT)/usr/sfw/bin
114ROOTSFWSBIN=	$(ROOT)/usr/sfw/sbin
115ROOTSFWETC=	$(ROOT)/etc/sfw
116ROOTSFWVAR=	$(ROOT)/var/sfw
117ROOTSFWSHARE=	$(ROOT)/usr/sfw/share
118ROOTSFWSHSRC=	$(ROOT)/usr/sfw/share/src
119ROOTSFWINCLUDE=	$(ROOT)/usr/sfw/include
120ROOTSFWLIB=	$(ROOT)/usr/sfw/lib
121ROOTSFWLIB64=	$(ROOT)/usr/sfw/lib/$(MACH64)
122ROOTSFWMAN=	$(ROOT)/usr/sfw/share/man
123ROOTSFWMANN=	$(ROOT)/usr/sfw/share/mann
124ROOTSFWMAN1=	$(ROOT)/usr/sfw/share/man/man1
125ROOTSFWMAN1M=	$(ROOT)/usr/sfw/share/man/man1m
126ROOTSFWMAN3=	$(ROOT)/usr/sfw/share/man/man3
127ROOTSFWMAN5=	$(ROOT)/usr/sfw/share/man/man5
128ROOTSFWMAN7=	$(ROOT)/usr/sfw/share/man/man7
129#
130# End /usr/sfw freeware rules
131#
132
133LINTLIB=	llib-l$(LIBNAME).ln
134LINTFLAGS=	-uaxm
135LINTFLAGS64=	-uaxm -Xarch=$(MACH64:sparcv9=v9)
136LINTSRC=	$(LINTLIB:%.ln=%)
137LINTOUT=	lint.out
138ARFLAGS=	r
139SONAME=		$(DYNLIB)
140# For most libraries, we should be able to resolve all symbols at link time,
141# either within the library or as dependencies, all text should be pure, and
142# combining relocations into one relocation table reduces startup costs.
143# All options are tunable to allow overload/omission from lower makefiles.
144
145
146HSONAME=	-h$(SONAME)
147DYNFLAGS=	$(HSONAME) $(ZTEXT) $(ZDEFS) $(ZCOMBRELOC) \
148		$(SPECMAPFILE:%=-M%) $(PGA_MAPFILE:%=-M%) $(NX_MAP:%=-M%)
149
150LDLIBS=		$(LDLIBS.lib)
151
152OBJS=		$(OBJECTS:%=objs/%)
153PICS=		$(OBJECTS:%=pics/%)
154
155# Declare that all library .o's can all be made in parallel.
156# The DUMMY target is for those instances where OBJS and PICS
157# are empty (to avoid an unconditional .PARALLEL declaration).
158.PARALLEL:	$(OBJS) $(PICS) DUMMY
159
160# default value for "portable" source
161SRCS=		$(OBJECTS:%.o=$(SRCDIR)/%.c)
162
163# default build of an archive and a shared object,
164# overridden locally when extra processing is needed
165BUILD.AR=	$(AR) $(ARFLAGS) $@ $(AROBJS)
166BUILD.SO=	$(CC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
167BUILDCCC.SO=	$(CCC) -o $@ $(GSHARED) $(DYNFLAGS) $(PICS) $(LDLIBS)
168
169# default dynamic library symlink
170INS.liblink=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
171INS.liblinkccc=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
172
173# default 64-bit dynamic library symlink
174INS.liblink64=	-$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKS)$(VERS) $@
175INS.liblinkccc64= -$(RM) $@; $(SYMLINK) $(LIBLINKPATH)$(LIBLINKSCCC)$(VERS) $@
176
177#
178# If appropriate, augment POST_PROCESS_O and POST_PROCESS_SO to do CTF
179# processing.  We'd like to just conditionally append to POST_PROCESS_O and
180# POST_PROCESS_SO, but ParallelMake has a bug which causes the same value to
181# sometimes get appended more than once, which will cause ctfconvert to fail.
182# So, instead we introduce CTFCONVERT_POST and CTFMERGE_POST, which are always
183# appended to POST_PROCESS_O and POST_PROCESS_SO but are no-ops unless CTF
184# processing should be done.
185#
186CTFCONVERT_POST = :
187CTFMERGE_POST	= :
188POST_PROCESS_O += ; $(CTFCONVERT_POST)
189POST_PROCESS_SO += ; $(CTFMERGE_POST)
190
191CTFMERGE_LIB	= $(CTFMERGE) -t -f -L VERSION -o $@ $(PICS)
192
193# conditional assignments
194
195$(OBJS)  :=	sparc_CFLAGS += -xregs=no%appl
196
197$(PICS)  :=	sparc_CFLAGS += -xregs=no%appl $(sparc_C_PICFLAGS)
198$(PICS)  :=	sparcv9_CFLAGS += -xregs=no%appl $(sparcv9_C_PICFLAGS)
199$(PICS)  :=	i386_CFLAGS += $(i386_C_PICFLAGS)
200$(PICS)  :=	amd64_CFLAGS += $(amd64_C_PICFLAGS)
201$(PICS)  :=	CCFLAGS += $(CC_PICFLAGS)
202$(PICS)  :=	CPPFLAGS += -DPIC -D_REENTRANT
203$(PICS)  :=	sparcv9_CCFLAGS += -xregs=no%appl $(sparcv9_CC_PICFLAGS)
204$(PICS)  :=	amd64_CCFLAGS += $(amd64_CC_PICFLAGS)
205$(PICS)  :=	CFLAGS += $(CTF_FLAGS)
206$(PICS)	 :=	CFLAGS64 += $(CTF_FLAGS)
207$(PICS)  :=	CTFCONVERT_POST = $(CTFCONVERT_O)
208$(DYNLIB) :=	CTFMERGE_POST = $(CTFMERGE_LIB)
209
210$(LINTLIB):=	LOG = -DLOGGING
211$(LIBRARY):=	AROBJS = $(OBJS)
212$(LIBRARY):=	DIR = objs
213$(DYNLIB):=	DIR = pics
214$(DYNLIBCCC):=	DIR = pics
215
216SONAMECCC=	$(DYNLIBCCC)
217HSONAMECCC=	-h $(SONAMECCC)
218#
219# Keep in sync with the standard DYNFLAGS
220#
221$(DYNLIBCCC):=	DYNFLAGS = $(HSONAMECCC) $(ZTEXT) $(ZDEFS) $(ZCOMBRELOC) \
222		$(SPECMAPFILE:%=-M%) $(PGA_MAPFILE:%=-M%) $(NX_MAP:%=-M%) \
223		$(NORUNPATH)
224
225
226# build rule for "portable" source
227objs/%.o pics/%.o: %.c
228	$(COMPILE.c) -o $@ $<
229	$(POST_PROCESS_O)
230
231objs/%.o pics/%.o: %.cc
232	$(COMPILE.cc) -o $@ $<
233	$(POST_PROCESS_O)
234
235.PRECIOUS: $(LIBS)
236
237# Define the majority text domain in this directory.
238TEXT_DOMAIN= SUNW_OST_OSLIB
239
240$(ROOTMAN3)/%: %.sunman
241	$(INS.rename)
242
243#
244# For library source code, we expect that some symbols may not be used or
245# may *appear* to be able to rescoped to static; shut lint up.  Never add
246# a flag here unless you're *sure* that all libraries need to be linted
247# with it.
248#
249LINTCHECKFLAGS = -m -erroff=E_NAME_DEF_NOT_USED2
250LINTCHECKFLAGS += -erroff=E_NAME_DECL_NOT_USED_DEF2
251
252#
253# Spec/ABI stuff
254#
255# Spectranslator Target Architecture
256TRANSMACH=	$(MACH)
257SPECMAPFILES=	$(SPECMAPFILE:%/$(MACH64)/mapfile=%/$(MACH)/mapfile)
258$(BUILD64)SPECMAPFILES += $(SPECMAPFILE:%/$(MACH)/mapfile=%/$(MACH64)/mapfile)
259
260#
261# Allow people to define their own clobber rules.  Normal makefiles
262# shouldn't override this - they should override $(CLOBBERFILES) instead.
263#
264CLOBBERTARGFILES= $(LIBS) $(DYNLIB) $(SPECMAPFILE) $(CLOBBERFILES)
265