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