xref: /illumos-gate/usr/src/cmd/svc/svccfg/Makefile (revision 3fced4392c3510db4e569c4f8188c45bb5b5f5d3)
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 2010 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
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
47OBJS =		$(MYOBJS)
48
49POFILES = 	$(SRCS:%.c=%.po) \
50		svccfg_grammar.po \
51		svccfg_lex.po \
52		../common/manifest_find.po \
53		../common/manifest_hash.po
54
55include ../../Makefile.cmd
56include ../../Makefile.ctf
57
58POFILE =	$(PROG)_all.po
59
60NATIVE_BUILD=$(POUND_SIGN)
61$(NATIVE_BUILD)NOT_NATIVE=$(POUND_SIGN)
62
63$(NATIVE_BUILD)PROG = $(MYPROG:%=%-native)
64$(NATIVE_BUILD)OBJS = $(MYOBJS:%.o=%-native.o)
65
66# svccfg has a name clash with main() and libl.so.1.  However, svccfg must
67# still export a number of "yy*" (libl) interfaces.  Reduce all other symbols
68# to local scope.
69MAPFILES +=	$(MAPFILE.LEX) $(MAPFILE.NGB)
70MAPOPTS =	$(MAPFILES:%=-M%)
71
72MYCPPFLAGS =	-I ../common -I/usr/include/libxml2
73CPPFLAGS +=	$(MYCPPFLAGS)
74LDFLAGS +=	$(MAPOPTS)
75
76LFLAGS = -t
77YFLAGS = -d
78
79CLOBBERFILES += svccfg_lex.c svccfg_grammar.c svccfg_grammar.h \
80    $(MYPROG:%=%-native)
81
82SVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd5
83$(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla
84
85LIBSCF		= $(SRC)/lib/libscf
86LIBTECLA	= $(SRC)/lib/libtecla		# just for the header
87LIBUUTIL	= $(SRC)/lib/libuutil
88
89debug := COPTFLAG = -g
90
91lint := LINTFLAGS = -mux
92lint := SVCCFG_EXTRA_LIBS = -lscf -ll -luutil -lumem -lmd5
93
94LDLIBS += $(SVCCFG_EXTRA_LIBS)
95
96$(NATIVE_BUILD)CC =	$(NATIVECC)
97$(NATIVE_BUILD)LD =	$(NATIVELD)
98$(NATIVE_BUILD)CFLAGS =	$(NATIVE_CFLAGS)
99$(NATIVE_BUILD)CPPFLAGS = \
100	-DNATIVE_BUILD \
101	$(MYCPPFLAGS) \
102	-I$(LIBSCF)/inc \
103	-I$(LIBTECLA) \
104	-I$(LIBUUTIL)/common
105$(NATIVE_BUILD)LDFLAGS =
106$(NATIVE_BUILD)LDLIBS = \
107	-L$(LIBUUTIL)/native -R $(LIBUUTIL)/native \
108	-L$(LIBSCF)/native -R $(LIBSCF)/native \
109	$(SVCCFG_EXTRA_LIBS)
110
111svccfg_lex.o svccfg_grammar.o := CCVERBOSE =
112
113svccfg_help.po := XGETFLAGS =	-a
114
115.KEEP_STATE:
116.PARALLEL: $(OBJS) $(LNTS)
117
118all debug: $(PROG)
119
120native: FRC
121	@cd $(LIBUUTIL)/native; pwd; $(MAKE) $(MFLAGS) install
122	@cd $(LIBSCF)/native; pwd; $(MAKE) $(MFLAGS) install
123	@NATIVE_BUILD= $(MAKE) $(MFLAGS) all
124
125$(PROG): $(OBJS) $(MAPFILES)
126	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
127	$(POST_PROCESS)
128
129$(POFILE): $(POFILES)
130	cat $(POFILES) > $(POFILE)
131
132install: all $(ROOTUSRSBINPROG)
133
134svccfg_lex.c: svccfg.l svccfg_grammar.h
135	$(LEX) $(LFLAGS) svccfg.l > $@
136
137svccfg_help.o: svccfg_grammar.h
138svccfg_help-native.o: svccfg_grammar.h
139
140svccfg_grammar.h svccfg_grammar.c: svccfg.y
141	$(YACC) $(YFLAGS) svccfg.y
142	@$(MV) y.tab.h svccfg_grammar.h
143	@$(MV) y.tab.c svccfg_grammar.c
144
145clean: FRC
146	$(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) $(LNTS)
147
148lint: $(LNTS)
149	$(LINT.c) $(LINTFLAGS) $(LNTS) $(LDLIBS)
150
151%-native.o: %.c
152	$(COMPILE.c) -o $@ $<
153	$(POST_PROCESS_O)
154
155%-native.o: ../common/%.c
156	$(COMPILE.c) -o $@ $<
157	$(POST_PROCESS_O)
158
159%.o: ../common/%.c
160	$(COMPILE.c) $(OUTPUT_OPTION) $<
161	$(POST_PROCESS_O)
162
163%.ln: ../common/%.c
164	$(LINT.c) $(OUTPUT_OPTION) -c $<
165
166include ../../Makefile.targ
167
168FRC:
169