xref: /illumos-gate/usr/src/cmd/sa/Makefile (revision bd335c6465ddbafe543900df4b03247bfa288eff)
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, Version 1.0 only
6# (the "License").  You may not use this file except in compliance
7# with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26#pragma	ident	"%Z%%M%	%I%	%E% SMI"
27#
28# cmd/sa/Makefile
29#
30
31include ../Makefile.cmd
32
33MANIFEST =	sar.xml
34
35ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
36ROOTMETHOD =	$(ROOTLIBSVCMETHOD)/svc-sar
37
38GREP=		grep
39
40SADC= 		sadc
41SADP= 		sadp
42SAR= 		sar
43TIMEX=		timex
44SAG=		sag
45SA1=		sa1
46SA2=		sa2
47
48sadc :=		LDLIBS += -lkstat
49
50# Executables produced
51BINPROG=	$(TIMEX)
52SBINPROG=	$(SAR) $(SAG)
53LIBPROG=	$(SADC)
54LIBSHELL=	$(SA1) $(SA2)
55INITSHELL=	$(PERF)
56
57PROGS=		$(BINPROG) $(SBINPROG) $(LIBPROG)
58SHELLS=		$(LIBSHELL)
59TXTS= 		$(SADP).c README
60ALL=		$(PROGS) $(SHELLS)
61
62# Source files
63SAG_OBJECTS=	$(SAG)a.o $(SAG)b.o
64SADC_OBJECTS=	$(SADC).o
65srcs=		$(TIMEX) $(SAR) $(SADC)
66SRCS=		$(srcs:%=%.c) $(SAG_OBJECTS:%.o=%.c)
67SHSRCS=		$(SHELLS:%=%.sh)
68
69# Set of target install directories
70LIBSAD=		$(ROOT)/usr/lib/sa
71CROND=		$(ROOT)/var/spool/cron
72CRONTABSD=	$(CROND)/crontabs
73
74# Set of target install files
75SYSCRONTAB=	$(CRONTABSD)/sys
76ROOTPROG=	$(BINPROG:%=$(ROOTBIN)/%)
77ROOTUSBINPROG=	$(SBINPROG:%=$(ROOTUSRSBIN)/%)
78ROOTLIBPROG=	$(LIBPROG:%=$(LIBSAD)/%)
79ROOTLIBSHELL=	$(LIBSHELL:%=$(LIBSAD)/%)
80ROOTSYMLINKS=	$(SBINPROG:%=$(ROOTBIN)/%)
81
82# Performance monitoring should not be enabled by default. Hence, these
83# entries are comments. Note the difficulty of inserting a literal #
84# in a makefile.... Wonderful parser here....
85COMMENT_CHAR:sh=          echo \\043
86ENTRY1=		'$(COMMENT_CHAR) 0 * * * 0-6 /usr/lib/sa/sa1'
87ENTRY2=		'$(COMMENT_CHAR) 20,40 8-17 * * 1-5 /usr/lib/sa/sa1'
88ENTRY3=		'$(COMMENT_CHAR) 5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A'
89
90CLOBBERFILES=	$(PROGS) $(SHELLS)
91
92# Conditionals
93$(SYSCRONTAB)		:= OWNER = root
94$(SYSCRONTAB)     	:= GROUP = sys
95$(ROOTBIN)/$(TIMEX)	:= GROUP = sys
96# $(ROOTUSRSBIN)/$(SADP) 	:= FILEMODE = 2555
97# $(ROOTUSRSBIN)/$(SADP) 	:= GROUP = sys
98$(LIBSAD)/$(SADC) 	:= FILEMODE = 0555
99$(LIBSAD)/$(SADC) 	:= GROUP = bin
100$(ROOTMANIFEST)		:= FILEMODE = 0444
101
102.KEEP_STATE:
103
104all: 		$(ALL) $(TXTS)
105
106$(SAG):		$(SAG_OBJECTS)
107	$(LINK.c) -o $@ $(SAG_OBJECTS) $(LDLIBS)
108	$(POST_PROCESS)
109
110$(SADC):	$(SADC_OBJECTS)
111	$(LINK.c) -o $@ $(SADC_OBJECTS) $(LDLIBS)
112	$(POST_PROCESS)
113
114$(ROOTSVCSYSTEM)/perf.xml := OWNER = root
115$(ROOTSVCSYSTEM)/perf.xml := GROUP = sys
116$(ROOTSVCSYSTEM)/perf.xml := FILEMODE = 0444
117
118$(ROOTLIBSVCMETHOD)/svc-perf := OWNER = root
119$(ROOTLIBSVCMETHOD)/svc-perf := GROUP = bin
120$(ROOTLIBSVCMETHOD)/svc-perf := FILEMODE = 0555
121
122# The edit of SYSCRONTAB must be done unconditionally because of the
123# creation of this file by a different component (Adm) and the possible
124# backdating.
125install:	all $(ROOTPROG) $(ROOTUSBINPROG)     \
126		$(ROOTINITSHELL)  $(ROOTLIBSHELL) $(ROOTSYMLINKS) \
127		$(ROOTMANIFEST) $(ROOTMETHOD) $(ROOTLIBPROG)
128	@if [ -f $(SYSCRONTAB) ]; \
129	then \
130		if $(GREP) "sa1" $(SYSCRONTAB) >/dev/null 2>&1 ; then :; \
131		else \
132			echo $(ENTRY1) >> $(SYSCRONTAB); \
133			echo $(ENTRY2) >> $(SYSCRONTAB); \
134			echo "$(SYSCRONTAB) modified"; \
135		fi; \
136		if $(GREP) "sa2" $(SYSCRONTAB) >/dev/null 2>&1 ; then :; \
137		else \
138			echo $(ENTRY3) >> $(SYSCRONTAB); \
139		fi; \
140	fi
141
142$(LIBSAD)/%: %
143	$(INS.file)
144
145$(ROOTSYMLINKS):
146	-$(RM) $@; $(SYMLINK) ../sbin/`basename $@` $@
147
148$(ETCINITD)/%: %
149	$(INS.file)
150
151check:	$(CHKMANIFEST)
152
153clean:
154	$(RM) $(SAG_OBJECTS) $(SADC_OBJECTS) $(PROGS) $(SHELLS) $(SADP)
155
156lint:	lint_SRCS
157
158include ../Makefile.targ
159