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 CPPFLAGS +=     $(MYCPPFLAGS)
  74 LDFLAGS +=      $(MAPOPTS)
  75 
  76 CERRWARN +=     -_gcc=-Wno-unused-label
  77 CERRWARN +=     -_gcc=-Wno-implicit-function-declaration
  78 CERRWARN +=     -_gcc=-Wno-switch
  79 CERRWARN +=     -_gcc=-Wno-uninitialized
  80 CERRWARN +=     -_gcc=-Wno-unused-variable
  81 CERRWARN +=     -_gcc=-Wno-parentheses
  82 
  83 LFLAGS = -t
  84 YFLAGS = -d
  85 
  86 CLOBBERFILES += svccfg_lex.c svccfg_grammar.c svccfg_grammar.h \
  87     $(MYPROG:%=%-native)
  88 
  89 SVCCFG_EXTRA_LIBS = -lxml2 -lscf -ll -luutil -lumem -lmd5 -lnvpair
  90 $(NOT_NATIVE)SVCCFG_EXTRA_LIBS += -ltecla
  91 
  92 LIBSCF          = $(SRC)/lib/libscf
  93 LIBTECLA        = $(SRC)/lib/libtecla           # just for the header
  94 LIBUUTIL        = $(SRC)/lib/libuutil
  95 
  96 debug := COPTFLAG = -g
  97 
  98 lint := LINTFLAGS = -mux
  99 lint := SVCCFG_EXTRA_LIBS = -lscf -ll -luutil -lumem -lmd5 -lnvpair
 100 
 101 LDLIBS += $(SVCCFG_EXTRA_LIBS)
 102 
 103 $(NATIVE_BUILD)CC =     $(NATIVECC)
 104 $(NATIVE_BUILD)LD =     $(NATIVELD)
 105 $(NATIVE_BUILD)CFLAGS = $(NATIVE_CFLAGS)
 106 $(NATIVE_BUILD)CPPFLAGS = \
 107         -DNATIVE_BUILD \
 108         $(MYCPPFLAGS) \
 109         -I$(LIBSCF)/inc \
 110         -I$(LIBTECLA) \
 111         -I$(LIBUUTIL)/common
 112 $(NATIVE_BUILD)LDFLAGS =
 113 $(NATIVE_BUILD)LDLIBS = \
 114         -L$(LIBUUTIL)/native -R $(LIBUUTIL)/native \
 115         -L$(LIBSCF)/native -R $(LIBSCF)/native \
 116         -L$(ADJUNCT_PROTO)/usr/lib -R$(ADJUNCT_PROTO)/usr/lib \
 117         $(SVCCFG_EXTRA_LIBS)
 118 
 119 svccfg_lex.o svccfg_grammar.o := CCVERBOSE =
 120 
 121 svccfg_help.po := XGETFLAGS =   -a
 122 
 123 .KEEP_STATE:
 124 .PARALLEL: $(OBJS) $(LNTS)
 125 
 126 all debug: $(PROG)
 127 
 128 native: FRC
 129         @cd $(LIBUUTIL)/native; pwd; $(MAKE) $(MFLAGS) install
 130         @cd $(LIBSCF)/native; pwd; $(MAKE) $(MFLAGS) install
 131         @NATIVE_BUILD= $(MAKE) $(MFLAGS) all
 132 
 133 $(PROG): $(OBJS) $(MAPFILES)
 134         $(LINK.c) -o $@ $(OBJS) $(LDLIBS)
 135         $(POST_PROCESS)
 136 
 137 $(POFILE): $(POFILES)
 138         cat $(POFILES) > $(POFILE)
 139 
 140 install: all $(ROOTUSRSBINPROG)
 141 
 142 svccfg_lex.c: svccfg.l svccfg_grammar.h
 143         $(LEX) $(LFLAGS) svccfg.l > $@
 144 
 145 svccfg_help.o: svccfg_grammar.h
 146 svccfg_help-native.o: svccfg_grammar.h
 147 
 148 svccfg_grammar.h svccfg_grammar.c: svccfg.y
 149         $(YACC) $(YFLAGS) svccfg.y
 150         @$(MV) y.tab.h svccfg_grammar.h
 151         @$(MV) y.tab.c svccfg_grammar.c
 152 
 153 clean: FRC
 154         $(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) $(LNTS)
 155 
 156 lint: $(LNTS)
 157         $(LINT.c) $(LINTFLAGS) $(LNTS) $(LDLIBS)
 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 
 171 %.ln: ../common/%.c
 172         $(LINT.c) $(OUTPUT_OPTION) -c $<
 173 
 174 include ../../Makefile.targ
 175 
 176 FRC: