xref: /titanic_44/usr/src/lib/README.Makefiles (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate#
2*7c478bd9Sstevel@tonic-gate# CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate#
4*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate# with the License.
8*7c478bd9Sstevel@tonic-gate#
9*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate# and limitations under the License.
13*7c478bd9Sstevel@tonic-gate#
14*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate#
20*7c478bd9Sstevel@tonic-gate# CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate#
22*7c478bd9Sstevel@tonic-gateWriting Library Makefiles in ON
23*7c478bd9Sstevel@tonic-gate===============================
24*7c478bd9Sstevel@tonic-gate
25*7c478bd9Sstevel@tonic-gate Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
26*7c478bd9Sstevel@tonic-gate Use is subject to license terms.
27*7c478bd9Sstevel@tonic-gate
28*7c478bd9Sstevel@tonic-gateident	"%Z%%M%	%I%	%E% SMI"
29*7c478bd9Sstevel@tonic-gate
30*7c478bd9Sstevel@tonic-gateIntroduction
31*7c478bd9Sstevel@tonic-gate------------
32*7c478bd9Sstevel@tonic-gate
33*7c478bd9Sstevel@tonic-gateThis document guides you through the gnarly process of writing library
34*7c478bd9Sstevel@tonic-gateMakefiles for the ON consolidation.  It assumes that you're comfortable with
35*7c478bd9Sstevel@tonic-gatemake(1) and are somewhat familiar with the ON Makefile standards outlined in
36*7c478bd9Sstevel@tonic-gate/shared/ON/general_docs/make_std.txt.
37*7c478bd9Sstevel@tonic-gate
38*7c478bd9Sstevel@tonic-gateMakefile Overview
39*7c478bd9Sstevel@tonic-gate-----------------
40*7c478bd9Sstevel@tonic-gate
41*7c478bd9Sstevel@tonic-gateYour library should consist of a hierarchical collection of Makefiles:
42*7c478bd9Sstevel@tonic-gate
43*7c478bd9Sstevel@tonic-gate	lib/<library>/Makefile:
44*7c478bd9Sstevel@tonic-gate
45*7c478bd9Sstevel@tonic-gate	  This is your library's top-level Makefile.  It should contain rules
46*7c478bd9Sstevel@tonic-gate	  for building any ISA-independent targets, such as installing header
47*7c478bd9Sstevel@tonic-gate	  files and building message catalogs, but should defer all other
48*7c478bd9Sstevel@tonic-gate	  targets to ISA-specific Makefiles.
49*7c478bd9Sstevel@tonic-gate
50*7c478bd9Sstevel@tonic-gate	lib/<library>/Makefile.com
51*7c478bd9Sstevel@tonic-gate
52*7c478bd9Sstevel@tonic-gate	  This is your library's common Makefile.  It should contain rules
53*7c478bd9Sstevel@tonic-gate	  and macros which are common to all ISAs. This Makefile should never
54*7c478bd9Sstevel@tonic-gate	  be built explicitly, but instead should be included (using the make
55*7c478bd9Sstevel@tonic-gate	  include mechanism) by all of your ISA-specific Makefiles.
56*7c478bd9Sstevel@tonic-gate
57*7c478bd9Sstevel@tonic-gate	lib/<library>/<isa>/Makefile
58*7c478bd9Sstevel@tonic-gate
59*7c478bd9Sstevel@tonic-gate	  These are your library's ISA-specific Makefiles, one per ISA
60*7c478bd9Sstevel@tonic-gate	  (usually sparc and i386, and sometimes sparcv9 and ia64).  These
61*7c478bd9Sstevel@tonic-gate	  Makefiles should include your common Makefile and then provide any
62*7c478bd9Sstevel@tonic-gate	  needed ISA-specific rules and definitions, perhaps overriding those
63*7c478bd9Sstevel@tonic-gate	  provided in your common Makefile.
64*7c478bd9Sstevel@tonic-gate
65*7c478bd9Sstevel@tonic-gateTo simplify their maintenance and construction, $(SRC)/lib has a handful of
66*7c478bd9Sstevel@tonic-gateprovided Makefiles that yours must include; the examples provided throughout
67*7c478bd9Sstevel@tonic-gatethe document will show how to use them.  Please be sure to consult these
68*7c478bd9Sstevel@tonic-gateMakefiles before introducing your own custom build macros or rules.
69*7c478bd9Sstevel@tonic-gate
70*7c478bd9Sstevel@tonic-gate	lib/Makefile.lib:
71*7c478bd9Sstevel@tonic-gate
72*7c478bd9Sstevel@tonic-gate	  This contains the bulk of the macros for building shared objects.
73*7c478bd9Sstevel@tonic-gate
74*7c478bd9Sstevel@tonic-gate	lib/Makefile.lib.64
75*7c478bd9Sstevel@tonic-gate
76*7c478bd9Sstevel@tonic-gate	  This contains macros for building 64-bit objects, and should be
77*7c478bd9Sstevel@tonic-gate	  included in Makfiles for 64-bit native ISAs.
78*7c478bd9Sstevel@tonic-gate
79*7c478bd9Sstevel@tonic-gate	lib/Makefile.rootfs
80*7c478bd9Sstevel@tonic-gate
81*7c478bd9Sstevel@tonic-gate	  This contains macro overrides for libraries that install into /lib
82*7c478bd9Sstevel@tonic-gate	  (rather than /usr/lib).
83*7c478bd9Sstevel@tonic-gate
84*7c478bd9Sstevel@tonic-gate	lib/Makefile.targ
85*7c478bd9Sstevel@tonic-gate
86*7c478bd9Sstevel@tonic-gate	  This contains rules for building shared objects.
87*7c478bd9Sstevel@tonic-gate
88*7c478bd9Sstevel@tonic-gateThe remainder of this document discusses how to write each of your Makefiles
89*7c478bd9Sstevel@tonic-gatein detail, and provides examples from the libinetutil library.
90*7c478bd9Sstevel@tonic-gate
91*7c478bd9Sstevel@tonic-gateThe Library Top-level Makefile
92*7c478bd9Sstevel@tonic-gate------------------------------
93*7c478bd9Sstevel@tonic-gate
94*7c478bd9Sstevel@tonic-gateAs described above, your top-level library Makefile should contain
95*7c478bd9Sstevel@tonic-gaterules for building ISA-independent targets, but should defer the
96*7c478bd9Sstevel@tonic-gatebuilding of all other targets to ISA-specific Makefiles.  The
97*7c478bd9Sstevel@tonic-gateISA-independent targets usually consist of:
98*7c478bd9Sstevel@tonic-gate
99*7c478bd9Sstevel@tonic-gate	install_h
100*7c478bd9Sstevel@tonic-gate
101*7c478bd9Sstevel@tonic-gate	  Install all library header files into the proto area.  Can be
102*7c478bd9Sstevel@tonic-gate	  omitted if your library has no header files.
103*7c478bd9Sstevel@tonic-gate
104*7c478bd9Sstevel@tonic-gate	check
105*7c478bd9Sstevel@tonic-gate
106*7c478bd9Sstevel@tonic-gate	  Check all library header files for hdrchk compliance.  Can be
107*7c478bd9Sstevel@tonic-gate	  omitted if your library has no header files.
108*7c478bd9Sstevel@tonic-gate
109*7c478bd9Sstevel@tonic-gate	_msg
110*7c478bd9Sstevel@tonic-gate
111*7c478bd9Sstevel@tonic-gate	  Build and install a message catalog.  Can be omitted if your
112*7c478bd9Sstevel@tonic-gate	  library has no message catalog.
113*7c478bd9Sstevel@tonic-gate
114*7c478bd9Sstevel@tonic-gateOf course, other targets are (such as `cstyle') are fine as well, as long as
115*7c478bd9Sstevel@tonic-gatethey are ISA-independent.
116*7c478bd9Sstevel@tonic-gate
117*7c478bd9Sstevel@tonic-gateThe ROOTHDRS and CHECKHDRS targets are provided in lib/Makefile.lib to make
118*7c478bd9Sstevel@tonic-gateit easy for you to install and check your library's header files.  To use
119*7c478bd9Sstevel@tonic-gatethese targets, your Makefile must set the HDRS to the list of your library's
120*7c478bd9Sstevel@tonic-gateheader files to install and HDRDIR to the their location in the source tree.
121*7c478bd9Sstevel@tonic-gateIn addition, if your header files need to be installed in a location other
122*7c478bd9Sstevel@tonic-gatethan $(ROOT)/usr/include, your Makefile must also set ROOTHDRDIR to the
123*7c478bd9Sstevel@tonic-gateappropriate location in the proto area.  Once HDRS, HDRDIR and (optionally)
124*7c478bd9Sstevel@tonic-gateROOTHDRDIR have been set, your Makefile need only contain
125*7c478bd9Sstevel@tonic-gate
126*7c478bd9Sstevel@tonic-gate	  install_h: $(ROOTHDRS)
127*7c478bd9Sstevel@tonic-gate
128*7c478bd9Sstevel@tonic-gate	  check: $(CHECKHDRS)
129*7c478bd9Sstevel@tonic-gate
130*7c478bd9Sstevel@tonic-gateto bind the provided targets to the standard `install_h' and `check' rules.
131*7c478bd9Sstevel@tonic-gate
132*7c478bd9Sstevel@tonic-gateSimilar rules are provided (in $(SRC)/Makefile.msg.targ) to make it easy for
133*7c478bd9Sstevel@tonic-gateyou to build and install message catalogs from your library's source files.
134*7c478bd9Sstevel@tonic-gate
135*7c478bd9Sstevel@tonic-gateTo install a catalog into the catalog directory in the proto area, define the
136*7c478bd9Sstevel@tonic-gatePOFILE macro to be the name of your catalog, and specify that the _msg target
137*7c478bd9Sstevel@tonic-gatedepends on $(MSGDOMAINPOFILE).  The examples below should clarify this.
138*7c478bd9Sstevel@tonic-gate
139*7c478bd9Sstevel@tonic-gateTo build a message catalog from arbitrarily many message source files, use
140*7c478bd9Sstevel@tonic-gatethe BUILDPO.msgfiles macro.
141*7c478bd9Sstevel@tonic-gate
142*7c478bd9Sstevel@tonic-gate	  include ../Makefile.lib
143*7c478bd9Sstevel@tonic-gate
144*7c478bd9Sstevel@tonic-gate	  POFILE =	  libfoo.po
145*7c478bd9Sstevel@tonic-gate	  MSGFILES =	  $(OBJECTS:%.o=%.i)
146*7c478bd9Sstevel@tonic-gate
147*7c478bd9Sstevel@tonic-gate	  # ...
148*7c478bd9Sstevel@tonic-gate
149*7c478bd9Sstevel@tonic-gate	  $(POFILE): $(MSGFILES)
150*7c478bd9Sstevel@tonic-gate		$(BUILDPO.msgfiles)
151*7c478bd9Sstevel@tonic-gate
152*7c478bd9Sstevel@tonic-gate	  _msg: $(MSGDOMAINPOFILE)
153*7c478bd9Sstevel@tonic-gate
154*7c478bd9Sstevel@tonic-gate	  include $(SRC)/Makefile.msg.targ
155*7c478bd9Sstevel@tonic-gate
156*7c478bd9Sstevel@tonic-gateNote that this example doesn't use grep to find message files, since that can
157*7c478bd9Sstevel@tonic-gatemask unreferenced files, and potentially lead to the inclusion of unwanted
158*7c478bd9Sstevel@tonic-gatemessages or omission of intended messages in the catalogs.  As such, MSGFILES
159*7c478bd9Sstevel@tonic-gateshould be derived from a known list of objects or sources.
160*7c478bd9Sstevel@tonic-gate
161*7c478bd9Sstevel@tonic-gateIt is usually preferable to run the source through the C preprocessor prior
162*7c478bd9Sstevel@tonic-gateto extracting messages.  To do this, use the ".i" suffix, as shown in the
163*7c478bd9Sstevel@tonic-gateabove example.  If you need to skip the C preprocessor, just use the native
164*7c478bd9Sstevel@tonic-gate(.[ch]) suffix.
165*7c478bd9Sstevel@tonic-gate
166*7c478bd9Sstevel@tonic-gateThe only time you shouldn't use BUILDPO.msgfiles as the preferred means of
167*7c478bd9Sstevel@tonic-gateextracting messages in when you're extracting them from shell scripts; in
168*7c478bd9Sstevel@tonic-gatethat case, you can use the BUILDPO.pofiles macro as explained below.
169*7c478bd9Sstevel@tonic-gate
170*7c478bd9Sstevel@tonic-gateTo build a message catalog from other message catalogs, or from source files
171*7c478bd9Sstevel@tonic-gatethat include shell scripts, use the BUILDPO.pofiles macro:
172*7c478bd9Sstevel@tonic-gate
173*7c478bd9Sstevel@tonic-gate	  include ../Makefile.lib
174*7c478bd9Sstevel@tonic-gate
175*7c478bd9Sstevel@tonic-gate	  SUBDIRS =	  $(MACH)
176*7c478bd9Sstevel@tonic-gate
177*7c478bd9Sstevel@tonic-gate	  POFILE =	  libfoo.po
178*7c478bd9Sstevel@tonic-gate	  POFILES =	  $(SUBDIRS:%=%/_%.po)
179*7c478bd9Sstevel@tonic-gate
180*7c478bd9Sstevel@tonic-gate	  _msg :=	  TARGET = _msg
181*7c478bd9Sstevel@tonic-gate
182*7c478bd9Sstevel@tonic-gate	  # ...
183*7c478bd9Sstevel@tonic-gate
184*7c478bd9Sstevel@tonic-gate	  $(POFILE): $(POFILES)
185*7c478bd9Sstevel@tonic-gate		$(BUILDPO.pofiles)
186*7c478bd9Sstevel@tonic-gate
187*7c478bd9Sstevel@tonic-gate	  _msg: $(MSGDOMAINPOFILE)
188*7c478bd9Sstevel@tonic-gate
189*7c478bd9Sstevel@tonic-gate	  include $(SRC)/Makefile.msg.targ
190*7c478bd9Sstevel@tonic-gate
191*7c478bd9Sstevel@tonic-gateThe Makefile above would work in conjunction with the following in its
192*7c478bd9Sstevel@tonic-gatesubdirectories' Makefiles:
193*7c478bd9Sstevel@tonic-gate
194*7c478bd9Sstevel@tonic-gate	  POFILE =	  _thissubdir.po
195*7c478bd9Sstevel@tonic-gate	  MSGFILES =	  $(OBJECTS:%.o=%.i)
196*7c478bd9Sstevel@tonic-gate
197*7c478bd9Sstevel@tonic-gate	  $(POFILE):	  $(MSGFILES)
198*7c478bd9Sstevel@tonic-gate		  $(BUILDPO.msgfiles)
199*7c478bd9Sstevel@tonic-gate
200*7c478bd9Sstevel@tonic-gate	  _msg:		  $(POFILE)
201*7c478bd9Sstevel@tonic-gate
202*7c478bd9Sstevel@tonic-gate	  include $(SRC)/Makefile.msg.targ
203*7c478bd9Sstevel@tonic-gate
204*7c478bd9Sstevel@tonic-gateSince this POFILE will be combined with those in other subdirectories by the
205*7c478bd9Sstevel@tonic-gateparent Makefile and that merged file will be installed into the proto area
206*7c478bd9Sstevel@tonic-gatevia MSGDOMAINPOFILE, there is no need to use MSGDOMAINPOFILE in this Makefile
207*7c478bd9Sstevel@tonic-gate(in fact, using it would lead to duplicate messages in the catalog).
208*7c478bd9Sstevel@tonic-gate
209*7c478bd9Sstevel@tonic-gateWhen using any of these targets, keep in mind that other macros, like
210*7c478bd9Sstevel@tonic-gateXGETFLAGS and TEXT_DOMAIN may also be set in your Makefile to override or
211*7c478bd9Sstevel@tonic-gateaugment the defaults provided in higher-level Makefiles.
212*7c478bd9Sstevel@tonic-gate
213*7c478bd9Sstevel@tonic-gateAs previously mentioned, you should defer all ISA-specific targets to your
214*7c478bd9Sstevel@tonic-gateISA-specific Makefiles.  You can do this by:
215*7c478bd9Sstevel@tonic-gate
216*7c478bd9Sstevel@tonic-gate	1. Setting SUBDIRS to the list of directories to descend into:
217*7c478bd9Sstevel@tonic-gate
218*7c478bd9Sstevel@tonic-gate		SUBDIRS = $(MACH)
219*7c478bd9Sstevel@tonic-gate
220*7c478bd9Sstevel@tonic-gate	   Note that if your library is also built 64-bit, then you should
221*7c478bd9Sstevel@tonic-gate	   also specify
222*7c478bd9Sstevel@tonic-gate
223*7c478bd9Sstevel@tonic-gate		$(BUILD64)SUBDIRS += $(MACH64)
224*7c478bd9Sstevel@tonic-gate
225*7c478bd9Sstevel@tonic-gate	   so that SUBDIRS contains $(MACH64) if and only if you're compiling
226*7c478bd9Sstevel@tonic-gate	   on a 64-bit ISA.
227*7c478bd9Sstevel@tonic-gate
228*7c478bd9Sstevel@tonic-gate	2. Providing a common "descend into SUBDIRS" rule:
229*7c478bd9Sstevel@tonic-gate
230*7c478bd9Sstevel@tonic-gate		spec $(SUBDIRS): FRC
231*7c478bd9Sstevel@tonic-gate			@cd $@; pwd; $(MAKE) $(TARGET)
232*7c478bd9Sstevel@tonic-gate
233*7c478bd9Sstevel@tonic-gate		FRC:
234*7c478bd9Sstevel@tonic-gate
235*7c478bd9Sstevel@tonic-gate	3. Providing a collection of conditional assignments that set TARGET
236*7c478bd9Sstevel@tonic-gate	   appropriately:
237*7c478bd9Sstevel@tonic-gate
238*7c478bd9Sstevel@tonic-gate		all	:= TARGET= all
239*7c478bd9Sstevel@tonic-gate		clean	:= TARGET= clean
240*7c478bd9Sstevel@tonic-gate		clobber := TARGET= clobber
241*7c478bd9Sstevel@tonic-gate		install := TARGET= install
242*7c478bd9Sstevel@tonic-gate		lint	:= TARGET= lint
243*7c478bd9Sstevel@tonic-gate
244*7c478bd9Sstevel@tonic-gate	   The order doesn't matter, but alphabetical is preferable.
245*7c478bd9Sstevel@tonic-gate
246*7c478bd9Sstevel@tonic-gate	4. Having the aforementioned targets depend on SUBDIRS:
247*7c478bd9Sstevel@tonic-gate
248*7c478bd9Sstevel@tonic-gate		all clean clobber install: spec .WAIT $(SUBDIRS)
249*7c478bd9Sstevel@tonic-gate
250*7c478bd9Sstevel@tonic-gate		lint: $(SUBDIRS)
251*7c478bd9Sstevel@tonic-gate
252*7c478bd9Sstevel@tonic-gate	   A few notes are in order here:
253*7c478bd9Sstevel@tonic-gate
254*7c478bd9Sstevel@tonic-gate		* The `all' target must be listed first; the others might as
255*7c478bd9Sstevel@tonic-gate		  well be listed alphabetically.
256*7c478bd9Sstevel@tonic-gate
257*7c478bd9Sstevel@tonic-gate		* The `lint' target is listed separately because there is
258*7c478bd9Sstevel@tonic-gate		  nothing to lint in the spec subdirectory.
259*7c478bd9Sstevel@tonic-gate
260*7c478bd9Sstevel@tonic-gate		* The .WAIT between spec and $(SUBDIRS) is suboptimal but
261*7c478bd9Sstevel@tonic-gate		  currently required to make sure that two different make
262*7c478bd9Sstevel@tonic-gate		  invocations don't simultaneously build the mapfiles.  It
263*7c478bd9Sstevel@tonic-gate		  will likely be replaced with a more sophisticated
264*7c478bd9Sstevel@tonic-gate		  mechanism in the future.
265*7c478bd9Sstevel@tonic-gate
266*7c478bd9Sstevel@tonic-gateAs an example of how all of this goes together, here's libinetutil's
267*7c478bd9Sstevel@tonic-gatetop-level library Makefile (copyright omitted):
268*7c478bd9Sstevel@tonic-gate
269*7c478bd9Sstevel@tonic-gate		include ../Makefile.lib
270*7c478bd9Sstevel@tonic-gate
271*7c478bd9Sstevel@tonic-gate		HDRS =		libinetutil.h
272*7c478bd9Sstevel@tonic-gate		HDRDIR =	common
273*7c478bd9Sstevel@tonic-gate		SUBDIRS =	$(MACH)
274*7c478bd9Sstevel@tonic-gate		$(BUILD64)SUBDIRS += $(MACH64)
275*7c478bd9Sstevel@tonic-gate
276*7c478bd9Sstevel@tonic-gate		all :=		TARGET = all
277*7c478bd9Sstevel@tonic-gate		clean :=	TARGET = clean
278*7c478bd9Sstevel@tonic-gate		clobber :=	TARGET = clobber
279*7c478bd9Sstevel@tonic-gate		install :=	TARGET = install
280*7c478bd9Sstevel@tonic-gate		lint :=		TARGET = lint
281*7c478bd9Sstevel@tonic-gate
282*7c478bd9Sstevel@tonic-gate		.KEEP_STATE:
283*7c478bd9Sstevel@tonic-gate
284*7c478bd9Sstevel@tonic-gate		all clean clobber install: spec .WAIT $(SUBDIRS)
285*7c478bd9Sstevel@tonic-gate
286*7c478bd9Sstevel@tonic-gate		lint:		$(SUBDIRS)
287*7c478bd9Sstevel@tonic-gate
288*7c478bd9Sstevel@tonic-gate		install_h:	$(ROOTHDRS)
289*7c478bd9Sstevel@tonic-gate
290*7c478bd9Sstevel@tonic-gate		check:		$(CHECKHDRS)
291*7c478bd9Sstevel@tonic-gate
292*7c478bd9Sstevel@tonic-gate		$(SUBDIRS) spec: FRC
293*7c478bd9Sstevel@tonic-gate			@cd $@; pwd; $(MAKE) $(TARGET)
294*7c478bd9Sstevel@tonic-gate
295*7c478bd9Sstevel@tonic-gate		FRC:
296*7c478bd9Sstevel@tonic-gate
297*7c478bd9Sstevel@tonic-gate		include ../Makefile.targ
298*7c478bd9Sstevel@tonic-gate
299*7c478bd9Sstevel@tonic-gateThe Common Makefile
300*7c478bd9Sstevel@tonic-gate-------------------
301*7c478bd9Sstevel@tonic-gate
302*7c478bd9Sstevel@tonic-gateIn concept, your common Makefile should contain all of the rules and
303*7c478bd9Sstevel@tonic-gatedefinitions that are the same on all ISAs.  However, for reasons of
304*7c478bd9Sstevel@tonic-gatemaintainability and cleanliness, you're encouraged to place even
305*7c478bd9Sstevel@tonic-gateISA-dependent rules and definitions, as long you express them in an
306*7c478bd9Sstevel@tonic-gateISA-independent way (e.g., by using $(MACH), $(TRANSMACH), and their kin).
307*7c478bd9Sstevel@tonic-gate
308*7c478bd9Sstevel@tonic-gateThe common Makefile can be conceptually split up into four sections:
309*7c478bd9Sstevel@tonic-gate
310*7c478bd9Sstevel@tonic-gate	1. A copyright and comments section.  Please see the prototype
311*7c478bd9Sstevel@tonic-gate	   files in usr/src/prototypes for examples of how to format the
312*7c478bd9Sstevel@tonic-gate	   copyright message properly.  For brevity and clarity, this
313*7c478bd9Sstevel@tonic-gate	   section has been omitted from the examples shown here.
314*7c478bd9Sstevel@tonic-gate
315*7c478bd9Sstevel@tonic-gate	2. A list of macros that must be defined prior to the inclusion of
316*7c478bd9Sstevel@tonic-gate	   Makefile.lib.  This section is conceptually terminated by the
317*7c478bd9Sstevel@tonic-gate	   inclusion of Makefile.lib, followed, if necessary, by the
318*7c478bd9Sstevel@tonic-gate	   inclusion of Makefile.rootfs (only if the library is to be
319*7c478bd9Sstevel@tonic-gate	   installed in /lib rather than the default /usr/lib).
320*7c478bd9Sstevel@tonic-gate
321*7c478bd9Sstevel@tonic-gate	3. A list of macros that need not be defined prior to the inclusion
322*7c478bd9Sstevel@tonic-gate	   of Makefile.lib (or which must be defined following the inclusion
323*7c478bd9Sstevel@tonic-gate	   of Makefile.lib, to override or augment its definitions).  This
324*7c478bd9Sstevel@tonic-gate	   section is conceptually terminated by the .KEEP_STATE directive.
325*7c478bd9Sstevel@tonic-gate
326*7c478bd9Sstevel@tonic-gate	4. A list of targets.
327*7c478bd9Sstevel@tonic-gate
328*7c478bd9Sstevel@tonic-gateThe first section is self-explanatory.  The second typically consists of the
329*7c478bd9Sstevel@tonic-gatefollowing macros:
330*7c478bd9Sstevel@tonic-gate
331*7c478bd9Sstevel@tonic-gate	LIBRARY
332*7c478bd9Sstevel@tonic-gate
333*7c478bd9Sstevel@tonic-gate	  Set to the name of the static version of your library, such
334*7c478bd9Sstevel@tonic-gate	  as `libinetutil.a'.  You should always specify the `.a' suffix,
335*7c478bd9Sstevel@tonic-gate	  since pattern-matching rules in higher-level Makefiles rely on it,
336*7c478bd9Sstevel@tonic-gate	  even though static libraries are not normally built in ON, and
337*7c478bd9Sstevel@tonic-gate	  are never installed in the proto area.  Note that the LIBS macro
338*7c478bd9Sstevel@tonic-gate	  (described below) controls the types of libraries that are built
339*7c478bd9Sstevel@tonic-gate	  when building your library.
340*7c478bd9Sstevel@tonic-gate
341*7c478bd9Sstevel@tonic-gate	  If you are building a loadable module (i.e., a shared object that
342*7c478bd9Sstevel@tonic-gate	  is only linked at runtime with dlopen(3dl)), specify the name of
343*7c478bd9Sstevel@tonic-gate	  the loadable module with a `.a' suffix, such as `devfsadm_mod.a'.
344*7c478bd9Sstevel@tonic-gate
345*7c478bd9Sstevel@tonic-gate	VERS
346*7c478bd9Sstevel@tonic-gate
347*7c478bd9Sstevel@tonic-gate	  Set to the version of your shared library, such as `.1'.  You
348*7c478bd9Sstevel@tonic-gate	  actually do not need to set this prior to the inclusion of
349*7c478bd9Sstevel@tonic-gate	  Makefile.lib, but it is good practice to do so since VERS and
350*7c478bd9Sstevel@tonic-gate	  LIBRARY are so closely related.
351*7c478bd9Sstevel@tonic-gate
352*7c478bd9Sstevel@tonic-gate	OBJECTS
353*7c478bd9Sstevel@tonic-gate
354*7c478bd9Sstevel@tonic-gate	  Set to the list of object files contained in your library, such as
355*7c478bd9Sstevel@tonic-gate	  `a.o b.o'.  Usually, this will be the same as your library's source
356*7c478bd9Sstevel@tonic-gate	  files (except with .o extensions), but if your library compiles
357*7c478bd9Sstevel@tonic-gate	  source files outside of the library directory itself, it will
358*7c478bd9Sstevel@tonic-gate	  differ.  We'll see an example of this with libinetutil.
359*7c478bd9Sstevel@tonic-gate
360*7c478bd9Sstevel@tonic-gateThe third section typically consists of the following macros:
361*7c478bd9Sstevel@tonic-gate
362*7c478bd9Sstevel@tonic-gate	LIBS
363*7c478bd9Sstevel@tonic-gate
364*7c478bd9Sstevel@tonic-gate	  Set to the list of the types of libraries to build when building
365*7c478bd9Sstevel@tonic-gate	  your library.  For dynamic libraries, you should set this to
366*7c478bd9Sstevel@tonic-gate	  `$(DYNLIB) $(LINTLIB)' so that a dynamic library and lint library
367*7c478bd9Sstevel@tonic-gate	  are built.  For loadable modules, you should just list DYNLIB,
368*7c478bd9Sstevel@tonic-gate	  since there's no point in building a lint library for libraries
369*7c478bd9Sstevel@tonic-gate	  that are never linked at compile-time.
370*7c478bd9Sstevel@tonic-gate
371*7c478bd9Sstevel@tonic-gate	  If your library needs to be built as a static library (typically
372*7c478bd9Sstevel@tonic-gate	  to be used in other parts of the build), you should set LIBS to
373*7c478bd9Sstevel@tonic-gate	  `$(LIBRARY)'.  However, you should do this only when absolutely
374*7c478bd9Sstevel@tonic-gate	  necessary, and you must *never* ship static libraries to customers.
375*7c478bd9Sstevel@tonic-gate
376*7c478bd9Sstevel@tonic-gate	ROOTLIBDIR (if your library installs to a nonstandard directory)
377*7c478bd9Sstevel@tonic-gate
378*7c478bd9Sstevel@tonic-gate	  Set to the directory your 32-bit shared objects will install into
379*7c478bd9Sstevel@tonic-gate	  with the standard $(ROOTxxx) macros.  Since this defaults to
380*7c478bd9Sstevel@tonic-gate	  $(ROOT)/usr/lib ($(ROOT)/lib if you included Makefile.rootfs),
381*7c478bd9Sstevel@tonic-gate	  you usually do not need to set this.
382*7c478bd9Sstevel@tonic-gate
383*7c478bd9Sstevel@tonic-gate	ROOTLIBDIR64 (if your library installs to a nonstandard directory)
384*7c478bd9Sstevel@tonic-gate
385*7c478bd9Sstevel@tonic-gate	  Set to the directory your 64-bit shared objects will install into
386*7c478bd9Sstevel@tonic-gate	  with the standard $(ROOTxxx64) macros.  Since this defaults to
387*7c478bd9Sstevel@tonic-gate	  $(ROOT)/usr/lib/$(MACH64) ($(ROOT)/lib/$(MACH64) if you included
388*7c478bd9Sstevel@tonic-gate	  Makefile.rootfs), you usually do not need to set this.
389*7c478bd9Sstevel@tonic-gate
390*7c478bd9Sstevel@tonic-gate	SRCDIR
391*7c478bd9Sstevel@tonic-gate
392*7c478bd9Sstevel@tonic-gate	  Set to the directory containing your library's source files, such
393*7c478bd9Sstevel@tonic-gate	  as `../common'.  Because this Makefile is actually included from
394*7c478bd9Sstevel@tonic-gate	  your ISA-specific Makefiles, make sure you specify the directory
395*7c478bd9Sstevel@tonic-gate	  relative to your library's <isa> directory.
396*7c478bd9Sstevel@tonic-gate
397*7c478bd9Sstevel@tonic-gate	SRCS (if necessary)
398*7c478bd9Sstevel@tonic-gate
399*7c478bd9Sstevel@tonic-gate	  Set to the list of source files required to build your library.
400*7c478bd9Sstevel@tonic-gate	  This defaults to $(OBJECTS:%.o=$(SRCDIR)/%.c) in Makefile.lib, so
401*7c478bd9Sstevel@tonic-gate	  you only need to set this when source files from directories other
402*7c478bd9Sstevel@tonic-gate	  than SRCDIR are needed.  Keep in mind that SRCS should be set to a
403*7c478bd9Sstevel@tonic-gate	  list of source file *pathnames*, not just a list of filenames.
404*7c478bd9Sstevel@tonic-gate
405*7c478bd9Sstevel@tonic-gate	LINTLIB-specific SRCS (required if building a lint library)
406*7c478bd9Sstevel@tonic-gate
407*7c478bd9Sstevel@tonic-gate	  Set to a special "lint stubs" file to use when constructing your
408*7c478bd9Sstevel@tonic-gate	  library's lint library.  The lint stubs file must be used to
409*7c478bd9Sstevel@tonic-gate	  guarantee that programs that link against your library will be able
410*7c478bd9Sstevel@tonic-gate	  to lint clean.  To do this, you must conditionally set SRCS to use
411*7c478bd9Sstevel@tonic-gate	  your stubs file by specifying `LINTLIB := SRCS= $(SRCDIR)/$(LINTSRC)'
412*7c478bd9Sstevel@tonic-gate	  in your Makefile.  Of course, you do not need to set this if your
413*7c478bd9Sstevel@tonic-gate	  library does not build a lint library.
414*7c478bd9Sstevel@tonic-gate
415*7c478bd9Sstevel@tonic-gate	LDLIBS
416*7c478bd9Sstevel@tonic-gate
417*7c478bd9Sstevel@tonic-gate	  Appended with the list of libraries and library directories needed
418*7c478bd9Sstevel@tonic-gate	  to build your library; minimally "-lc".  Note that this should
419*7c478bd9Sstevel@tonic-gate	  *never* be set, since that will inadvertently clear the library
420*7c478bd9Sstevel@tonic-gate	  search path, causing the linker to look in the wrong place for
421*7c478bd9Sstevel@tonic-gate	  the libraries.
422*7c478bd9Sstevel@tonic-gate
423*7c478bd9Sstevel@tonic-gate	  Since lint targets also make use of LDLIBS, LDLIBS *must* only
424*7c478bd9Sstevel@tonic-gate	  contain -l and -L directives; all other link-related directives
425*7c478bd9Sstevel@tonic-gate	  should be put in DYNFLAGS (if they apply only to shared object
426*7c478bd9Sstevel@tonic-gate	  construction) or LDFLAGS (if they apply in general).
427*7c478bd9Sstevel@tonic-gate
428*7c478bd9Sstevel@tonic-gate	MAPDIR
429*7c478bd9Sstevel@tonic-gate
430*7c478bd9Sstevel@tonic-gate	  Set to the directory in which your library mapfile is built.  If
431*7c478bd9Sstevel@tonic-gate	  your library builds its mapfile from specfiles, set this to
432*7c478bd9Sstevel@tonic-gate	  `../spec/$(TRANSMACH)' (TRANSMACH is the same as MACH for
433*7c478bd9Sstevel@tonic-gate	  32-bit targets, and the same as MACH64 for 64-bit targets).
434*7c478bd9Sstevel@tonic-gate
435*7c478bd9Sstevel@tonic-gate	MAPFILE (required if your mapfile is under source control)
436*7c478bd9Sstevel@tonic-gate
437*7c478bd9Sstevel@tonic-gate	  Set to the path to your library mapfile.  If your library builds
438*7c478bd9Sstevel@tonic-gate	  its mapfile from specfiles, this need not be set.  If you set this,
439*7c478bd9Sstevel@tonic-gate	  you must also set DYNFLAGS to include `-M $(MAPFILE)' and set
440*7c478bd9Sstevel@tonic-gate	  DYNLIB to depend on MAPFILE.
441*7c478bd9Sstevel@tonic-gate
442*7c478bd9Sstevel@tonic-gate	SPECMAPFILE (required if your mapfile is generated from specfiles)
443*7c478bd9Sstevel@tonic-gate
444*7c478bd9Sstevel@tonic-gate	  Set to the path to your generated mapfile (usually
445*7c478bd9Sstevel@tonic-gate	  `$(MAPDIR)/mapfile').  If your library mapfile is under source
446*7c478bd9Sstevel@tonic-gate	  control, you need not set this. Setting this triggers a number of
447*7c478bd9Sstevel@tonic-gate	  features in higher-level Makefiles:
448*7c478bd9Sstevel@tonic-gate
449*7c478bd9Sstevel@tonic-gate		* Your shared library will automatically be linked with
450*7c478bd9Sstevel@tonic-gate		  `-M $(SPECMAPFILE)'.
451*7c478bd9Sstevel@tonic-gate
452*7c478bd9Sstevel@tonic-gate		* A `make clobber' will remove $(SPECMAPFILE).
453*7c478bd9Sstevel@tonic-gate
454*7c478bd9Sstevel@tonic-gate		* Changes to $(SPECMAPFILE) will cause your shared library
455*7c478bd9Sstevel@tonic-gate		  to be rebuilt.
456*7c478bd9Sstevel@tonic-gate
457*7c478bd9Sstevel@tonic-gate		* An attempt to build $(SPECMAPFILE) will automatically
458*7c478bd9Sstevel@tonic-gate		  cause a `make mapfile' to be done in MAPDIR.
459*7c478bd9Sstevel@tonic-gate
460*7c478bd9Sstevel@tonic-gate	CPPFLAGS (if necessary)
461*7c478bd9Sstevel@tonic-gate
462*7c478bd9Sstevel@tonic-gate	   Appended with any flags that need to be passed to the C
463*7c478bd9Sstevel@tonic-gate	   preprocessor (typically -D and -I flags).  Since lint macros use
464*7c478bd9Sstevel@tonic-gate	   CPPFLAGS, CPPFLAGS *must* only contain directives known to the C
465*7c478bd9Sstevel@tonic-gate	   preprocessor.  When compiling MT-safe code, CPPFLAGS *must*
466*7c478bd9Sstevel@tonic-gate	   include -D_REENTRANT.  When compiling large file aware code,
467*7c478bd9Sstevel@tonic-gate	   CPPFLAGS *must* include -D_FILE_OFFSET_BITS=64.
468*7c478bd9Sstevel@tonic-gate
469*7c478bd9Sstevel@tonic-gate	CFLAGS
470*7c478bd9Sstevel@tonic-gate
471*7c478bd9Sstevel@tonic-gate	   Appended with any flags that need to be passed to the C compiler.
472*7c478bd9Sstevel@tonic-gate	   Minimally, append `$(CCVERBOSE)'.  Keep in mind that you should
473*7c478bd9Sstevel@tonic-gate	   add any C preprocessor flags to CPPFLAGS, not CFLAGS.
474*7c478bd9Sstevel@tonic-gate
475*7c478bd9Sstevel@tonic-gate	CFLAGS64 (if necessary)
476*7c478bd9Sstevel@tonic-gate
477*7c478bd9Sstevel@tonic-gate	   Appended with any flags that need to be passed to the C compiler
478*7c478bd9Sstevel@tonic-gate	   when compiling 64-bit code.  Since all 64-bit code is compiled
479*7c478bd9Sstevel@tonic-gate	   $(CCVERBOSE), you usually do not need to modify CFLAGS64.
480*7c478bd9Sstevel@tonic-gate
481*7c478bd9Sstevel@tonic-gate 	COPTFLAG (if necessary)
482*7c478bd9Sstevel@tonic-gate
483*7c478bd9Sstevel@tonic-gate	   Set to control the optimization level used by the C compiler when
484*7c478bd9Sstevel@tonic-gate	   compiling 32-bit code.  You should only set this if absolutely
485*7c478bd9Sstevel@tonic-gate	   necessary, and it should only contain optimization-related
486*7c478bd9Sstevel@tonic-gate	   settings (or -g).
487*7c478bd9Sstevel@tonic-gate
488*7c478bd9Sstevel@tonic-gate 	COPTFLAG64 (if necessary)
489*7c478bd9Sstevel@tonic-gate
490*7c478bd9Sstevel@tonic-gate	   Set to control the optimization level used by the C compiler when
491*7c478bd9Sstevel@tonic-gate	   compiling 64-bit code.  You should only set this if absolutely
492*7c478bd9Sstevel@tonic-gate	   necessary, and it should only contain optimization-related
493*7c478bd9Sstevel@tonic-gate	   settings (or -g).
494*7c478bd9Sstevel@tonic-gate
495*7c478bd9Sstevel@tonic-gate	LINTFLAGS (if necessary)
496*7c478bd9Sstevel@tonic-gate
497*7c478bd9Sstevel@tonic-gate	   Appended with any flags that need to be passed to lint when
498*7c478bd9Sstevel@tonic-gate	   linting 32-bit code.  You should only modify LINTFLAGS in
499*7c478bd9Sstevel@tonic-gate	   rare instances where your code cannot (or should not) be fixed.
500*7c478bd9Sstevel@tonic-gate
501*7c478bd9Sstevel@tonic-gate	LINTFLAGS64 (if necessary)
502*7c478bd9Sstevel@tonic-gate
503*7c478bd9Sstevel@tonic-gate	   Appended with any flags that need to be passed to lint when
504*7c478bd9Sstevel@tonic-gate	   linting 64-bit code.  You should only modify LINTFLAGS64 in
505*7c478bd9Sstevel@tonic-gate	   rare instances where your code cannot (or should not) be fixed.
506*7c478bd9Sstevel@tonic-gate
507*7c478bd9Sstevel@tonic-gateOf course, you may use other macros as necessary.
508*7c478bd9Sstevel@tonic-gate
509*7c478bd9Sstevel@tonic-gateThe fourth section typically consists of the following targets:
510*7c478bd9Sstevel@tonic-gate
511*7c478bd9Sstevel@tonic-gate	all
512*7c478bd9Sstevel@tonic-gate
513*7c478bd9Sstevel@tonic-gate	  Build all of the types of the libraries named by LIBS.  Must always
514*7c478bd9Sstevel@tonic-gate	  be the first real target in common Makefile.  Since the
515*7c478bd9Sstevel@tonic-gate	  higher-level Makefiles already contain rules to build all of the
516*7c478bd9Sstevel@tonic-gate	  different types of libraries, you can usually just specify
517*7c478bd9Sstevel@tonic-gate
518*7c478bd9Sstevel@tonic-gate		all: $(LIBS)
519*7c478bd9Sstevel@tonic-gate
520*7c478bd9Sstevel@tonic-gate	  though it should be listed as an empty target if LIBS is set by your
521*7c478bd9Sstevel@tonic-gate	  ISA-specific Makefiles (see above).
522*7c478bd9Sstevel@tonic-gate
523*7c478bd9Sstevel@tonic-gate	lint
524*7c478bd9Sstevel@tonic-gate
525*7c478bd9Sstevel@tonic-gate	  Use the `lintcheck' rule provided by lib/Makefile.targ to lint the
526*7c478bd9Sstevel@tonic-gate	  actual library sources.  Historically, this target has also been
527*7c478bd9Sstevel@tonic-gate	  used to build the lint library (using LINTLIB), but that usage is
528*7c478bd9Sstevel@tonic-gate	  now discouraged.  Thus, this rule should be specified as
529*7c478bd9Sstevel@tonic-gate
530*7c478bd9Sstevel@tonic-gate		lint: lintcheck
531*7c478bd9Sstevel@tonic-gate
532*7c478bd9Sstevel@tonic-gateConspicuously absent from this section are the `clean' and `clobber' targets.
533*7c478bd9Sstevel@tonic-gateThese targets are already provided by lib/Makefile.targ and thus should not
534*7c478bd9Sstevel@tonic-gatebe provided by your common Makefile.  Instead, your common Makefile should
535*7c478bd9Sstevel@tonic-gatelist any additional files to remove during a `clean' and `clobber' by
536*7c478bd9Sstevel@tonic-gateappending to the CLEANFILES and CLOBBERFILES macros.
537*7c478bd9Sstevel@tonic-gate
538*7c478bd9Sstevel@tonic-gateOnce again, here's libinetutil's common Makefile, which shows how many of
539*7c478bd9Sstevel@tonic-gatethese directives go together.  Note that Makefile.rootfs is included to
540*7c478bd9Sstevel@tonic-gatecause libinetutil.so.1 to be installed in /lib rather than /usr/lib:
541*7c478bd9Sstevel@tonic-gate
542*7c478bd9Sstevel@tonic-gate		LIBRARY =	libinetutil.a
543*7c478bd9Sstevel@tonic-gate		VERS =		.1
544*7c478bd9Sstevel@tonic-gate		OBJECTS =	octet.o inetutil4.o ifspec.o
545*7c478bd9Sstevel@tonic-gate
546*7c478bd9Sstevel@tonic-gate		include ../../Makefile.lib
547*7c478bd9Sstevel@tonic-gate		include ../../Makefile.rootfs
548*7c478bd9Sstevel@tonic-gate
549*7c478bd9Sstevel@tonic-gate		LIBS =		$(DYNLIB) $(LINTLIB)
550*7c478bd9Sstevel@tonic-gate		SRCS =		$(COMDIR)/octet.c $(SRCDIR)/inetutil4.c \
551*7c478bd9Sstevel@tonic-gate				$(SRCDIR)/ifspec.c
552*7c478bd9Sstevel@tonic-gate		$(LINTLIB):=	SRCS = $(SRCDIR)/$(LINTSRC)
553*7c478bd9Sstevel@tonic-gate		LDLIBS +=	-lsocket -lc
554*7c478bd9Sstevel@tonic-gate
555*7c478bd9Sstevel@tonic-gate		SRCDIR =	../common
556*7c478bd9Sstevel@tonic-gate		COMDIR =	$(SRC)/common/net/dhcp
557*7c478bd9Sstevel@tonic-gate		MAPDIR =	../spec/$(TRANSMACH)
558*7c478bd9Sstevel@tonic-gate		SPECMAPFILE =	$(MAPDIR)/mapfile
559*7c478bd9Sstevel@tonic-gate
560*7c478bd9Sstevel@tonic-gate		CFLAGS +=	$(CCVERBOSE)
561*7c478bd9Sstevel@tonic-gate		CPPFLAGS +=	-I$(SRCDIR)
562*7c478bd9Sstevel@tonic-gate
563*7c478bd9Sstevel@tonic-gate		.KEEP_STATE:
564*7c478bd9Sstevel@tonic-gate
565*7c478bd9Sstevel@tonic-gate		all: $(LIBS)
566*7c478bd9Sstevel@tonic-gate
567*7c478bd9Sstevel@tonic-gate		lint: lintcheck
568*7c478bd9Sstevel@tonic-gate
569*7c478bd9Sstevel@tonic-gate		pics/%.o: $(COMDIR)/%.c
570*7c478bd9Sstevel@tonic-gate			$(COMPILE.c) -o $@ $<
571*7c478bd9Sstevel@tonic-gate			$(POST_PROCESS_O)
572*7c478bd9Sstevel@tonic-gate
573*7c478bd9Sstevel@tonic-gate		include ../../Makefile.targ
574*7c478bd9Sstevel@tonic-gate
575*7c478bd9Sstevel@tonic-gateNote that for libinetutil, not all of the object files come from SRCDIR.  To
576*7c478bd9Sstevel@tonic-gatesupport this, an alternate source file directory named COMDIR is defined, and
577*7c478bd9Sstevel@tonic-gatethe source files listed in SRCS are specified using both COMDIR and SRCDIR.
578*7c478bd9Sstevel@tonic-gateAdditionally, a special build rule is provided to build object files from the
579*7c478bd9Sstevel@tonic-gatesources in COMDIR; the rule uses COMPILE.c and POST_PROCESS_O so that any
580*7c478bd9Sstevel@tonic-gatechanges to the compilation and object-post-processing phases will be
581*7c478bd9Sstevel@tonic-gateautomatically picked up.
582*7c478bd9Sstevel@tonic-gate
583*7c478bd9Sstevel@tonic-gateThe ISA-Specific Makefiles
584*7c478bd9Sstevel@tonic-gate--------------------------
585*7c478bd9Sstevel@tonic-gate
586*7c478bd9Sstevel@tonic-gateAs the name implies, your ISA-specific Makefiles should contain macros and
587*7c478bd9Sstevel@tonic-gaterules that cannot be expressed in an ISA-independent way.  Usually, the only
588*7c478bd9Sstevel@tonic-gaterule you will need to put here is `install', which has different dependencies
589*7c478bd9Sstevel@tonic-gatefor 32-bit and 64-bit libraries.  For instance, here are the ISA-specific
590*7c478bd9Sstevel@tonic-gateMakefiles for libinetutil:
591*7c478bd9Sstevel@tonic-gate
592*7c478bd9Sstevel@tonic-gate	sparc/Makefile:
593*7c478bd9Sstevel@tonic-gate
594*7c478bd9Sstevel@tonic-gate		include ../Makefile.com
595*7c478bd9Sstevel@tonic-gate
596*7c478bd9Sstevel@tonic-gate		install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
597*7c478bd9Sstevel@tonic-gate
598*7c478bd9Sstevel@tonic-gate	sparcv9/Makefile:
599*7c478bd9Sstevel@tonic-gate
600*7c478bd9Sstevel@tonic-gate		include ../Makefile.com
601*7c478bd9Sstevel@tonic-gate		include ../../Makefile.lib.64
602*7c478bd9Sstevel@tonic-gate
603*7c478bd9Sstevel@tonic-gate		install: all $(ROOTLIBS64) $(ROOTLINKS64)
604*7c478bd9Sstevel@tonic-gate
605*7c478bd9Sstevel@tonic-gate	i386/Makefile:
606*7c478bd9Sstevel@tonic-gate
607*7c478bd9Sstevel@tonic-gate		include ../Makefile.com
608*7c478bd9Sstevel@tonic-gate
609*7c478bd9Sstevel@tonic-gate		install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
610*7c478bd9Sstevel@tonic-gate
611*7c478bd9Sstevel@tonic-gateObserve that there is no .KEEP_STATE directive in these Makefiles, since all
612*7c478bd9Sstevel@tonic-gateof these Makefiles include libinetutil/Makefile.com, and it already has a
613*7c478bd9Sstevel@tonic-gate.KEEP_STATE directive.  Also, note that the 64-bit Makefile also includes
614*7c478bd9Sstevel@tonic-gateMakefile.lib.64, which overrides some of the definitions contained in the
615*7c478bd9Sstevel@tonic-gatehigher level Makefiles included by the common Makefile so that 64-bit
616*7c478bd9Sstevel@tonic-gatecompiles work correctly.
617*7c478bd9Sstevel@tonic-gate
618*7c478bd9Sstevel@tonic-gateCTF Data in Libraries
619*7c478bd9Sstevel@tonic-gate---------------------
620*7c478bd9Sstevel@tonic-gate
621*7c478bd9Sstevel@tonic-gateBy default, all position-indepedent objects are built with CTF data using
622*7c478bd9Sstevel@tonic-gatectfconvert, which is then merged together using ctfmerge when the shared
623*7c478bd9Sstevel@tonic-gateobject is built.  All C-source objects processed via ctfmerge need to be
624*7c478bd9Sstevel@tonic-gateprocessed via ctfconvert or the build will fail.  Objects built from non-C
625*7c478bd9Sstevel@tonic-gatesources (such as assembly or C++) are silently ignored for CTF processing.
626*7c478bd9Sstevel@tonic-gate
627*7c478bd9Sstevel@tonic-gateFilter libraries that have no source files will need to explicitly disable
628*7c478bd9Sstevel@tonic-gateCTF by setting CTFMERGE_LIB to ":"; see libw/Makefile.com for an example.
629*7c478bd9Sstevel@tonic-gate
630*7c478bd9Sstevel@tonic-gateMore Information
631*7c478bd9Sstevel@tonic-gate----------------
632*7c478bd9Sstevel@tonic-gate
633*7c478bd9Sstevel@tonic-gateOther issues and questions will undoubtedly arise while you work on your
634*7c478bd9Sstevel@tonic-gatelibrary's Makefiles.  To help in this regard, a number of libraries of
635*7c478bd9Sstevel@tonic-gatevarying complexity have been updated to follow the guidelines and practices
636*7c478bd9Sstevel@tonic-gateoutlined in this document:
637*7c478bd9Sstevel@tonic-gate
638*7c478bd9Sstevel@tonic-gate	lib/libdhcputil
639*7c478bd9Sstevel@tonic-gate
640*7c478bd9Sstevel@tonic-gate	  Example of a simple 32-bit only library.
641*7c478bd9Sstevel@tonic-gate
642*7c478bd9Sstevel@tonic-gate	lib/libdhcpagent
643*7c478bd9Sstevel@tonic-gate
644*7c478bd9Sstevel@tonic-gate	  Example of a simple 32-bit only library that obtains its sources
645*7c478bd9Sstevel@tonic-gate	  from multiple directories.
646*7c478bd9Sstevel@tonic-gate
647*7c478bd9Sstevel@tonic-gate	lib/ncad_addr
648*7c478bd9Sstevel@tonic-gate
649*7c478bd9Sstevel@tonic-gate	  Example of a simple loadable module.
650*7c478bd9Sstevel@tonic-gate
651*7c478bd9Sstevel@tonic-gate	lib/libipmp
652*7c478bd9Sstevel@tonic-gate
653*7c478bd9Sstevel@tonic-gate	  Example of a simple library that builds a message catalog.
654*7c478bd9Sstevel@tonic-gate
655*7c478bd9Sstevel@tonic-gate	lib/libdhcpsvc
656*7c478bd9Sstevel@tonic-gate
657*7c478bd9Sstevel@tonic-gate	  Example of a Makefile hierarchy for a library and a collection
658*7c478bd9Sstevel@tonic-gate	  of related pluggable modules.
659*7c478bd9Sstevel@tonic-gate
660*7c478bd9Sstevel@tonic-gate	lib/lvm
661*7c478bd9Sstevel@tonic-gate
662*7c478bd9Sstevel@tonic-gate	  Example of a Makefile hierarchy for a collection of related
663*7c478bd9Sstevel@tonic-gate	  libraries and pluggable modules.
664*7c478bd9Sstevel@tonic-gate
665*7c478bd9Sstevel@tonic-gate	  Also an example of a Makefile hierarchy that supports the
666*7c478bd9Sstevel@tonic-gate	  _dc target for domain and category specific messages.
667*7c478bd9Sstevel@tonic-gate
668*7c478bd9Sstevel@tonic-gateOf course, if you still have questions, please do not hesitate to send email
669*7c478bd9Sstevel@tonic-gateto the ON gatekeepers.
670