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