xref: /illumos-gate/usr/src/cmd/svc/svccfg/Makefile (revision e0ad97e3)
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#
238afbae07SRod Evans# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate# Use is subject to license terms.
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-gateLNTS =		$(SRCS:%.c=%.ln) \
397c478bd9Sstevel@tonic-gate		manifest_hash.ln
407c478bd9Sstevel@tonic-gate
417c478bd9Sstevel@tonic-gateMYOBJS =	$(SRCS:%.c=%.o) \
427c478bd9Sstevel@tonic-gate		svccfg_grammar.o \
437c478bd9Sstevel@tonic-gate		svccfg_lex.o \
447c478bd9Sstevel@tonic-gate		manifest_hash.o
457c478bd9Sstevel@tonic-gateOBJS =		$(MYOBJS)
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gatePOFILES = 	$(SRCS:%.c=%.po) \
487c478bd9Sstevel@tonic-gate		svccfg_grammar.po \
497c478bd9Sstevel@tonic-gate		svccfg_lex.po \
507c478bd9Sstevel@tonic-gate		../common/manifest_hash.po
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gateinclude ../../Makefile.cmd
53*e0ad97e3SJonathan Adamsinclude ../../Makefile.ctf
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gatePOFILE =	$(PROG)_all.po
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gateNATIVE_BUILD=$(POUND_SIGN)
587c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)NOT_NATIVE=$(POUND_SIGN)
597c478bd9Sstevel@tonic-gate
607c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)PROG = $(MYPROG:%=%-native)
617c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)OBJS = $(MYOBJS:%.o=%-native.o)
627c478bd9Sstevel@tonic-gate
63df4628cbSrie# svccfg has a name clash with main() and libl.so.1.  However, svccfg must
64df4628cbSrie# still export a number of "yy*" (libl) interfaces.  Reduce all other symbols
65df4628cbSrie# to local scope.
66df4628cbSrieMAPFILES +=	$(MAPFILE.LEX) $(MAPFILE.NGB)
67df4628cbSrieMAPOPTS =	$(MAPFILES:%=-M%)
68df4628cbSrie
697c478bd9Sstevel@tonic-gateMYCPPFLAGS =	-I ../common -I/usr/include/libxml2
707c478bd9Sstevel@tonic-gateCPPFLAGS +=	$(MYCPPFLAGS)
71df4628cbSrieLDFLAGS +=	$(MAPOPTS)
727c478bd9Sstevel@tonic-gate
737c478bd9Sstevel@tonic-gateLFLAGS = -t
747c478bd9Sstevel@tonic-gateYFLAGS = -d
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gateCLOBBERFILES += svccfg_lex.c svccfg_grammar.c svccfg_grammar.h \
777c478bd9Sstevel@tonic-gate    $(MYPROG:%=%-native)
787c478bd9Sstevel@tonic-gate
7967e3a03eSrieSVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd5
807c478bd9Sstevel@tonic-gate$(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla
817c478bd9Sstevel@tonic-gate
827c478bd9Sstevel@tonic-gateLIBSCF		= $(SRC)/lib/libscf
837c478bd9Sstevel@tonic-gateLIBTECLA	= $(SRC)/lib/libtecla		# just for the header
847c478bd9Sstevel@tonic-gateLIBUUTIL	= $(SRC)/lib/libuutil
857c478bd9Sstevel@tonic-gate
867c478bd9Sstevel@tonic-gatedebug := COPTFLAG = -g
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gatelint := LINTFLAGS = -mux
897c478bd9Sstevel@tonic-gatelint := SVCCFG_EXTRA_LIBS = -lscf -ll -luutil -lumem -lmd5
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gateLDLIBS += $(SVCCFG_EXTRA_LIBS)
927c478bd9Sstevel@tonic-gate
937c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)CC =	$(NATIVECC)
947c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)LD =	$(NATIVELD)
957c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)CFLAGS =	$(NATIVE_CFLAGS)
967c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)CPPFLAGS = \
977c478bd9Sstevel@tonic-gate	-DNATIVE_BUILD \
987c478bd9Sstevel@tonic-gate	$(MYCPPFLAGS) \
997c478bd9Sstevel@tonic-gate	-I$(LIBSCF)/inc \
1007c478bd9Sstevel@tonic-gate	-I$(LIBTECLA) \
1017c478bd9Sstevel@tonic-gate	-I$(LIBUUTIL)/common
1027c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)LDFLAGS =
1037c478bd9Sstevel@tonic-gate$(NATIVE_BUILD)LDLIBS = \
1047c478bd9Sstevel@tonic-gate	-L$(LIBUUTIL)/native -R $(LIBUUTIL)/native \
1057c478bd9Sstevel@tonic-gate	-L$(LIBSCF)/native -R $(LIBSCF)/native \
1068afbae07SRod Evans	$(SVCCFG_EXTRA_LIBS)
1077c478bd9Sstevel@tonic-gate
1087c478bd9Sstevel@tonic-gatesvccfg_lex.o svccfg_grammar.o := CCVERBOSE =
1097c478bd9Sstevel@tonic-gate
1107c478bd9Sstevel@tonic-gatesvccfg_help.po := XGETFLAGS =	-a
1117c478bd9Sstevel@tonic-gate
1127c478bd9Sstevel@tonic-gate.KEEP_STATE:
1137c478bd9Sstevel@tonic-gate.PARALLEL: $(OBJS) $(LNTS)
1147c478bd9Sstevel@tonic-gate
1157c478bd9Sstevel@tonic-gateall debug: $(PROG)
1167c478bd9Sstevel@tonic-gate
1177c478bd9Sstevel@tonic-gatenative: FRC
1187c478bd9Sstevel@tonic-gate	@cd $(LIBUUTIL)/native; pwd; $(MAKE) $(MFLAGS) install
1197c478bd9Sstevel@tonic-gate	@cd $(LIBSCF)/native; pwd; $(MAKE) $(MFLAGS) install
1207c478bd9Sstevel@tonic-gate	@NATIVE_BUILD= $(MAKE) $(MFLAGS) all
1217c478bd9Sstevel@tonic-gate
122df4628cbSrie$(PROG): $(OBJS) $(MAPFILES)
123*e0ad97e3SJonathan Adams	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
1247c478bd9Sstevel@tonic-gate	$(POST_PROCESS)
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate$(POFILE): $(POFILES)
1277c478bd9Sstevel@tonic-gate	cat $(POFILES) > $(POFILE)
1287c478bd9Sstevel@tonic-gate
1297c478bd9Sstevel@tonic-gateinstall: all $(ROOTUSRSBINPROG)
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gatesvccfg_lex.c: svccfg.l svccfg_grammar.h
1327c478bd9Sstevel@tonic-gate	$(LEX) $(LFLAGS) svccfg.l > $@
1337c478bd9Sstevel@tonic-gate
1347c478bd9Sstevel@tonic-gatesvccfg_help.o: svccfg_grammar.h
1357c478bd9Sstevel@tonic-gatesvccfg_help-native.o: svccfg_grammar.h
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gatesvccfg_grammar.h svccfg_grammar.c: svccfg.y
1387c478bd9Sstevel@tonic-gate	$(YACC) $(YFLAGS) svccfg.y
1397c478bd9Sstevel@tonic-gate	@$(MV) y.tab.h svccfg_grammar.h
1407c478bd9Sstevel@tonic-gate	@$(MV) y.tab.c svccfg_grammar.c
1417c478bd9Sstevel@tonic-gate
1427c478bd9Sstevel@tonic-gateclean: FRC
1437c478bd9Sstevel@tonic-gate	$(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) $(LNTS)
1447c478bd9Sstevel@tonic-gate
1457c478bd9Sstevel@tonic-gatelint: $(LNTS)
1467c478bd9Sstevel@tonic-gate	$(LINT.c) $(LINTFLAGS) $(LNTS) $(LDLIBS)
1477c478bd9Sstevel@tonic-gate
1487c478bd9Sstevel@tonic-gate%-native.o: %.c
149*e0ad97e3SJonathan Adams	$(COMPILE.c) -o $@ $<
1507c478bd9Sstevel@tonic-gate	$(POST_PROCESS_O)
1517c478bd9Sstevel@tonic-gate
1527c478bd9Sstevel@tonic-gate%-native.o: ../common/%.c
153*e0ad97e3SJonathan Adams	$(COMPILE.c) -o $@ $<
1547c478bd9Sstevel@tonic-gate	$(POST_PROCESS_O)
1557c478bd9Sstevel@tonic-gate
1567c478bd9Sstevel@tonic-gate%.o: ../common/%.c
157*e0ad97e3SJonathan Adams	$(COMPILE.c) $(OUTPUT_OPTION) $<
1587c478bd9Sstevel@tonic-gate	$(POST_PROCESS_O)
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gate%.ln: ../common/%.c
1617c478bd9Sstevel@tonic-gate	$(LINT.c) $(OUTPUT_OPTION) -c $<
1627c478bd9Sstevel@tonic-gate
1637c478bd9Sstevel@tonic-gateinclude ../../Makefile.targ
1647c478bd9Sstevel@tonic-gate
1657c478bd9Sstevel@tonic-gateFRC:
166