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