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