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