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 2020 Joyent, Inc. 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 38 39MYOBJS = $(SRCS:%.c=%.o) \ 40 svccfg_grammar.o \ 41 svccfg_lex.o \ 42 manifest_find.o \ 43 manifest_hash.o \ 44 notify_params.o 45OBJS = $(MYOBJS) 46 47POFILES = $(SRCS:%.c=%.po) \ 48 svccfg_grammar.po \ 49 svccfg_lex.po \ 50 ../common/manifest_find.po \ 51 ../common/manifest_hash.po 52 53include ../../Makefile.cmd 54include ../../Makefile.ctf 55 56POFILE = $(PROG)_all.po 57 58NATIVE_BUILD=$(POUND_SIGN) 59$(NATIVE_BUILD)NOT_NATIVE=$(POUND_SIGN) 60 61$(NATIVE_BUILD)PROG = $(MYPROG:%=%-native) 62$(NATIVE_BUILD)OBJS = $(MYOBJS:%.o=%-native.o) 63 64# svccfg has a name clash with main() and libl.so.1. However, svccfg must 65# still export a number of "yy*" (libl) interfaces. Reduce all other symbols 66# to local scope. 67MAPFILES += $(MAPFILE.LEX) $(MAPFILE.NGB) 68MAPOPTS = $(MAPFILES:%=-Wl,-M%) 69 70$(NOT_NATIVE)MYCPPFLAGS = -I ../common -I$(ADJUNCT_PROTO)/usr/include/libxml2 71$(NATIVE_BUILD)MYCPPFLAGS = -I ../common -I$(NATIVE_ADJUNCT)/include/libxml2 72CPPFLAGS += $(MYCPPFLAGS) 73LDFLAGS += $(MAPOPTS) 74 75# These are because of bugs in lex(1)/yacc(1) generated code 76CERRWARN += -_gcc=-Wno-unused-label 77CERRWARN += -_gcc=-Wno-unused-variable 78 79CERRWARN += -_gcc=-Wno-switch 80CERRWARN += $(CNOWARN_UNINIT) 81 82# not linted 83SMATCH=off 84 85LFLAGS = -t 86YFLAGS = -d 87 88CLOBBERFILES += svccfg_lex.c svccfg_grammar.c svccfg_grammar.h \ 89 $(MYPROG:%=%-native) 90 91SVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd -lnvpair 92$(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla 93# 94# If no adjunct, then we'll already find /usr/lib via LDLIBS below. 95# 96NATIVE_LIBS += libxml2.so libl.so libumem.so libmd.so libnvpair.so libc.so 97 98LIBSCF = $(SRC)/lib/libscf 99LIBTECLA = $(SRC)/lib/libtecla # just for the header 100LIBUUTIL = $(SRC)/lib/libuutil 101 102LDLIBS += $(SVCCFG_EXTRA_LIBS) 103 104$(NATIVE_BUILD)CC = $(NATIVECC) 105$(NATIVE_BUILD)LD = $(NATIVELD) 106$(NATIVE_BUILD)CFLAGS = $(NATIVE_CFLAGS) 107$(NATIVE_BUILD)CPPFLAGS = \ 108 -DNATIVE_BUILD \ 109 $(MYCPPFLAGS) \ 110 -I$(LIBSCF)/inc \ 111 -I$(LIBTECLA) \ 112 -I$(LIBUUTIL)/common 113$(NATIVE_BUILD)LDFLAGS = $(BDIRECT) 114$(NATIVE_BUILD)LDLIBS = \ 115 -L$(LIBUUTIL)/native -R $(LIBUUTIL)/native \ 116 -L$(LIBSCF)/native -R $(LIBSCF)/native \ 117 -L$(NATIVE_ADJUNCT)/lib -R$(NATIVE_ADJUNCT)/lib \ 118 $(SVCCFG_EXTRA_LIBS) 119 120svccfg_lex.o svccfg_grammar.o := CCVERBOSE = 121 122svccfg_help.po := XGETFLAGS = -a 123 124.KEEP_STATE: 125.PARALLEL: $(OBJS) 126 127all debug: $(PROG) 128 129native: FRC 130 @cd $(LIBUUTIL)/native; pwd; $(MAKE) install 131 @cd $(LIBSCF)/native; pwd; $(MAKE) install 132 @NATIVE_BUILD= $(MAKE) all 133 134$(PROG): $(OBJS) $(MAPFILES) 135 $(LINK.c) -o $@ $(OBJS) $(LDLIBS) 136 $(POST_PROCESS) 137 138$(POFILES): svccfg_grammar.h 139 140$(POFILE): $(POFILES) 141 cat $(POFILES) > $(POFILE) 142 143install: all $(ROOTUSRSBINPROG) 144 145svccfg_lex.c: svccfg.l svccfg_grammar.h 146 $(LEX) $(LFLAGS) svccfg.l > $@ 147 148svccfg_help.o: svccfg_grammar.h 149svccfg_help-native.o: svccfg_grammar.h 150 151svccfg_grammar.h svccfg_grammar.c: svccfg.y 152 $(YACC) $(YFLAGS) svccfg.y 153 @$(MV) y.tab.h svccfg_grammar.h 154 @$(MV) y.tab.c svccfg_grammar.c 155 156clean: FRC 157 $(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) 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 171include ../../Makefile.targ 172 173FRC: 174