xref: /titanic_51/usr/src/cmd/sa/Makefile (revision 98157a7002f4f2cf7978f3084ca5577f0a1d72b2)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25#pragma	ident	"%Z%%M%	%I%	%E% SMI"
26#
27# cmd/sa/Makefile
28#
29
30MANIFEST =	sar.xml
31SVCMETHOD =	svc-sar
32
33include ../Makefile.cmd
34
35ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
36
37GREP=		grep
38
39SADC= 		sadc
40SADP= 		sadp
41SAR= 		sar
42TIMEX=		timex
43SAG=		sag
44SA1=		sa1
45SA2=		sa2
46
47sadc :=		LDLIBS += -lkstat
48
49# Executables produced
50BINPROG=	$(TIMEX)
51SBINPROG=	$(SAR) $(SAG)
52LIBPROG=	$(SADC)
53LIBSHELL=	$(SA1) $(SA2)
54INITSHELL=	$(PERF)
55
56PROGS=		$(BINPROG) $(SBINPROG) $(LIBPROG)
57SHELLS=		$(LIBSHELL)
58TXTS= 		$(SADP).c README
59ALL=		$(PROGS) $(SHELLS)
60
61# Source files
62SAG_OBJECTS=	$(SAG)a.o $(SAG)b.o
63SADC_OBJECTS=	$(SADC).o
64srcs=		$(TIMEX) $(SAR) $(SADC)
65SRCS=		$(srcs:%=%.c) $(SAG_OBJECTS:%.o=%.c)
66SHSRCS=		$(SHELLS:%=%.sh)
67
68# Set of target install directories
69LIBSAD=		$(ROOT)/usr/lib/sa
70CROND=		$(ROOT)/var/spool/cron
71CRONTABSD=	$(CROND)/crontabs
72
73# Set of target install files
74SYSCRONTAB=	$(CRONTABSD)/sys
75ROOTPROG=	$(BINPROG:%=$(ROOTBIN)/%)
76ROOTUSBINPROG=	$(SBINPROG:%=$(ROOTUSRSBIN)/%)
77ROOTLIBPROG=	$(LIBPROG:%=$(LIBSAD)/%)
78ROOTLIBSHELL=	$(LIBSHELL:%=$(LIBSAD)/%)
79ROOTSYMLINKS=	$(SBINPROG:%=$(ROOTBIN)/%)
80
81# Performance monitoring should not be enabled by default. Hence, these
82# entries are comments. Note the difficulty of inserting a literal #
83# in a makefile.... Wonderful parser here....
84COMMENT_CHAR:sh=          echo \\043
85ENTRY1=		'$(COMMENT_CHAR) 0 * * * 0-6 /usr/lib/sa/sa1'
86ENTRY2=		'$(COMMENT_CHAR) 20,40 8-17 * * 1-5 /usr/lib/sa/sa1'
87ENTRY3=		'$(COMMENT_CHAR) 5 18 * * 1-5 /usr/lib/sa/sa2 -s 8:00 -e 18:01 -i 1200 -A'
88
89CLOBBERFILES=	$(PROGS) $(SHELLS)
90
91# Conditionals
92$(SYSCRONTAB)		:= OWNER = root
93$(SYSCRONTAB)     	:= GROUP = sys
94$(ROOTBIN)/$(TIMEX)	:= GROUP = sys
95# $(ROOTUSRSBIN)/$(SADP) 	:= FILEMODE = 2555
96# $(ROOTUSRSBIN)/$(SADP) 	:= GROUP = sys
97$(LIBSAD)/$(SADC) 	:= FILEMODE = 0555
98$(LIBSAD)/$(SADC) 	:= GROUP = bin
99
100.KEEP_STATE:
101
102all: 		$(ALL) $(TXTS)
103
104$(SAG):		$(SAG_OBJECTS)
105	$(LINK.c) -o $@ $(SAG_OBJECTS) $(LDLIBS)
106	$(POST_PROCESS)
107
108$(SADC):	$(SADC_OBJECTS)
109	$(LINK.c) -o $@ $(SADC_OBJECTS) $(LDLIBS)
110	$(POST_PROCESS)
111
112# The edit of SYSCRONTAB must be done unconditionally because of the
113# creation of this file by a different component (Adm) and the possible
114# backdating.
115install:	all $(ROOTPROG) $(ROOTUSBINPROG)     \
116		$(ROOTINITSHELL)  $(ROOTLIBSHELL) $(ROOTSYMLINKS) \
117		$(ROOTMANIFEST) $(ROOTSVCMETHOD) $(ROOTLIBPROG)
118	@if [ -f $(SYSCRONTAB) ]; \
119	then \
120		if $(GREP) "sa1" $(SYSCRONTAB) >/dev/null 2>&1 ; then :; \
121		else \
122			echo $(ENTRY1) >> $(SYSCRONTAB); \
123			echo $(ENTRY2) >> $(SYSCRONTAB); \
124			echo "$(SYSCRONTAB) modified"; \
125		fi; \
126		if $(GREP) "sa2" $(SYSCRONTAB) >/dev/null 2>&1 ; then :; \
127		else \
128			echo $(ENTRY3) >> $(SYSCRONTAB); \
129		fi; \
130	fi
131
132$(LIBSAD)/%: %
133	$(INS.file)
134
135$(ROOTSYMLINKS):
136	-$(RM) $@; $(SYMLINK) ../sbin/`basename $@` $@
137
138$(ETCINITD)/%: %
139	$(INS.file)
140
141check:	$(CHKMANIFEST)
142
143clean:
144	$(RM) $(SAG_OBJECTS) $(SADC_OBJECTS) $(PROGS) $(SHELLS) $(SADP)
145
146lint:	lint_SRCS
147
148include ../Makefile.targ
149