xref: /titanic_41/usr/src/cmd/Makefile.cmd (revision 24a1f0af9f770e0e795ef1fa1c6dece8dd8dc959)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# Definitions common to command source.
26#
27# include global definitions; SRC should be defined in the shell.
28# SRC is needed until RFE 1026993 is implemented.
29
30include $(SRC)/Makefile.master
31
32LN=		ln
33SH=		sh
34ECHO=		echo
35MKDIR=		mkdir
36TOUCH=		touch
37
38FILEMODE=	0555
39LIBFILEMODE=	0444
40XPG4=		$(XPG4PROG:%=%.xpg4)
41XPG6=		$(XPG6PROG:%=%.xpg6)
42
43KRB5DIR=	$(ROOT)/usr
44KRB5BIN=	$(KRB5DIR)/bin
45KRB5SBIN=	$(KRB5DIR)/sbin
46KRB5LIB=	$(KRB5DIR)/lib/krb5
47KRB5RUNPATH=	/usr/lib/krb5
48GSSRUNPATH=	/usr/lib/gss
49
50
51ROOTBIN=		$(ROOT)/usr/bin
52ROOTLIB=		$(ROOT)/usr/lib
53ROOTLIBSVCBIN=		$(ROOT)/lib/svc/bin
54ROOTLIBSVCMETHOD=	$(ROOT)/lib/svc/method
55ROOTLIBXEN=		$(ROOT)/usr/lib/xen/bin
56ROOTLIBZONES=		$(ROOT)/lib/zones
57
58ROOTSHLIB=	$(ROOT)/usr/share/lib
59ROOTSHLIBCCS=	$(ROOTSHLIB)/ccs
60ROOTSBIN=	$(ROOT)/sbin
61ROOTUSRSBIN=	$(ROOT)/usr/sbin
62ROOTETC=	$(ROOT)/etc
63
64ROOTETCSECURITY=	$(ROOTETC)/security
65ROOTETCTSOL=	$(ROOTETCSECURITY)/tsol
66ROOTETCSECLIB=	$(ROOTETCSECURITY)/lib
67ROOTETCZONES=	$(ROOTETC)/zones
68
69ROOTCCSBIN=	$(ROOT)/usr/ccs/bin
70ROOTCCSBIN64=	$(ROOTCCSBIN)/$(MACH64)
71ROOTCCSBINLINKDIR=	$(ROOT)/../../bin
72ROOTCCSBINLINKDIR64=	$(ROOT)../../../bin/$(MACH)
73ROOTUSRKVM=	$(ROOT)/usr/kvm
74ROOTXPG4=	$(ROOT)/usr/xpg4
75ROOTXPG4BIN=	$(ROOT)/usr/xpg4/bin
76ROOTXPG4BIN32=	$(ROOTXPG4BIN)/$(MACH32)
77ROOTXPG4BIN64=	$(ROOTXPG4BIN)/$(MACH64)
78ROOTXPG6=	$(ROOT)/usr/xpg6
79ROOTXPG6BIN=	$(ROOT)/usr/xpg6/bin
80ROOTLOCALEDEF=	$(ROOT)/usr/lib/localedef
81ROOTCHARMAP=	$(ROOTLOCALEDEF)/charmap
82ROOTI18NEXT=	$(ROOTLOCALEDEF)/extensions
83ROOTI18NEXT64=	$(ROOTLOCALEDEF)/extensions/$(MACH64)
84ROOTBIN32=	$(ROOTBIN)/$(MACH32)
85ROOTBIN64=	$(ROOTBIN)/$(MACH64)
86ROOTCMDDIR64=	$(ROOTCMDDIR)/$(MACH64)
87ROOTLIB64=	$(ROOTLIB)/$(MACH64)
88ROOTUSRSBIN32=	$(ROOTUSRSBIN)/$(MACH32)
89ROOTUSRSBIN64=	$(ROOTUSRSBIN)/$(MACH64)
90ROOTMAN=	$(ROOT)/usr/share/man
91ROOTMAN1=	$(ROOTMAN)/man1
92ROOTMAN1M=	$(ROOTMAN)/man1m
93ROOTMAN3=	$(ROOTMAN)/man3
94ROOTVARSMB=	$(ROOT)/var/smb
95
96#
97
98# Like ROOTLIBDIR in $(SRC)/Makefile.lib, any lower-level Makefiles that
99# put their binaries in a non-standard location should reset this and use
100# $(ROOTCMD) in their `install' target. By default we set this to a bogus
101# value so that it will not conflict with any of the other values already
102# defined in this Makefile.
103#
104ROOTCMDDIR=	$(ROOT)/__nonexistent_directory__
105
106ROOTSHAUDIO=	$(ROOT)/usr/share/audio
107ROOTAUDIOSAMP=	$(ROOTSHAUDIO)/samples
108ROOTAUDIOSAMPAU=$(ROOTAUDIOSAMP)/au
109
110ISAEXEC=	$(ROOT)/usr/lib/isaexec
111PLATEXEC=	$(ROOT)/usr/lib/platexec
112
113LDLIBS =	$(LDLIBS.cmd)
114
115LDFLAGS.cmd = \
116	$(BDIRECT) $(ENVLDFLAGS1) $(ENVLDFLAGS2) $(ENVLDFLAGS3) \
117	$(MAPFILE.NES:%=-M%) $(MAPFILE.PGA:%=-M%) $(MAPFILE.NED:%=-M%)
118
119LDFLAGS =	$(LDFLAGS.cmd)
120
121LINTFLAGS=	-axsm
122LINTFLAGS64=	-axsm -m64
123LINTOUT=	lint.out
124
125KRB5PROG=	$(PROG:%=$(KRB5BIN)/%)
126KRB5SBINPROG=	$(PROG:%=$(KRB5SBIN)/%)
127KRB5LIBPROG=	$(PROG:%=$(KRB5LIB)/%)
128
129ROOTPROG=	$(PROG:%=$(ROOTBIN)/%)
130ROOTCMD=	$(PROG:%=$(ROOTCMDDIR)/%)
131ROOTSHFILES=	$(SHFILES:%=$(ROOTBIN)/%)
132ROOTLIBPROG=	$(PROG:%=$(ROOTLIB)/%)
133ROOTLIBSHFILES= $(SHFILES:%=$(ROOTLIB)/%)
134ROOTSHLIBPROG=	$(PROG:%=$(ROOTSHLIB)/%)
135ROOTSBINPROG=	$(PROG:%=$(ROOTSBIN)/%)
136ROOTUSRSBINPROG=$(PROG:%=$(ROOTUSRSBIN)/%)
137ROOTUSRSBINSCRIPT=$(SCRIPT:%=$(ROOTUSRSBIN)/%)
138ROOTETCPROG=	$(PROG:%=$(ROOTETC)/%)
139ROOTCCSBINPROG=	$(PROG:%=$(ROOTCCSBIN)/%)
140ROOTCCSBINPROG64=	  $(PROG:%=$(ROOTCCSBIN64)/%)
141ROOTCCSBINLINK=$(PROG:%=  $(ROOTCCSBINLINKDIR)/%)
142ROOTCCSBINLINK64=$(PROG:%=$(ROOTCCSBINLINKDIR64)/%)
143ROOTUSRKVMPROG=	$(PROG:%=$(ROOTUSRKVM)/%)
144ROOTXPG4PROG=	$(XPG4PROG:%=$(ROOTXPG4BIN)/%)
145ROOTXPG4PROG32=	$(XPG4PROG:%=$(ROOTXPG4BIN32)/%)
146ROOTXPG4PROG64=	$(XPG4PROG:%=$(ROOTXPG4BIN64)/%)
147ROOTXPG6PROG=	$(XPG6PROG:%=$(ROOTXPG6BIN)/%)
148ROOTLOCALEPROG=	$(PROG:%=$(ROOTLOCALEDEF)/%)
149ROOTPROG64=	$(PROG:%=$(ROOTBIN64)/%)
150ROOTPROG32=	$(PROG:%=$(ROOTBIN32)/%)
151ROOTCMD64=	$(PROG:%=$(ROOTCMDDIR64)/%)
152ROOTUSRSBINPROG32=	$(PROG:%=$(ROOTUSRSBIN32)/%)
153ROOTUSRSBINPROG64=	$(PROG:%=$(ROOTUSRSBIN64)/%)
154ROOTMAN1FILES=	$(MAN1FILES:%=$(ROOTMAN1)/%)
155$(ROOTMAN1FILES) := FILEMODE= 444
156$(ROOTMAN1FILES) := OWNER= root
157$(ROOTMAN1FILES) := GROUP= bin
158ROOTMAN1MFILES=	$(MAN1MFILES:%=$(ROOTMAN1M)/%)
159$(ROOTMAN1MFILES) := FILEMODE= 444
160$(ROOTMAN1MFILES) := OWNER= root
161$(ROOTMAN1MFILES) := GROUP= bin
162ROOTMAN3FILES=	$(MAN3FILES:%=$(ROOTMAN3)/%)
163$(ROOTMAN3FILES) := FILEMODE= 444
164$(ROOTMAN3FILES) := OWNER= root
165$(ROOTMAN3FILES) := GROUP= bin
166
167# Symlink rules for /usr/ccs/bin commands. Note, those commands under
168# the rule of the linker area, are controlled by a different set of
169# rules defined in $(SRC)/cmd/sgs/Makefile.var.
170
171INS.ccsbinlink= \
172	$(RM) $(ROOTCCSBINPROG); \
173	$(SYMLINK) ../../bin/$(PROG) $(ROOTCCSBINPROG)
174
175INS.ccsbinlink64= \
176	$(RM) $(ROOTCCSBINPROG64); \
177	$(SYMLINK) ../../../bin/$(MACH64)/$(PROG) $(ROOTCCSBINPROG64)
178
179ROOTETCDEFAULT=	$(ROOTETC)/default
180ROOTETCDEFAULTFILES=	$(DEFAULTFILES:%.dfl=$(ROOTETCDEFAULT)/%)
181$(ROOTETCDEFAULTFILES) :=	OWNER = root
182$(ROOTETCDEFAULTFILES) :=	GROUP = sys
183$(ROOTETCDEFAULTFILES) :=	FILEMODE = 0644
184
185ROOTETCSECFILES=	$(ETCSECFILES:%=$(ROOTETCSECURITY)/%)
186$(ROOTETCSECFILES) :=	FILEMODE = 0644
187
188ROOTETCTSOLFILES=	$(ETCTSOLFILES:%=$(ROOTETCTSOL)/%)
189$(ROOTETCTSOLFILES) :=	FILEMODE = 0644
190
191ROOTETCSECLIBFILES=	$(ETCSECLIBFILES:%=$(ROOTETCSECLIB)/%)
192
193ROOTETCZONESFILES=	$(ETCZONESFILES:%=$(ROOTETCZONES)/%)
194$(ROOTETCZONESFILES) :=	FILEMODE = 0444
195
196ROOTLIBZONESFILES=	$(LIBZONESFILES:%=$(ROOTLIBZONES)/%)
197$(ROOTLIBZONESFILES) :=	FILEMODE = 0555
198
199
200#
201# Directories for smf(5) service manifests and profiles.
202#
203ROOTVARSVC=			$(ROOT)/var/svc
204
205ROOTVARSVCMANIFEST=		$(ROOTVARSVC)/manifest
206ROOTVARSVCPROFILE=		$(ROOTVARSVC)/profile
207
208ROOTSVCMILESTONE=		$(ROOTVARSVCMANIFEST)/milestone
209ROOTSVCDEVICE=			$(ROOTVARSVCMANIFEST)/device
210ROOTSVCSYSTEM=			$(ROOTVARSVCMANIFEST)/system
211ROOTSVCSYSTEMDEVICE=		$(ROOTSVCSYSTEM)/device
212ROOTSVCSYSTEMFILESYSTEM=	$(ROOTSVCSYSTEM)/filesystem
213ROOTSVCSYSTEMSECURITY=		$(ROOTSVCSYSTEM)/security
214ROOTSVCNETWORK=			$(ROOTVARSVCMANIFEST)/network
215ROOTSVCNETWORKDNS=		$(ROOTSVCNETWORK)/dns
216ROOTSVCNETWORKISCSI=		$(ROOTSVCNETWORK)/iscsi
217ROOTSVCNETWORKLDAP=		$(ROOTSVCNETWORK)/ldap
218ROOTSVCNETWORKNFS=		$(ROOTSVCNETWORK)/nfs
219ROOTSVCNETWORKNIS=		$(ROOTSVCNETWORK)/nis
220ROOTSVCNETWORKROUTING=		$(ROOTSVCNETWORK)/routing
221ROOTSVCNETWORKRPC=		$(ROOTSVCNETWORK)/rpc
222ROOTSVCNETWORKSMB=		$(ROOTSVCNETWORK)/smb
223ROOTSVCNETWORKSECURITY=		$(ROOTSVCNETWORK)/security
224ROOTSVCNETWORKSSL=		$(ROOTSVCNETWORK)/ssl
225ROOTSVCNETWORKIPSEC=		$(ROOTSVCNETWORK)/ipsec
226ROOTSVCNETWORKSHARES=		$(ROOTSVCNETWORK)/shares
227ROOTSVCSMB=			$(ROOTSVCNETWORK)/smb
228ROOTSVCPLATFORM=		$(ROOTVARSVCMANIFEST)/platform
229ROOTSVCPLATFORMSUN4U=		$(ROOTSVCPLATFORM)/sun4u
230ROOTSVCPLATFORMSUN4V=		$(ROOTSVCPLATFORM)/sun4v
231ROOTSVCAPPLICATION=		$(ROOTVARSVCMANIFEST)/application
232ROOTSVCAPPLICATIONMANAGEMENT=	$(ROOTSVCAPPLICATION)/management
233ROOTSVCAPPLICATIONSECURITY=	$(ROOTSVCAPPLICATION)/security
234ROOTSVCAPPLICATIONPRINT=	$(ROOTSVCAPPLICATION)/print
235
236#
237# Commands Makefiles delivering a manifest are expected to define MANIFEST.
238#
239# Like ROOTCMDDIR, any lower-level Makefiles that put their manifests in a
240# subdirectory of the manifest directories listed above should reset
241# ROOTMANIFESTDIR and use it in their `install' target. By default we set this
242# to a bogus value so that it will not conflict with any of the other values
243# already  defined in this Makefile.
244#
245# The manifest validation of the $SRC/cmd check target is also derived from a
246# valid MANIFEST setting.
247#
248ROOTMANIFESTDIR=	$(ROOTVARSVCMANIFEST)/__nonexistent_directory__
249ROOTMANIFEST=		$(MANIFEST:%=$(ROOTMANIFESTDIR)/%)
250CHKMANIFEST=		$(MANIFEST:%.xml=%.xmlchk)
251
252# Manifests cannot be checked in parallel, because we are using the global
253# repository that is in $(SRC)/cmd/svc/seed/global.db.  This is a
254# repository that is built from the manifests in this workspace, whereas
255# the build machine's repository may be out of sync with these manifests.
256# Because we are using a private repository, svccfg-native must start up a
257# private copy of configd-native.  We cannot have multiple copies of
258# configd-native trying to access global.db simultaneously.
259
260.NO_PARALLEL:	$(CHKMANIFEST)
261
262#
263# For installing "starter scripts" of services
264#
265
266ROOTSVCMETHOD=		$(SVCMETHOD:%=$(ROOTLIBSVCMETHOD)/%)
267
268ROOTSVCBINDIR=		$(ROOTLIBSVCBIN)/__nonexistent_directory__
269ROOTSVCBIN= 		$(SVCBIN:%=$(ROOTSVCBINDIR)/%)
270
271#
272
273# For programs that are installed in the root filesystem,
274# build $(ROOTFS_PROG) rather than $(PROG)
275$(ROOTFS_PROG) := LDFLAGS += -Wl,-I/lib/ld.so.1
276
277$(KRB5BIN)/%: %
278	$(INS.file)
279
280$(KRB5SBIN)/%: %
281	$(INS.file)
282
283$(KRB5LIB)/%: %
284	$(INS.file)
285
286$(ROOTBIN)/%: %
287	$(INS.file)
288
289$(ROOTLIB)/%: %
290	$(INS.file)
291
292$(ROOTBIN64)/%: %
293	$(INS.file)
294
295$(ROOTLIB64)/%: %
296	$(INS.file)
297
298$(ROOTBIN32)/%: %
299	$(INS.file)
300
301$(ROOTSHLIB)/%: %
302	$(INS.file)
303
304$(ROOTSBIN)/%: %
305	$(INS.file)
306
307$(ROOTUSRSBIN)/%: %
308	$(INS.file)
309
310$(ROOTUSRSBIN32)/%: %
311	$(INS.file)
312
313$(ROOTUSRSBIN64)/%: %
314	$(INS.file)
315
316$(ROOTETC)/%: %
317	$(INS.file)
318
319$(ROOTETCDEFAULT)/%:	%.dfl
320	$(INS.rename)
321
322$(ROOTETCTSOL)/%: %
323	$(INS.file)
324
325$(ROOTETCSECLIB)/%: %
326	$(INS.file)
327
328$(ROOTETCZONES)/%: %
329	$(INS.file)
330
331$(ROOTLIBZONES)/%: %
332	$(INS.file)
333
334$(ROOTLIBXEN)/%: %
335	$(INS.file)
336
337$(ROOTUSRKVM)/%: %
338	$(INS.file)
339
340$(ROOTXPG4BIN)/%: %.xpg4
341	$(INS.rename)
342
343$(ROOTXPG4BIN32)/%: %.xpg4
344	$(INS.rename)
345
346$(ROOTXPG4BIN64)/%: %.xpg4
347	$(INS.rename)
348
349$(ROOTXPG6BIN)/%: %.xpg6
350	$(INS.rename)
351
352$(ROOTLOCALEDEF)/%: %
353	$(INS.file)
354
355$(ROOTCHARMAP)/%: %
356	$(INS.file)
357
358$(ROOTI18NEXT)/%: %
359	$(INS.file)
360
361$(ROOTI18NEXT64)/%: %
362	$(INS.file)
363
364$(ROOTLIBSVCMETHOD)/%: %
365	$(INS.file)
366
367$(ROOTLIBSVCBIN)/%: %
368	$(INS.file)
369
370$(ROOTSVCMILESTONE)/%: %
371	$(INS.file)
372
373$(ROOTSVCDEVICE)/%: %
374	$(INS.file)
375
376$(ROOTSVCSYSTEM)/%: %
377	$(INS.file)
378
379$(ROOTSVCSYSTEMDEVICE)/%: %
380	$(INS.file)
381
382$(ROOTSVCSYSTEMFILESYSTEM)/%: %
383	$(INS.file)
384
385$(ROOTSVCSYSTEMSECURITY)/%: %
386	$(INS.file)
387
388$(ROOTSVCNETWORK)/%: %
389	$(INS.file)
390
391$(ROOTSVCNETWORKLDAP)/%: %
392	$(INS.file)
393
394$(ROOTSVCNETWORKNFS)/%: %
395	$(INS.file)
396
397$(ROOTSVCNETWORKNIS)/%: %
398	$(INS.file)
399
400$(ROOTSVCNETWORKRPC)/%: %
401	$(INS.file)
402
403$(ROOTSVCNETWORKSECURITY)/%: %
404	$(INS.file)
405
406$(ROOTSVCNETWORKSSL)/%: %
407	$(INS.file)
408
409$(ROOTSVCNETWORKIPSEC)/%: %
410	$(INS.file)
411
412$(ROOTSVCNETWORKSHARES)/%: %
413	$(INS.file)
414
415$(ROOTSVCNETWORKSMB)/%: %
416	$(INS.file)
417
418$(ROOTSVCAPPLICATION)/%: %
419	$(INS.file)
420
421$(ROOTSVCAPPLICATIONMANAGEMENT)/%: %
422	$(INS.file)
423
424$(ROOTSVCAPPLICATIONSECURITY)/%: %
425	$(INS.file)
426
427$(ROOTSVCAPPLICATIONPRINT)/%: %
428	$(INS.file)
429
430$(ROOTSVCPLATFORM)/%: %
431	$(INS.file)
432
433$(ROOTSVCPLATFORMSUN4U)/%: %
434	$(INS.file)
435
436$(ROOTSVCPLATFORMSUN4V)/%: %
437	$(INS.file)
438
439# Install rule for gprof, yacc, and lex dependency files
440$(ROOTSHLIBCCS)/%: ../common/%
441	$(INS.file)
442
443$(ROOTCCSBINLINKDIR)/%: %
444	$(INS.ccsbinlink)
445
446$(ROOTCCSBINLINKDIR64)/%: %
447	$(INS.ccsbinlink64)
448
449$(ROOTMAN1)/%: %.sunman
450	$(INS.rename)
451
452$(ROOTMAN1M)/%: %.sunman
453	$(INS.rename)
454
455$(ROOTMAN3)/%: %.sunman
456	$(INS.rename)
457
458$(ROOTVARSMB)/%: %
459	$(INS.file)
460
461# build rule for statically linked programs with single source file.
462%.static: %.c
463	$(LINK.c) -o $@ $< $(LDLIBS)
464	$(POST_PROCESS)
465
466%.xpg4: %.c
467	$(LINK.c) -o $@ $< $(LDLIBS)
468	$(POST_PROCESS)
469
470%.xpg6: %.c
471	$(LINK.c) -o $@ $< $(LDLIBS)
472	$(POST_PROCESS)
473
474# Define the majority text domain in this directory.
475TEXT_DOMAIN= SUNW_OST_OSCMD
476
477CLOBBERFILES += $(XPG4) $(XPG6) $(DCFILE)
478
479# This flag is being added only for SCO (x86) compatibility
480i386_SPFLAG=    -D_iBCS2
481sparc_SPFLAG=
482
483iBCS2FLAG = $($(MACH)_SPFLAG)
484
485# This flag is for programs which should not build a 32-bit binary
486sparc_64ONLY= $(POUND_SIGN)
48764ONLY=	 $($(MACH)_64ONLY)
488