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