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, Version 1.0 only
   6 # (the "License").  You may not use this file except in compliance
   7 # with the License.
   8 #
   9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10 # or http://www.opensolaris.org/os/licensing.
  11 # See the License for the specific language governing permissions
  12 # and limitations under the License.
  13 #
  14 # When distributing Covered Code, include this CDDL HEADER in each
  15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16 # If applicable, add the following below this CDDL HEADER, with the
  17 # fields enclosed by brackets "[]" replaced with your own identifying
  18 # information: Portions Copyright [yyyy] [name of copyright owner]
  19 #
  20 # CDDL HEADER END
  21 #
  22 
  23 #
  24 # Copyright 1989,2003 Sun Microsystems, Inc.  All rights reserved.
  25 # Use is subject to license terms.
  26 #
  27 # Copyright (c) 2018, Joyent, Inc.
  28 
  29 PROG=           prex
  30 
  31 OBJS.c=         source.o        \
  32                 main.o          \
  33                 util.o          \
  34                 expr.o          \
  35                 spec.o          \
  36                 set.o           \
  37                 queue.o         \
  38                 cmd.o           \
  39                 new.o           \
  40                 list.o          \
  41                 fcn.o           \
  42                 prbk.o          \
  43                 help.o
  44 
  45 OBJS.yl=        prexgram.o      \
  46                 prexlex.o
  47 
  48 OBJS=            $(OBJS.yl) $(OBJS.c)
  49 
  50 SRCS= $(OBJS.c:%.o=../%.c) $(OBJS.yl:%.o=%.c)
  51 
  52 SRCS.yl = $(OBJS.yl:%.o=%.c)
  53 CLEANFILES = $(SRCS.yl)  y.tab.h
  54 
  55 include ../../../Makefile.cmd
  56 
  57 POFILE= prex.po
  58 POFILES= $(OBJS.c:%.o=%.po)
  59 
  60 #YFLAGS=        -d -t -v
  61 YFLAGS=         -d
  62 LFLAGS=         -v
  63 # FOR normal makefile, uncomment the next line
  64 LDLIBS +=       -lgen -ltnfctl -lelf -lc
  65 # Uncomment the following line for a debug build
  66 # COPTFLAG =    -g -DDEBUG
  67 
  68 CFLAGS +=       $(CCVERBOSE)
  69 CERRWARN +=     -_gcc=-Wno-unused-label
  70 CERRWARN +=     -_gcc=-Wno-unused-variable
  71 CERRWARN +=     -_gcc=-Wno-parentheses
  72 CERRWARN +=     -_gcc=-Wno-uninitialized
  73 
  74 # not linted
  75 SMATCH=off
  76 
  77 .KEEP_STATE:
  78 
  79 .PARALLEL: $(OBJS)
  80 
  81 all: $(PROG)
  82 
  83 #OBJS can be built in parallel after all .c (and y.tab.h) are properly built
  84 $(PROG): $(SRCS.yl) .WAIT $(OBJS)
  85         $(LINK.c) $(OBJS) -o $@ $(LDLIBS)
  86         $(POST_PROCESS)
  87 
  88 #This also builds y.tab.h
  89 prexgram.c: ../prexgram.y
  90         $(YACC.y) ../prexgram.y
  91         mv y.tab.c $@
  92 
  93 prexlex.c: ../prexlex.l
  94         $(RM) $@
  95         $(LEX.l) ../prexlex.l > $@
  96 
  97 #Use %.c in priority to ../%.c for prexgram.c and prexlec.c
  98 %.o:    %.c
  99         $(COMPILE.c) $<
 100 
 101 %.o:    ../%.c
 102         $(COMPILE.c) $<
 103 
 104 
 105 $(ROOTBIN):
 106         $(INS.dir)
 107 
 108 $(POFILE):      $(POFILES)
 109         $(RM)   $@
 110         cat     $(POFILES)      > $@
 111 
 112 clean:
 113         $(RM) $(OBJS) $(CLEANFILES)
 114 
 115 lint: $(OBJS) 
 116         $(LINT.c) $(SRCS)
 117 
 118 include ../../../Makefile.targ