xref: /titanic_51/usr/src/cmd/svc/svccfg/Makefile (revision a776e90690d98f629ab57f6493ff5949af9d65bd)
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 2007 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
27
28MYPROG =	svccfg
29PROG =		$(MYPROG)
30
31SRCS  =		svccfg_main.c \
32		svccfg_engine.c \
33		svccfg_internal.c \
34		svccfg_libscf.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
79LAZYLIBS = $(ZLAZYLOAD) -lxml2 $(ZNOLAZYLOAD)
80SVCCFG_EXTRA_LIBS = $(LAZYLIBS) -lscf -ll -luutil -lumem -lmd5
81$(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla
82
83LIBSCF		= $(SRC)/lib/libscf
84LIBTECLA	= $(SRC)/lib/libtecla		# just for the header
85LIBUUTIL	= $(SRC)/lib/libuutil
86
87debug := COPTFLAG = -g
88
89lint := LINTFLAGS = -mux
90lint := SVCCFG_EXTRA_LIBS = -lscf -ll -luutil -lumem -lmd5
91
92LDLIBS += $(SVCCFG_EXTRA_LIBS)
93
94$(NATIVE_BUILD)CC =	$(NATIVECC)
95$(NATIVE_BUILD)LD =	$(NATIVELD)
96$(NATIVE_BUILD)CFLAGS =	$(NATIVE_CFLAGS)
97$(NATIVE_BUILD)CPPFLAGS = \
98	-DNATIVE_BUILD \
99	$(MYCPPFLAGS) \
100	-I$(LIBSCF)/inc \
101	-I$(LIBTECLA) \
102	-I$(LIBUUTIL)/common
103$(NATIVE_BUILD)LDFLAGS =
104$(NATIVE_BUILD)LDLIBS = \
105	-L$(LIBUUTIL)/native -R $(LIBUUTIL)/native \
106	-L$(LIBSCF)/native -R $(LIBSCF)/native \
107	$(SVCCFG_EXTRA_LIBS) -ldoor
108
109svccfg_lex.o svccfg_grammar.o := CCVERBOSE =
110
111svccfg_help.po := XGETFLAGS =	-a
112
113.KEEP_STATE:
114.PARALLEL: $(OBJS) $(LNTS)
115
116all debug: $(PROG)
117
118native: FRC
119	@cd $(LIBUUTIL)/native; pwd; $(MAKE) $(MFLAGS) install
120	@cd $(LIBSCF)/native; pwd; $(MAKE) $(MFLAGS) install
121	@NATIVE_BUILD= $(MAKE) $(MFLAGS) all
122
123$(PROG): $(OBJS) $(MAPFILES)
124	$(LINK.c) -o $@ $(OBJS) $(LDLIBS) $(CTFMERGE_HOOK)
125	$(POST_PROCESS)
126
127$(POFILE): $(POFILES)
128	cat $(POFILES) > $(POFILE)
129
130install: all $(ROOTUSRSBINPROG)
131
132svccfg_lex.c: svccfg.l svccfg_grammar.h
133	$(LEX) $(LFLAGS) svccfg.l > $@
134
135svccfg_help.o: svccfg_grammar.h
136svccfg_help-native.o: svccfg_grammar.h
137
138svccfg_grammar.h svccfg_grammar.c: svccfg.y
139	$(YACC) $(YFLAGS) svccfg.y
140	@$(MV) y.tab.h svccfg_grammar.h
141	@$(MV) y.tab.c svccfg_grammar.c
142
143clean: FRC
144	$(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) $(LNTS)
145
146lint: $(LNTS)
147	$(LINT.c) $(LINTFLAGS) $(LNTS) $(LDLIBS)
148
149%-native.o: %.c
150	$(COMPILE.c) -o $@ $< $(CTFCONVERT_HOOK)
151	$(POST_PROCESS_O)
152
153%-native.o: ../common/%.c
154	$(COMPILE.c) -o $@ $< $(CTFCONVERT_HOOK)
155	$(POST_PROCESS_O)
156
157%.o: ../common/%.c
158	$(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK)
159	$(POST_PROCESS_O)
160
161%.ln: ../common/%.c
162	$(LINT.c) $(OUTPUT_OPTION) -c $<
163
164include ../../Makefile.targ
165
166FRC:
167