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