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