xref: /illumos-gate/usr/src/cmd/svc/svccfg/Makefile (revision 3e3015ce0eb82be8ac17954eba80f3f24204fcbd)
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#
23# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
24# Copyright 2020 Joyent, Inc.
25#
26
27MYPROG =	svccfg
28PROG =		$(MYPROG)
29
30SRCS  =		svccfg_main.c \
31		svccfg_engine.c \
32		svccfg_internal.c \
33		svccfg_libscf.c \
34		svccfg_tmpl.c \
35		svccfg_xml.c \
36		svccfg_help.c
37
38LNTS =		$(SRCS:%.c=%.ln) \
39		manifest_find.ln \
40		manifest_hash.ln
41
42MYOBJS =	$(SRCS:%.c=%.o) \
43		svccfg_grammar.o \
44		svccfg_lex.o \
45		manifest_find.o \
46		manifest_hash.o \
47		notify_params.o
48OBJS =		$(MYOBJS)
49
50POFILES =	$(SRCS:%.c=%.po) \
51		svccfg_grammar.po \
52		svccfg_lex.po \
53		../common/manifest_find.po \
54		../common/manifest_hash.po
55
56include ../../Makefile.cmd
57include ../../Makefile.ctf
58
59POFILE =	$(PROG)_all.po
60
61NATIVE_BUILD=$(POUND_SIGN)
62$(NATIVE_BUILD)NOT_NATIVE=$(POUND_SIGN)
63
64$(NATIVE_BUILD)PROG = $(MYPROG:%=%-native)
65$(NATIVE_BUILD)OBJS = $(MYOBJS:%.o=%-native.o)
66
67# svccfg has a name clash with main() and libl.so.1.  However, svccfg must
68# still export a number of "yy*" (libl) interfaces.  Reduce all other symbols
69# to local scope.
70MAPFILES +=	$(MAPFILE.LEX) $(MAPFILE.NGB)
71MAPOPTS =	$(MAPFILES:%=-M%)
72
73MYCPPFLAGS =	-I ../common -I$(ADJUNCT_PROTO)/usr/include/libxml2
74CPPFLAGS +=	$(MYCPPFLAGS)
75LDFLAGS +=	$(MAPOPTS)
76
77CERRWARN +=	-_gcc=-Wno-unused-label
78CERRWARN +=	-_gcc=-Wno-implicit-function-declaration
79CERRWARN +=	-_gcc=-Wno-switch
80CERRWARN +=	$(CNOWARN_UNINIT)
81CERRWARN +=	-_gcc=-Wno-unused-variable
82CERRWARN +=	-_gcc=-Wno-parentheses
83
84# not linted
85SMATCH=off
86
87LFLAGS = -t
88YFLAGS = -d
89
90CLOBBERFILES += svccfg_lex.c svccfg_grammar.c svccfg_grammar.h \
91    $(MYPROG:%=%-native)
92
93SVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd5 -lnvpair
94$(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla
95#
96# If no adjunct, then we'll already find /usr/lib via LDLIBS below.
97#
98$(NO_ADJUNCT_PROTO)NATIVE_LIBS += libxml2.so libl.so libumem.so \
99    libmd5.so libnvpair.so libc.so
100
101LIBSCF		= $(SRC)/lib/libscf
102LIBTECLA	= $(SRC)/lib/libtecla		# just for the header
103LIBUUTIL	= $(SRC)/lib/libuutil
104
105lint := LINTFLAGS = -mux
106lint := SVCCFG_EXTRA_LIBS = -lscf -ll -luutil -lumem -lmd5 -lnvpair
107
108LDLIBS += $(SVCCFG_EXTRA_LIBS)
109
110$(NATIVE_BUILD)CC =	$(NATIVECC)
111$(NATIVE_BUILD)LD =	$(NATIVELD)
112$(NATIVE_BUILD)CFLAGS =	$(NATIVE_CFLAGS)
113$(NATIVE_BUILD)CPPFLAGS = \
114	-DNATIVE_BUILD \
115	$(MYCPPFLAGS) \
116	-I$(LIBSCF)/inc \
117	-I$(LIBTECLA) \
118	-I$(LIBUUTIL)/common
119$(NATIVE_BUILD)LDFLAGS = $(BDIRECT)
120$(NATIVE_BUILD)LDLIBS = \
121	-L$(LIBUUTIL)/native -R $(LIBUUTIL)/native \
122	-L$(LIBSCF)/native -R $(LIBSCF)/native \
123	-L$(ADJUNCT_PROTO)/usr/lib -R$(ADJUNCT_PROTO)/usr/lib \
124	$(SVCCFG_EXTRA_LIBS)
125
126svccfg_lex.o svccfg_grammar.o := CCVERBOSE =
127
128svccfg_help.po := XGETFLAGS =	-a
129
130.KEEP_STATE:
131.PARALLEL: $(OBJS) $(LNTS)
132
133all debug: $(PROG)
134
135native: FRC
136	@cd $(LIBUUTIL)/native; pwd; $(MAKE) $(MFLAGS) install
137	@cd $(LIBSCF)/native; pwd; $(MAKE) $(MFLAGS) install
138	@NATIVE_BUILD= $(MAKE) $(MFLAGS) all
139
140$(PROG): $(OBJS) $(MAPFILES)
141	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
142	$(POST_PROCESS)
143
144$(POFILES): svccfg_grammar.h
145
146$(POFILE): $(POFILES)
147	cat $(POFILES) > $(POFILE)
148
149install: all $(ROOTUSRSBINPROG)
150
151svccfg_lex.c: svccfg.l svccfg_grammar.h
152	$(LEX) $(LFLAGS) svccfg.l > $@
153
154svccfg_help.o: svccfg_grammar.h
155svccfg_help-native.o: svccfg_grammar.h
156
157svccfg_grammar.h svccfg_grammar.c: svccfg.y
158	$(YACC) $(YFLAGS) svccfg.y
159	@$(MV) y.tab.h svccfg_grammar.h
160	@$(MV) y.tab.c svccfg_grammar.c
161
162clean: FRC
163	$(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) $(LNTS)
164
165lint: $(LNTS)
166	$(LINT.c) $(LINTFLAGS) $(LNTS) $(LDLIBS)
167
168%-native.o: %.c
169	$(COMPILE.c) -o $@ $<
170	$(POST_PROCESS_O)
171
172%-native.o: ../common/%.c
173	$(COMPILE.c) -o $@ $<
174	$(POST_PROCESS_O)
175
176%.o: ../common/%.c
177	$(COMPILE.c) $(OUTPUT_OPTION) $<
178	$(POST_PROCESS_O)
179
180%.ln: ../common/%.c
181	$(LINT.c) $(OUTPUT_OPTION) -c $<
182
183include ../../Makefile.targ
184
185FRC:
186