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