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