xref: /titanic_51/usr/src/cmd/svc/svccfg/Makefile (revision 9e573dcc6440324d76c37be570afdef86f045685)
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#
25
26MYPROG =	svccfg
27PROG =		$(MYPROG)
28
29SRCS  =		svccfg_main.c \
30		svccfg_engine.c \
31		svccfg_internal.c \
32		svccfg_libscf.c \
33		svccfg_tmpl.c \
34		svccfg_xml.c \
35		svccfg_help.c
36
37LNTS =		$(SRCS:%.c=%.ln) \
38		manifest_find.ln \
39		manifest_hash.ln
40
41MYOBJS =	$(SRCS:%.c=%.o) \
42		svccfg_grammar.o \
43		svccfg_lex.o \
44		manifest_find.o \
45		manifest_hash.o \
46		notify_params.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$(ADJUNCT_PROTO)/usr/include/libxml2
73CPPFLAGS +=	$(MYCPPFLAGS)
74LDFLAGS +=	$(MAPOPTS)
75
76CERRWARN +=	-_gcc=-Wno-unused-label
77CERRWARN +=	-_gcc=-Wno-implicit-function-declaration
78CERRWARN +=	-_gcc=-Wno-switch
79CERRWARN +=	-_gcc=-Wno-uninitialized
80CERRWARN +=	-_gcc=-Wno-unused-variable
81CERRWARN +=	-_gcc=-Wno-parentheses
82
83LFLAGS = -t
84YFLAGS = -d
85
86CLOBBERFILES += svccfg_lex.c svccfg_grammar.c svccfg_grammar.h \
87    $(MYPROG:%=%-native)
88
89SVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd5 -lnvpair
90$(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla
91
92LIBSCF		= $(SRC)/lib/libscf
93LIBTECLA	= $(SRC)/lib/libtecla		# just for the header
94LIBUUTIL	= $(SRC)/lib/libuutil
95
96debug := COPTFLAG = -g
97
98lint := LINTFLAGS = -mux
99lint := SVCCFG_EXTRA_LIBS = -lscf -ll -luutil -lumem -lmd5 -lnvpair
100
101LDLIBS += $(SVCCFG_EXTRA_LIBS)
102
103$(NATIVE_BUILD)CC =	$(NATIVECC)
104$(NATIVE_BUILD)LD =	$(NATIVELD)
105$(NATIVE_BUILD)CFLAGS =	$(NATIVE_CFLAGS)
106$(NATIVE_BUILD)CPPFLAGS = \
107	-DNATIVE_BUILD \
108	$(MYCPPFLAGS) \
109	-I$(LIBSCF)/inc \
110	-I$(LIBTECLA) \
111	-I$(LIBUUTIL)/common
112$(NATIVE_BUILD)LDFLAGS =
113$(NATIVE_BUILD)LDLIBS = \
114	-L$(LIBUUTIL)/native -R $(LIBUUTIL)/native \
115	-L$(LIBSCF)/native -R $(LIBSCF)/native \
116	-L$(ADJUNCT_PROTO)/usr/lib -R$(ADJUNCT_PROTO)/usr/lib \
117	$(SVCCFG_EXTRA_LIBS)
118
119svccfg_lex.o svccfg_grammar.o := CCVERBOSE =
120
121svccfg_help.po := XGETFLAGS =	-a
122
123.KEEP_STATE:
124.PARALLEL: $(OBJS) $(LNTS)
125
126all debug: $(PROG)
127
128native: FRC
129	@cd $(LIBUUTIL)/native; pwd; $(MAKE) $(MFLAGS) install
130	@cd $(LIBSCF)/native; pwd; $(MAKE) $(MFLAGS) install
131	@NATIVE_BUILD= $(MAKE) $(MFLAGS) all
132
133$(PROG): $(OBJS) $(MAPFILES)
134	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
135	$(POST_PROCESS)
136
137$(POFILE): $(POFILES)
138	cat $(POFILES) > $(POFILE)
139
140install: all $(ROOTUSRSBINPROG)
141
142svccfg_lex.c: svccfg.l svccfg_grammar.h
143	$(LEX) $(LFLAGS) svccfg.l > $@
144
145svccfg_help.o: svccfg_grammar.h
146svccfg_help-native.o: svccfg_grammar.h
147
148svccfg_grammar.h svccfg_grammar.c: svccfg.y
149	$(YACC) $(YFLAGS) svccfg.y
150	@$(MV) y.tab.h svccfg_grammar.h
151	@$(MV) y.tab.c svccfg_grammar.c
152
153clean: FRC
154	$(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) $(LNTS)
155
156lint: $(LNTS)
157	$(LINT.c) $(LINTFLAGS) $(LNTS) $(LDLIBS)
158
159%-native.o: %.c
160	$(COMPILE.c) -o $@ $<
161	$(POST_PROCESS_O)
162
163%-native.o: ../common/%.c
164	$(COMPILE.c) -o $@ $<
165	$(POST_PROCESS_O)
166
167%.o: ../common/%.c
168	$(COMPILE.c) $(OUTPUT_OPTION) $<
169	$(POST_PROCESS_O)
170
171%.ln: ../common/%.c
172	$(LINT.c) $(OUTPUT_OPTION) -c $<
173
174include ../../Makefile.targ
175
176FRC:
177