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 
  26 MYPROG =        svccfg
  27 PROG =          $(MYPROG)
  28 
  29 SRCS  =         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 
  37 LNTS =          $(SRCS:%.c=%.ln) \
  38                 manifest_find.ln \
  39                 manifest_hash.ln
  40 
  41 MYOBJS =        $(SRCS:%.c=%.o) \
  42                 svccfg_grammar.o \
  43                 svccfg_lex.o \
  44                 manifest_find.o \
  45                 manifest_hash.o \
  46                 notify_params.o
  47 OBJS =          $(MYOBJS)
  48 
  49 POFILES =       $(SRCS:%.c=%.po) \
  50                 svccfg_grammar.po \
  51                 svccfg_lex.po \
  52                 ../common/manifest_find.po \
  53                 ../common/manifest_hash.po
  54 
  55 include ../../Makefile.cmd
  56 include ../../Makefile.ctf
  57 
  58 POFILE =        $(PROG)_all.po
  59 
  60 NATIVE_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.
  69 MAPFILES +=     $(MAPFILE.LEX) $(MAPFILE.NGB)
  70 MAPOPTS =       $(MAPFILES:%=-M%)
  71 
  72 MYCPPFLAGS =    -I ../common -I$(ADJUNCT_PROTO)/usr/include/libxml2
  73 $(NATIVE_BUILD)MYCPPFLAGS =     -I ../common \
  74                 -I$(NATIVE_ADJUNCT)/usr/include/libxml2
  75 CPPFLAGS +=     $(MYCPPFLAGS)
  76 LDFLAGS +=      $(MAPOPTS)
  77 
  78 CERRWARN +=     -_gcc=-Wno-unused-label
  79 CERRWARN +=     -_gcc=-Wno-implicit-function-declaration
  80 CERRWARN +=     -_gcc=-Wno-switch
  81 CERRWARN +=     -_gcc=-Wno-uninitialized
  82 CERRWARN +=     -_gcc=-Wno-unused-variable
  83 CERRWARN +=     -_gcc=-Wno-parentheses
  84 
  85 LFLAGS = -t
  86 YFLAGS = -d
  87 
  88 CLOBBERFILES += svccfg_lex.c svccfg_grammar.c svccfg_grammar.h \
  89     $(MYPROG:%=%-native)
  90 
  91 SVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd5 -lnvpair
  92 $(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla
  93 
  94 LIBSCF          = $(SRC)/lib/libscf
  95 LIBTECLA        = $(SRC)/lib/libtecla           # just for the header
  96 LIBUUTIL        = $(SRC)/lib/libuutil
  97 
  98 debug := COPTFLAG = -g
  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$(NATIVE_ADJUNCT)/usr/lib -R$(NATIVE_ADJUNCT)/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 $(POFILE): $(POFILES)
 140         cat $(POFILES) > $(POFILE)
 141 
 142 install: all $(ROOTUSRSBINPROG)
 143 
 144 svccfg_lex.c: svccfg.l svccfg_grammar.h
 145         $(LEX) $(LFLAGS) svccfg.l > $@
 146 
 147 svccfg_help.o: svccfg_grammar.h
 148 svccfg_help-native.o: svccfg_grammar.h
 149 
 150 svccfg_grammar.h svccfg_grammar.c: svccfg.y
 151         $(YACC) $(YFLAGS) svccfg.y
 152         @$(MV) y.tab.h svccfg_grammar.h
 153         @$(MV) y.tab.c svccfg_grammar.c
 154 
 155 clean: FRC
 156         $(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) $(LNTS)
 157 
 158 lint: $(LNTS)
 159         $(LINT.c) $(LINTFLAGS) $(LNTS) $(LDLIBS)
 160 
 161 %-native.o: %.c
 162         $(COMPILE.c) -o $@ $<
 163         $(POST_PROCESS_O)
 164 
 165 %-native.o: ../common/%.c
 166         $(COMPILE.c) -o $@ $<
 167         $(POST_PROCESS_O)
 168 
 169 %.o: ../common/%.c
 170         $(COMPILE.c) $(OUTPUT_OPTION) $<
 171         $(POST_PROCESS_O)
 172 
 173 %.ln: ../common/%.c
 174         $(LINT.c) $(OUTPUT_OPTION) -c $<
 175 
 176 include ../../Makefile.targ
 177 
 178 FRC: