xref: /illumos-gate/usr/src/cmd/Makefile.cmd (revision b02637af6dc592eb1f43cb4c74f06268648dbd2d)
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
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
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
110#
111# Begin /usr/sfw freeware rules for freeware that has "External"
112# taxonomy stability level.
113#
114ROOTSFW=	$(ROOT)/usr/sfw
115ROOTSFWBIN=	$(ROOT)/usr/sfw/bin
116ROOTSFWSBIN=	$(ROOT)/usr/sfw/sbin
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	$(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
239ROOTSVCNETWORKLDAP=		$(ROOTSVCNETWORK)/ldap
240ROOTSVCNETWORKNFS=		$(ROOTSVCNETWORK)/nfs
241ROOTSVCNETWORKNIS=		$(ROOTSVCNETWORK)/nis
242ROOTSVCNETWORKROUTING=		$(ROOTSVCNETWORK)/routing
243ROOTSVCNETWORKRPC=		$(ROOTSVCNETWORK)/rpc
244ROOTSVCNETWORKSECURITY=		$(ROOTSVCNETWORK)/security
245ROOTSVCNETWORKSSL=		$(ROOTSVCNETWORK)/ssl
246ROOTSVCNETWORKIPSEC=		$(ROOTSVCNETWORK)/ipsec
247ROOTSVCNETWORKSHARES=		$(ROOTSVCNETWORK)/shares
248ROOTSVCPLATFORM=		$(ROOTVARSVCMANIFEST)/platform
249ROOTSVCPLATFORMSUN4U=		$(ROOTSVCPLATFORM)/sun4u
250ROOTSVCPLATFORMSUN4V=		$(ROOTSVCPLATFORM)/sun4v
251ROOTSVCAPPLICATION=		$(ROOTVARSVCMANIFEST)/application
252ROOTSVCAPPLICATIONMANAGEMENT=	$(ROOTSVCAPPLICATION)/management
253ROOTSVCAPPLICATIONSECURITY=	$(ROOTSVCAPPLICATION)/security
254ROOTSVCAPPLICATIONPRINT=	$(ROOTSVCAPPLICATION)/print
255
256#
257# Commands Makefiles delivering a manifest are expected to define MANIFEST.
258#
259# Like ROOTCMDDIR, any lower-level Makefiles that put their manifests in a
260# subdirectory of the manifest directories listed above should reset
261# ROOTMANIFESTDIR and use it in their `install' target. By default we set this
262# to a bogus value so that it will not conflict with any of the other values
263# already  defined in this Makefile.
264#
265# The manifest validation of the $SRC/cmd check target is also derived from a
266# valid MANIFEST setting.
267#
268ROOTMANIFESTDIR=	$(ROOTVARSVCMANIFEST)/__nonexistent_directory__
269ROOTMANIFEST=		$(MANIFEST:%=$(ROOTMANIFESTDIR)/%)
270CHKMANIFEST=		$(MANIFEST:%.xml=%.xmlchk)
271
272#
273# For installing "starter scripts" of services
274#
275
276ROOTSVCMETHOD=		$(SVCMETHOD:%=$(ROOTLIBSVCMETHOD)/%)
277
278ROOTSVCBINDIR=		$(ROOTLIBSVCBIN)/__nonexistent_directory__
279ROOTSVCBIN= 		$(SVCBIN:%=$(ROOTSVCBINDIR)/%)
280
281#
282
283# For programs that are installed in the root filesystem,
284# build $(ROOTFS_PROG) rather than $(PROG)
285$(ROOTFS_PROG) := LDFLAGS += -Wl,-I/lib/ld.so.1
286
287$(KRB5BIN)/%: %
288	$(INS.file)
289
290$(KRB5SBIN)/%: %
291	$(INS.file)
292
293$(KRB5LIB)/%: %
294	$(INS.file)
295
296$(ROOTBIN)/%: %
297	$(INS.file)
298
299$(ROOTLIB)/%: %
300	$(INS.file)
301
302$(ROOTBIN64)/%: %
303	$(INS.file)
304
305$(ROOTLIB64)/%: %
306	$(INS.file)
307
308$(ROOTBIN32)/%: %
309	$(INS.file)
310
311$(ROOTSHLIB)/%: %
312	$(INS.file)
313
314$(ROOTSBIN)/%: %
315	$(INS.file)
316
317$(ROOTUSRSBIN)/%: %
318	$(INS.file)
319
320$(ROOTUSRSBIN32)/%: %
321	$(INS.file)
322
323$(ROOTUSRSBIN64)/%: %
324	$(INS.file)
325
326$(ROOTETC)/%: %
327	$(INS.file)
328
329$(ROOTETCDEFAULT)/%:	%.dfl
330	$(INS.rename)
331
332$(ROOTETCTSOL)/%: %
333	$(INS.file)
334
335$(ROOTETCSECLIB)/%: %
336	$(INS.file)
337
338$(ROOTETCZONES)/%: %
339	$(INS.file)
340
341$(ROOTLIBZONES)/%: %
342	$(INS.file)
343
344$(ROOTUSRKVM)/%: %
345	$(INS.file)
346
347$(ROOTXPG4BIN)/%: %.xpg4
348	$(INS.rename)
349
350$(ROOTXPG4BIN32)/%: %.xpg4
351	$(INS.rename)
352
353$(ROOTXPG4BIN64)/%: %.xpg4
354	$(INS.rename)
355
356$(ROOTXPG6BIN)/%: %.xpg6
357	$(INS.rename)
358
359$(ROOTLOCALEDEF)/%: %
360	$(INS.file)
361
362$(ROOTCHARMAP)/%: %
363	$(INS.file)
364
365$(ROOTI18NEXT)/%: %
366	$(INS.file)
367
368$(ROOTI18NEXT64)/%: %
369	$(INS.file)
370
371$(ROOTLIBSVCMETHOD)/%: %
372	$(INS.file)
373
374$(ROOTLIBSVCBIN)/%: %
375	$(INS.file)
376
377$(ROOTSVCMILESTONE)/%: %
378	$(INS.file)
379
380$(ROOTSVCDEVICE)/%: %
381	$(INS.file)
382
383$(ROOTSVCSYSTEM)/%: %
384	$(INS.file)
385
386$(ROOTSVCSYSTEMDEVICE)/%: %
387	$(INS.file)
388
389$(ROOTSVCSYSTEMFILESYSTEM)/%: %
390	$(INS.file)
391
392$(ROOTSVCSYSTEMSECURITY)/%: %
393	$(INS.file)
394
395$(ROOTSVCNETWORK)/%: %
396	$(INS.file)
397
398$(ROOTSVCNETWORKLDAP)/%: %
399	$(INS.file)
400
401$(ROOTSVCNETWORKNFS)/%: %
402	$(INS.file)
403
404$(ROOTSVCNETWORKNIS)/%: %
405	$(INS.file)
406
407$(ROOTSVCNETWORKRPC)/%: %
408	$(INS.file)
409
410$(ROOTSVCNETWORKSECURITY)/%: %
411	$(INS.file)
412
413$(ROOTSVCNETWORKSSL)/%: %
414	$(INS.file)
415
416$(ROOTSVCNETWORKIPSEC)/%: %
417	$(INS.file)
418
419$(ROOTSVCNETWORKSHARES)/%: %
420	$(INS.file)
421
422$(ROOTSVCAPPLICATION)/%: %
423	$(INS.file)
424
425$(ROOTSVCAPPLICATIONMANAGEMENT)/%: %
426	$(INS.file)
427
428$(ROOTSVCAPPLICATIONSECURITY)/%: %
429	$(INS.file)
430
431$(ROOTSVCAPPLICATIONPRINT)/%: %
432	$(INS.file)
433
434$(ROOTSVCPLATFORM)/%: %
435	$(INS.file)
436
437$(ROOTSVCPLATFORMSUN4U)/%: %
438	$(INS.file)
439
440$(ROOTSVCPLATFORMSUN4V)/%: %
441	$(INS.file)
442
443# Install rule for gprof, yacc, and lex dependency files
444$(ROOTSHLIBCCS)/%: ../common/%
445	$(INS.file)
446
447$(ROOTCCSBINLINKDIR)/%: %
448	$(INS.ccsbinlink)
449
450$(ROOTCCSBINLINKDIR64)/%: %
451	$(INS.ccsbinlink64)
452
453$(ROOTMAN1)/%: %.sunman
454	$(INS.rename)
455
456$(ROOTMAN1M)/%: %.sunman
457	$(INS.rename)
458
459$(ROOTMAN3)/%: %.sunman
460	$(INS.rename)
461
462# build rule for statically linked programs with single source file.
463%.static: %.c
464	$(LINK.c) -o $@ $< $(LDLIBS)
465	$(POST_PROCESS)
466
467%.xpg4: %.c
468	$(LINK.c) -o $@ $< $(LDLIBS)
469	$(POST_PROCESS)
470
471%.xpg6: %.c
472	$(LINK.c) -o $@ $< $(LDLIBS)
473	$(POST_PROCESS)
474
475# Define the majority text domain in this directory.
476TEXT_DOMAIN= SUNW_OST_OSCMD
477
478CLOBBERFILES += $(XPG4) $(XPG6) $(DCFILE)
479
480# This flag is being added only for SCO (x86) compatibility
481i386_SPFLAG=    -D_iBCS2
482sparc_SPFLAG=
483
484iBCS2FLAG = $($(MACH)_SPFLAG)
485
486# This flag is for programs which should not build a 32-bit binary
487sparc_64ONLY= $(POUND_SIGN)
48864ONLY=	 $($(MACH)_64ONLY)
489