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