1*b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 21da177e4SLinus TorvaldsPROG= aicasm 31da177e4SLinus Torvalds 4516b7db5SJakub KicinskiOUTDIR ?= ./ 5516b7db5SJakub Kicinski 61da177e4SLinus Torvalds.SUFFIXES= .l .y .c .h 71da177e4SLinus Torvalds 81da177e4SLinus TorvaldsCSRCS= aicasm.c aicasm_symbol.c 91da177e4SLinus TorvaldsYSRCS= aicasm_gram.y aicasm_macro_gram.y 101da177e4SLinus TorvaldsLSRCS= aicasm_scan.l aicasm_macro_scan.l 111da177e4SLinus Torvalds 12516b7db5SJakub KicinskiGENHDRS= $(addprefix ${OUTDIR}/,aicdb.h $(YSRCS:.y=.h)) 13516b7db5SJakub KicinskiGENSRCS= $(addprefix ${OUTDIR}/,$(YSRCS:.y=.c) $(LSRCS:.l=.c)) 141da177e4SLinus Torvalds 151da177e4SLinus TorvaldsSRCS= ${CSRCS} ${GENSRCS} 161da177e4SLinus TorvaldsLIBS= -ldb 171da177e4SLinus Torvaldsclean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG) 181da177e4SLinus Torvalds# Override default kernel CFLAGS. This is a userland app. 19516b7db5SJakub KicinskiAICASM_CFLAGS:= -I/usr/include -I. -I$(OUTDIR) 20dba654d1SSam RavnborgLEX= flex 21dba654d1SSam RavnborgYACC= bison 221da177e4SLinus TorvaldsYFLAGS= -d 231da177e4SLinus Torvalds 241da177e4SLinus TorvaldsNOMAN= noman 251da177e4SLinus Torvalds 261da177e4SLinus Torvaldsifneq ($(HOSTCC),) 271da177e4SLinus TorvaldsAICASM_CC= $(HOSTCC) 281da177e4SLinus Torvaldselse 291da177e4SLinus TorvaldsAICASM_CC= $(CC) 301da177e4SLinus Torvaldsendif 311da177e4SLinus Torvalds 321da177e4SLinus Torvaldsifdef DEBUG 331da177e4SLinus TorvaldsCFLAGS+= -DDEBUG -g 341da177e4SLinus TorvaldsYFLAGS+= -t -v 351da177e4SLinus TorvaldsLFLAGS= -d 361da177e4SLinus Torvaldsendif 371da177e4SLinus Torvalds 38516b7db5SJakub Kicinski$(PROG): $(OUTDIR) ${GENHDRS} $(SRCS) 39516b7db5SJakub Kicinski $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(OUTDIR)/$(PROG) $(LIBS) 401da177e4SLinus Torvalds 41516b7db5SJakub Kicinski$(OUTDIR): 42516b7db5SJakub Kicinski mkdir -p $(OUTDIR) 43516b7db5SJakub Kicinski 44516b7db5SJakub Kicinski$(OUTDIR)/aicdb.h: 451da177e4SLinus Torvalds @if [ -e "/usr/include/db4/db_185.h" ]; then \ 46516b7db5SJakub Kicinski echo "#include <db4/db_185.h>" > $@; \ 471da177e4SLinus Torvalds elif [ -e "/usr/include/db3/db_185.h" ]; then \ 48516b7db5SJakub Kicinski echo "#include <db3/db_185.h>" > $@; \ 491da177e4SLinus Torvalds elif [ -e "/usr/include/db2/db_185.h" ]; then \ 50516b7db5SJakub Kicinski echo "#include <db2/db_185.h>" > $@; \ 511da177e4SLinus Torvalds elif [ -e "/usr/include/db1/db_185.h" ]; then \ 52516b7db5SJakub Kicinski echo "#include <db1/db_185.h>" > $@; \ 531da177e4SLinus Torvalds elif [ -e "/usr/include/db/db_185.h" ]; then \ 54516b7db5SJakub Kicinski echo "#include <db/db_185.h>" > $@; \ 551da177e4SLinus Torvalds elif [ -e "/usr/include/db_185.h" ]; then \ 56516b7db5SJakub Kicinski echo "#include <db_185.h>" > $@; \ 571da177e4SLinus Torvalds else \ 581da177e4SLinus Torvalds echo "*** Install db development libraries"; \ 591da177e4SLinus Torvalds fi 601da177e4SLinus Torvalds 611da177e4SLinus Torvaldsclean: 621da177e4SLinus Torvalds rm -f $(clean-files) 631da177e4SLinus Torvalds 641da177e4SLinus Torvalds# Create a dependency chain in generated files 651da177e4SLinus Torvalds# to avoid concurrent invocations of the single 661da177e4SLinus Torvalds# rule that builds them all. 67516b7db5SJakub Kicinski$(OUTDIR)/aicasm_gram.c: $(OUTDIR)/aicasm_gram.h 68516b7db5SJakub Kicinski$(OUTDIR)/aicasm_gram.c $(OUTDIR)/aicasm_gram.h: aicasm_gram.y 691da177e4SLinus Torvalds $(YACC) $(YFLAGS) -b $(<:.y=) $< 70516b7db5SJakub Kicinski mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c) 71516b7db5SJakub Kicinski mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h) 721da177e4SLinus Torvalds 731da177e4SLinus Torvalds# Create a dependency chain in generated files 741da177e4SLinus Torvalds# to avoid concurrent invocations of the single 751da177e4SLinus Torvalds# rule that builds them all. 76516b7db5SJakub Kicinski$(OUTDIR)/aicasm_macro_gram.c: $(OUTDIR)/aicasm_macro_gram.h 77516b7db5SJakub Kicinski$(OUTDIR)/aicasm_macro_gram.c $(OUTDIR)/aicasm_macro_gram.h: aicasm_macro_gram.y 781da177e4SLinus Torvalds $(YACC) $(YFLAGS) -b $(<:.y=) -p mm $< 79516b7db5SJakub Kicinski mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c) 80516b7db5SJakub Kicinski mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h) 811da177e4SLinus Torvalds 82516b7db5SJakub Kicinski$(OUTDIR)/aicasm_scan.c: aicasm_scan.l 831da177e4SLinus Torvalds $(LEX) $(LFLAGS) -o $@ $< 841da177e4SLinus Torvalds 85516b7db5SJakub Kicinski$(OUTDIR)/aicasm_macro_scan.c: aicasm_macro_scan.l 861da177e4SLinus Torvalds $(LEX) $(LFLAGS) -Pmm -o $@ $< 87