xref: /illumos-gate/usr/src/cmd/power/Makefile (revision 58e78d16)
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# Copyright (c) 2018, Joyent, Inc.
26
27DAEMON_SRCS =	powerd.c sysstat.c
28DAEMON_OBJS =	$(DAEMON_SRCS:%.c=%.o)
29DAEMON =	powerd
30PMCFG_SRCS =	conf.c parse.c handlers.c
31PMCFG_OBJS =	$(PMCFG_SRCS:%.c=%.o)
32PMCFG =		pmconfig
33SUSPEND_SRCS =	sys-suspend.c pm_pam_conv.c
34SUSPEND_OBJS =	$(SUSPEND_SRCS:%.c=%.o)
35SUSPEND =	sys-suspend
36SRCS =		$(DAEMON_SRCS) $(PMCFG_SRCS) $(SUSPEND_SRCS)
37OBJS =		$(SRCS:%.c=%.o)
38PROG =		$(DAEMON) $(PMCFG) $(SUSPEND)
39POWERCONF=	power.conf
40ETCFILES =	$(POWERCONF)
41POWERPERM =	power
42DEFAULTFILES =	power.dfl
43
44MANIFEST=	power.xml
45SVCMETHOD=	svc-power
46
47include ../Makefile.cmd
48
49ROOTMANIFESTDIR =	$(ROOTSVCSYSTEM)
50
51TEXT_DOMAIN=	SUNW_OST_OSCMD
52
53XGETFLAGS +=    -a -x power_all.xcl
54POFILE=		power_all.po
55POFILES=	$(PMCFG_SRCS:%.c=%.po) $(SUSPEND_SRCS:%.c=%.po)
56
57# pmconfig only needs libdevinfo on sparc
58sparc_LDEVINFO=	-ldevinfo -lefi -ladm -lzfs -lnvpair
59i386_LDEVINFO=
60
61LDEVINFO=	-ldevinfo
62
63DAEMON_LDLIBS =	$(LDLIBS.cmd) -lkstat $(LDEVINFO)
64PMCFG_LDLIBS =	$(LDLIBS.cmd) -lsmbios -lkstat $($(MACH)_LDEVINFO)
65SUSPEND_LDLIBS = $(LDLIBS.cmd) -lbsm -lpam -lsecdb
66
67ROOTUSRSBINPMCFG= $(PMCFG:%=$(ROOTUSRSBIN)/%)
68$(ROOTUSRSBINPMCFG) := FILEMODE= 4555
69ROOTUSRBINSUSPEND= $(SUSPEND:%=$(ROOTBIN)/%)
70$(ROOTUSRBINSUSPEND) := FILEMODE= 4555
71
72ROOTLIBPOWER= $(ROOTLIB)/power
73ROOTLIBPOWERDAEMON= $(DAEMON:%=$(ROOTLIBPOWER)/%)
74$(ROOTLIBPOWER) := FILEMODE= 755
75$(ROOTLIBPOWERDAEMON) := FILEMODE= 555
76
77ROOTETCFILES= $(ETCFILES:%=$(ROOTETC)/%)
78$(ROOTETCFILES) := FILEMODE= 644
79
80#
81# lint pass one enforcement
82#
83CFLAGS += $(CCVERBOSE)
84
85SMOFF += signed
86
87.PARALLEL: $(OBJS)
88
89.KEEP_STATE:
90
91all: $(PROG) $(POWERPERM).dfl $(ETCFILES)
92
93install clean:
94
95$(POWERCONF): $(POWERCONF).$(MACH)
96
97$(DAEMON_OBJS): $(DAEMON_SRCS)
98	$(CC) $(CFLAGS) -D_REENTRANT $(CPPFLAGS) -o $@ -c $<
99	$(PROCESS_COMMENT) $@
100
101$(DAEMON): $(DAEMON_OBJS)
102	$(LINK.c) -o $@ $(DAEMON_OBJS) $(DAEMON_LDLIBS)
103	$(POST_PROCESS)
104
105$(PMCFG_OBJS): pmconfig.h
106
107$(PMCFG): $(PMCFG_OBJS)
108	$(LINK.c) -o $@ $(PMCFG_OBJS) $(PMCFG_LDLIBS)
109	$(POST_PROCESS)
110
111$(SUSPEND): $(SUSPEND_OBJS)
112	$(LINK.c) -o $@ $(SUSPEND_OBJS) $(SUSPEND_LDLIBS)
113	$(POST_PROCESS)
114
115install: all $(ROOTUSRSBINPMCFG) $(ROOTLIBPOWERDAEMON) $(ROOTUSRBINSUSPEND) \
116	$(ROOTETCFILES) $(ROOTETCDEFAULTFILES) \
117	$(ROOTMANIFEST) $(ROOTSVCMETHOD)
118
119$(ROOTLIBPOWER):
120	$(INS.dir)
121
122$(ROOTLIBPOWER)/%:	%
123	$(INS.file)
124
125$(ROOTLIBPOWERDAEMON): $(ROOTLIBPOWER)
126
127$(POFILE):	$(POFILES)
128	$(RM)	$@
129	cat	$(POFILES)	> $@
130
131check:	$(CHKMANIFEST)
132
133clean:
134	$(RM) $(OBJS) $(POWERCONF)
135	$(RM) $(POFILE) $(POFILES)
136
137lint := LINTFLAGS=-auxn
138lint:
139	$(LINT.c) $(DAEMON_SRCS)
140	$(LINT.c) $(PMCFG_SRCS)
141	$(LINT.c) $(SUSPEND_SRCS)
142
143cstyle:
144	$(CSTYLE) $(SRCS)
145
146%:	%.$(MACH)
147	$(RM) $@
148	cat $< > $@
149
150include ../Makefile.targ
151