xref: /illumos-gate/usr/src/cmd/sa/Makefile (revision 02b17e23)
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# Copyright (c) 2013 Andrew Stormont.  All rights reserved.
25#
26# Copyright (c) 2018, Joyent, Inc.
27
28MANIFEST =	sar.xml
29SVCMETHOD =	svc-sar
30
31include ../Makefile.cmd
32
33ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
34
35CERRWARN +=	-_gcc=-Wno-parentheses
36CERRWARN +=	$(CNOWARN_UNINIT)
37
38SMOFF += all_func_returns
39
40SADC=		sadc
41SAR=		sar
42TIMEX=		timex
43SA1=		sa1
44SA2=		sa2
45
46sadc :=		LDLIBS += -lkstat
47
48# Executables produced
49BINPROG=	$(TIMEX)
50SBINPROG=	$(SAR)
51LIBPROG=	$(SADC)
52LIBSHELL=	$(SA1) $(SA2)
53INITSHELL=	$(PERF)
54
55PROGS=		$(BINPROG) $(SBINPROG) $(LIBPROG)
56SHELLS=		$(LIBSHELL)
57TXTS=		README
58ALL=		$(PROGS) $(SHELLS)
59
60# Source files
61SADC_OBJECTS=	$(SADC).o
62srcs=		$(TIMEX) $(SAR) $(SADC)
63SRCS=		$(srcs:%=%.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.
81ENTRY1=		'$(POUND_SIGN) 0 * * * 0-6 /usr/lib/sa/sa1'
82ENTRY2=		'$(POUND_SIGN) 20,40 8-17 * * 1-5 /usr/lib/sa/sa1'
83ENTRY3=		'$(POUND_SIGN) 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)
131
132lint:	lint_SRCS
133
134include ../Makefile.targ
135