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