Back to home page

OSCL-LXR

 
 

    


0001 # SPDX-License-Identifier: GPL-2.0
0002 PROG=   aicasm
0003 
0004 OUTDIR ?= ./
0005 
0006 .SUFFIXES= .l .y .c .h
0007 
0008 CSRCS=  aicasm.c aicasm_symbol.c
0009 YSRCS=  aicasm_gram.y aicasm_macro_gram.y
0010 LSRCS=  aicasm_scan.l aicasm_macro_scan.l
0011 
0012 GENHDRS=        $(addprefix ${OUTDIR}/,aicdb.h $(YSRCS:.y=.h))
0013 GENSRCS=        $(addprefix ${OUTDIR}/,$(YSRCS:.y=.c) $(LSRCS:.l=.c))
0014 
0015 SRCS=   ${CSRCS} ${GENSRCS}
0016 LIBS=   -ldb
0017 clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
0018 # Override default kernel CFLAGS.  This is a userland app.
0019 AICASM_CFLAGS:= -I/usr/include -I. -I$(OUTDIR) 
0020 LEX= flex
0021 YACC= bison
0022 YFLAGS= -d
0023 
0024 NOMAN=  noman
0025 
0026 ifneq ($(HOSTCC),)
0027 AICASM_CC= $(HOSTCC)
0028 else
0029 AICASM_CC= $(CC)
0030 endif
0031 
0032 ifdef DEBUG
0033 CFLAGS+= -DDEBUG -g
0034 YFLAGS+= -t -v
0035 LFLAGS= -d
0036 endif
0037 
0038 $(PROG):  $(OUTDIR) ${GENHDRS} $(SRCS)
0039         $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(OUTDIR)/$(PROG) $(LIBS)
0040 
0041 $(OUTDIR):
0042         mkdir -p $(OUTDIR)
0043 
0044 $(OUTDIR)/aicdb.h:
0045         @if [ -e "/usr/include/db4/db_185.h" ]; then            \
0046                 echo "#include <db4/db_185.h>" > $@;    \
0047          elif [ -e "/usr/include/db3/db_185.h" ]; then          \
0048                 echo "#include <db3/db_185.h>" > $@;    \
0049          elif [ -e "/usr/include/db2/db_185.h" ]; then          \
0050                 echo "#include <db2/db_185.h>" > $@;    \
0051          elif [ -e "/usr/include/db1/db_185.h" ]; then          \
0052                 echo "#include <db1/db_185.h>" > $@;    \
0053          elif [ -e "/usr/include/db/db_185.h" ]; then           \
0054                 echo "#include <db/db_185.h>" > $@;     \
0055          elif [ -e "/usr/include/db_185.h" ]; then              \
0056                 echo "#include <db_185.h>" > $@;                \
0057          else                                                   \
0058                 echo "*** Install db development libraries";    \
0059          fi
0060 
0061 clean:
0062         rm -f $(clean-files)
0063 
0064 # Create a dependency chain in generated files
0065 # to avoid concurrent invocations of the single
0066 # rule that builds them all.
0067 $(OUTDIR)/aicasm_gram.c: $(OUTDIR)/aicasm_gram.h
0068 $(OUTDIR)/aicasm_gram.c $(OUTDIR)/aicasm_gram.h: aicasm_gram.y
0069         $(YACC) $(YFLAGS) -b $(<:.y=) $<
0070         mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c)
0071         mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h)
0072 
0073 # Create a dependency chain in generated files
0074 # to avoid concurrent invocations of the single
0075 # rule that builds them all.
0076 $(OUTDIR)/aicasm_macro_gram.c: $(OUTDIR)/aicasm_macro_gram.h
0077 $(OUTDIR)/aicasm_macro_gram.c $(OUTDIR)/aicasm_macro_gram.h: aicasm_macro_gram.y
0078         $(YACC) $(YFLAGS) -b $(<:.y=) -p mm $<
0079         mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c)
0080         mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h)
0081 
0082 $(OUTDIR)/aicasm_scan.c: aicasm_scan.l
0083         $(LEX) $(LFLAGS) -o $@ $<
0084 
0085 $(OUTDIR)/aicasm_macro_scan.c: aicasm_macro_scan.l
0086         $(LEX) $(LFLAGS) -Pmm -o $@ $<