xref: /illumos-gate/usr/src/cmd/svc/svccfg/Makefile (revision 4f924176)
17c478bd9Sstevel@tonic-gate#
27c478bd9Sstevel@tonic-gate# CDDL HEADER START
37c478bd9Sstevel@tonic-gate#
47c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
524da5b34Srie# Common Development and Distribution License (the "License").
624da5b34Srie# You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate#
87c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate# and limitations under the License.
127c478bd9Sstevel@tonic-gate#
137c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate#
197c478bd9Sstevel@tonic-gate# CDDL HEADER END
207c478bd9Sstevel@tonic-gate#
2124da5b34Srie
227c478bd9Sstevel@tonic-gate#
23f6e214c7SGavin Maltby# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
243e3015ceSJohn Levon# Copyright 2020 Joyent, Inc.
257c478bd9Sstevel@tonic-gate#
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gateMYPROG =	svccfg
287c478bd9Sstevel@tonic-gatePROG =		$(MYPROG)
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gateSRCS  =		svccfg_main.c \
317c478bd9Sstevel@tonic-gate		svccfg_engine.c \
327c478bd9Sstevel@tonic-gate		svccfg_internal.c \
337c478bd9Sstevel@tonic-gate		svccfg_libscf.c \
341f6eb021SLiane Praza		svccfg_tmpl.c \
357c478bd9Sstevel@tonic-gate		svccfg_xml.c \
367c478bd9Sstevel@tonic-gate		svccfg_help.c
377c478bd9Sstevel@tonic-gate
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gateMYOBJS =	$(SRCS:%.c=%.o) \
407c478bd9Sstevel@tonic-gate		svccfg_grammar.o \
417c478bd9Sstevel@tonic-gate		svccfg_lex.o \
429444c26fSTom Whitten		manifest_find.o \
43f6e214c7SGavin Maltby		manifest_hash.o \
44f6e214c7SGavin Maltby		notify_params.o
457c478bd9Sstevel@tonic-gateOBJS =		$(MYOBJS)
467c478bd9Sstevel@tonic-gate
47299e09deSRichard LowePOFILES =	$(SRCS:%.c=%.po) \
487c478bd9Sstevel@tonic-gate		svccfg_grammar.po \
497c478bd9Sstevel@tonic-gate		svccfg_lex.po \
509444c26fSTom Whitten		../common/manifest_find.po \
517c478bd9Sstevel@tonic-gate		../common/manifest_hash.po
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gateinclude ../../Makefile.cmd
54e0ad97e3SJonathan Adamsinclude ../../Makefile.ctf
557c478bd9Sstevel@tonic-gate
567c478bd9Sstevel@tonic-gatePOFILE =	$(PROG)_all.po
577c478bd9Sstevel@tonic-gate
587c478bd9Sstevel@tonic-gateNATIVE_BUILD=$(POUND_SIGN)
597c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)NOT_NATIVE=$(POUND_SIGN)
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)PROG = $(MYPROG:%=%-native)
627c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)OBJS = $(MYOBJS:%.o=%-native.o)
637c478bd9Sstevel@tonic-gate
64df4628cbSrie# svccfg has a name clash with main() and libl.so.1.  However, svccfg must
65df4628cbSrie# still export a number of "yy*" (libl) interfaces.  Reduce all other symbols
66df4628cbSrie# to local scope.
67df4628cbSrieMAPFILES +=	$(MAPFILE.LEX) $(MAPFILE.NGB)
6885f4cb87SRichard LoweMAPOPTS =	$(MAPFILES:%=-Wl,-M%)
69df4628cbSrie
70*4f924176SRobert Mustacchi$(NOT_NATIVE)MYCPPFLAGS =	-I ../common -I$(ADJUNCT_PROTO)/usr/include/libxml2
71*4f924176SRobert Mustacchi$(NATIVE_BUILD)MYCPPFLAGS =	-I ../common -I$(NATIVE_ADJUNCT)/include/libxml2
727c478bd9Sstevel@tonic-gateCPPFLAGS +=	$(MYCPPFLAGS)
73df4628cbSrieLDFLAGS +=	$(MAPOPTS)
747c478bd9Sstevel@tonic-gate
757014882cSRichard LoweCERRWARN +=	-_gcc=-Wno-unused-label
767014882cSRichard LoweCERRWARN +=	-_gcc=-Wno-implicit-function-declaration
777014882cSRichard LoweCERRWARN +=	-_gcc=-Wno-switch
78d3b5f563SJohn LevonCERRWARN +=	$(CNOWARN_UNINIT)
797014882cSRichard LoweCERRWARN +=	-_gcc=-Wno-unused-variable
807014882cSRichard LoweCERRWARN +=	-_gcc=-Wno-parentheses
817014882cSRichard Lowe
825661bb76SJohn Levon# not linted
835661bb76SJohn LevonSMATCH=off
845661bb76SJohn Levon
857c478bd9Sstevel@tonic-gateLFLAGS = -t
867c478bd9Sstevel@tonic-gateYFLAGS = -d
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gateCLOBBERFILES += svccfg_lex.c svccfg_grammar.c svccfg_grammar.h \
897c478bd9Sstevel@tonic-gate    $(MYPROG:%=%-native)
907c478bd9Sstevel@tonic-gate
91*4f924176SRobert MustacchiSVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd -lnvpair
927c478bd9Sstevel@tonic-gate$(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla
933e3015ceSJohn Levon#
943e3015ceSJohn Levon# If no adjunct, then we'll already find /usr/lib via LDLIBS below.
953e3015ceSJohn Levon#
96*4f924176SRobert MustacchiNATIVE_LIBS += libxml2.so libl.so libumem.so libmd.so libnvpair.so libc.so
977c478bd9Sstevel@tonic-gate
987c478bd9Sstevel@tonic-gateLIBSCF		= $(SRC)/lib/libscf
997c478bd9Sstevel@tonic-gateLIBTECLA	= $(SRC)/lib/libtecla		# just for the header
1007c478bd9Sstevel@tonic-gateLIBUUTIL	= $(SRC)/lib/libuutil
1017c478bd9Sstevel@tonic-gate
1027c478bd9Sstevel@tonic-gateLDLIBS += $(SVCCFG_EXTRA_LIBS)
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)CC =	$(NATIVECC)
1057c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)LD =	$(NATIVELD)
1067c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)CFLAGS =	$(NATIVE_CFLAGS)
1077c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)CPPFLAGS = \
1087c478bd9Sstevel@tonic-gate	-DNATIVE_BUILD \
1097c478bd9Sstevel@tonic-gate	$(MYCPPFLAGS) \
1107c478bd9Sstevel@tonic-gate	-I$(LIBSCF)/inc \
1117c478bd9Sstevel@tonic-gate	-I$(LIBTECLA) \
1127c478bd9Sstevel@tonic-gate	-I$(LIBUUTIL)/common
1135801b0f0SToomas Soome$(NATIVE_BUILD)LDFLAGS = $(BDIRECT)
1147c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)LDLIBS = \
1157c478bd9Sstevel@tonic-gate	-L$(LIBUUTIL)/native -R $(LIBUUTIL)/native \
1167c478bd9Sstevel@tonic-gate	-L$(LIBSCF)/native -R $(LIBSCF)/native \
117*4f924176SRobert Mustacchi	-L$(NATIVE_ADJUNCT)/lib -R$(NATIVE_ADJUNCT)/lib \
1188afbae07SRod Evans	$(SVCCFG_EXTRA_LIBS)
1197c478bd9Sstevel@tonic-gate
1207c478bd9Sstevel@tonic-gatesvccfg_lex.o svccfg_grammar.o := CCVERBOSE =
1217c478bd9Sstevel@tonic-gate
1227c478bd9Sstevel@tonic-gatesvccfg_help.po := XGETFLAGS =	-a
1237c478bd9Sstevel@tonic-gate
1247c478bd9Sstevel@tonic-gate.KEEP_STATE:
12585f4cb87SRichard Lowe.PARALLEL: $(OBJS)
1267c478bd9Sstevel@tonic-gate
1277c478bd9Sstevel@tonic-gateall debug: $(PROG)
1287c478bd9Sstevel@tonic-gate
1297c478bd9Sstevel@tonic-gatenative: FRC
130f96a0cefSRichard Lowe	@cd $(LIBUUTIL)/native; pwd; $(MAKE) install
131f96a0cefSRichard Lowe	@cd $(LIBSCF)/native; pwd; $(MAKE) install
132f96a0cefSRichard Lowe	@NATIVE_BUILD= $(MAKE) all
1337c478bd9Sstevel@tonic-gate
134df4628cbSrie$(PROG): $(OBJS) $(MAPFILES)
135e0ad97e3SJonathan Adams	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
1367c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
1377c478bd9Sstevel@tonic-gate
1389e01f109SJason King$(POFILES): svccfg_grammar.h
1399e01f109SJason King
1407c478bd9Sstevel@tonic-gate$(POFILE): $(POFILES)
1417c478bd9Sstevel@tonic-gate	cat $(POFILES) > $(POFILE)
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gateinstall: all $(ROOTUSRSBINPROG)
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gatesvccfg_lex.c: svccfg.l svccfg_grammar.h
1467c478bd9Sstevel@tonic-gate	$(LEX) $(LFLAGS) svccfg.l > $@
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gatesvccfg_help.o: svccfg_grammar.h
1497c478bd9Sstevel@tonic-gatesvccfg_help-native.o: svccfg_grammar.h
1507c478bd9Sstevel@tonic-gate
1517c478bd9Sstevel@tonic-gatesvccfg_grammar.h svccfg_grammar.c: svccfg.y
1527c478bd9Sstevel@tonic-gate	$(YACC) $(YFLAGS) svccfg.y
1537c478bd9Sstevel@tonic-gate	@$(MV) y.tab.h svccfg_grammar.h
1547c478bd9Sstevel@tonic-gate	@$(MV) y.tab.c svccfg_grammar.c
1557c478bd9Sstevel@tonic-gate
1567c478bd9Sstevel@tonic-gateclean: FRC
15785f4cb87SRichard Lowe	$(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o)
1587c478bd9Sstevel@tonic-gate
1597c478bd9Sstevel@tonic-gate%-native.o: %.c
160e0ad97e3SJonathan Adams	$(COMPILE.c) -o $@ $<
1617c478bd9Sstevel@tonic-gate	$(POST_PROCESS_O)
1627c478bd9Sstevel@tonic-gate
1637c478bd9Sstevel@tonic-gate%-native.o: ../common/%.c
164e0ad97e3SJonathan Adams	$(COMPILE.c) -o $@ $<
1657c478bd9Sstevel@tonic-gate	$(POST_PROCESS_O)
1667c478bd9Sstevel@tonic-gate
1677c478bd9Sstevel@tonic-gate%.o: ../common/%.c
168e0ad97e3SJonathan Adams	$(COMPILE.c) $(OUTPUT_OPTION) $<
1697c478bd9Sstevel@tonic-gate	$(POST_PROCESS_O)
1707c478bd9Sstevel@tonic-gate
1717c478bd9Sstevel@tonic-gateinclude ../../Makefile.targ
1727c478bd9Sstevel@tonic-gate
1737c478bd9Sstevel@tonic-gateFRC:
174