xref: /titanic_41/usr/src/cmd/svc/svccfg/Makefile (revision e0724c534a46ca4754330bc022bf1e2a68f5bb93)
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/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	$(SVCCFG_EXTRA_LIBS)
117
118svccfg_lex.o svccfg_grammar.o := CCVERBOSE =
119
120svccfg_help.po := XGETFLAGS =	-a
121
122.KEEP_STATE:
123.PARALLEL: $(OBJS) $(LNTS)
124
125all debug: $(PROG)
126
127native: FRC
128	@cd $(LIBUUTIL)/native; pwd; $(MAKE) $(MFLAGS) install
129	@cd $(LIBSCF)/native; pwd; $(MAKE) $(MFLAGS) install
130	@NATIVE_BUILD= $(MAKE) $(MFLAGS) all
131
132$(PROG): $(OBJS) $(MAPFILES)
133	$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
134	$(POST_PROCESS)
135
136$(POFILE): $(POFILES)
137	cat $(POFILES) > $(POFILE)
138
139install: all $(ROOTUSRSBINPROG)
140
141svccfg_lex.c: svccfg.l svccfg_grammar.h
142	$(LEX) $(LFLAGS) svccfg.l > $@
143
144svccfg_help.o: svccfg_grammar.h
145svccfg_help-native.o: svccfg_grammar.h
146
147svccfg_grammar.h svccfg_grammar.c: svccfg.y
148	$(YACC) $(YFLAGS) svccfg.y
149	@$(MV) y.tab.h svccfg_grammar.h
150	@$(MV) y.tab.c svccfg_grammar.c
151
152clean: FRC
153	$(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) $(LNTS)
154
155lint: $(LNTS)
156	$(LINT.c) $(LINTFLAGS) $(LNTS) $(LDLIBS)
157
158%-native.o: %.c
159	$(COMPILE.c) -o $@ $<
160	$(POST_PROCESS_O)
161
162%-native.o: ../common/%.c
163	$(COMPILE.c) -o $@ $<
164	$(POST_PROCESS_O)
165
166%.o: ../common/%.c
167	$(COMPILE.c) $(OUTPUT_OPTION) $<
168	$(POST_PROCESS_O)
169
170%.ln: ../common/%.c
171	$(LINT.c) $(OUTPUT_OPTION) -c $<
172
173include ../../Makefile.targ
174
175FRC:
176