Makefile 2.04 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2
PROG=	aicasm

3
.SUFFIXES= .l .y .c .h
Linus Torvalds's avatar
Linus Torvalds committed
4

Linus Torvalds's avatar
Linus Torvalds committed
5
CSRCS=	aicasm.c aicasm_symbol.c
6 7
YSRCS=	aicasm_gram.y aicasm_macro_gram.y
LSRCS=	aicasm_scan.l aicasm_macro_scan.l
8

9 10
GENHDRS=	aicdb.h $(YSRCS:.y=.h)
GENSRCS=	$(YSRCS:.y=.c) $(LSRCS:.l=.c)
Linus Torvalds's avatar
Linus Torvalds committed
11

12
SRCS=	${CSRCS} ${GENSRCS}
Alan Cox's avatar
Alan Cox committed
13
LIBS=	-ldb
14
clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
Linus Torvalds's avatar
Linus Torvalds committed
15
# Override default kernel CFLAGS.  This is a userland app.
Alan Cox's avatar
Alan Cox committed
16
AICASM_CFLAGS:= -I/usr/include -I.
Linus Torvalds's avatar
Linus Torvalds committed
17 18 19 20
YFLAGS= -d

NOMAN=	noman

Linus Torvalds's avatar
Linus Torvalds committed
21 22 23 24 25 26
ifneq ($(HOSTCC),)
AICASM_CC= $(HOSTCC)
else
AICASM_CC= $(CC)
endif

Linus Torvalds's avatar
Linus Torvalds committed
27 28 29 30 31 32
ifdef DEBUG
CFLAGS+= -DDEBUG -g
YFLAGS+= -t -v
LFLAGS= -d
endif

33
$(PROG):  ${GENHDRS} $(SRCS)
Alan Cox's avatar
Alan Cox committed
34
	$(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(PROG) $(LIBS)
Linus Torvalds's avatar
Linus Torvalds committed
35 36

aicdb.h:
37 38 39
	@if [ -e "/usr/include/db4/db_185.h" ]; then		\
		echo "#include <db4/db_185.h>" > aicdb.h;	\
	 elif [ -e "/usr/include/db3/db_185.h" ]; then		\
Linus Torvalds's avatar
Linus Torvalds committed
40 41 42
		echo "#include <db3/db_185.h>" > aicdb.h;	\
	 elif [ -e "/usr/include/db2/db_185.h" ]; then		\
		echo "#include <db2/db_185.h>" > aicdb.h;	\
43 44
	 elif [ -e "/usr/include/db1/db_185.h" ]; then		\
		echo "#include <db1/db_185.h>" > aicdb.h;	\
Linus Torvalds's avatar
Linus Torvalds committed
45 46 47 48 49 50 51
	 elif [ -e "/usr/include/db/db_185.h" ]; then		\
		echo "#include <db/db_185.h>" > aicdb.h;	\
	 elif [ -e "/usr/include/db_185.h" ]; then		\
		echo "#include <db_185.h>" > aicdb.h;		\
	 else							\
		echo "*** Install db development libraries";	\
	 fi
Linus Torvalds's avatar
Linus Torvalds committed
52

53
clean:
Alan Cox's avatar
Alan Cox committed
54
	rm -f $(clean-files)
55

James Bottomley's avatar
James Bottomley committed
56 57 58 59
# Create a dependency chain in generated files
# to avoid concurrent invocations of the single
# rule that builds them all.
aicasm_gram.c: aicasm_gram.h
60 61 62 63 64
aicasm_gram.c aicasm_gram.h: aicasm_gram.y
	$(YACC) $(YFLAGS) -b $(<:.y=) $<
	mv $(<:.y=).tab.c $(<:.y=.c)
	mv $(<:.y=).tab.h $(<:.y=.h)

James Bottomley's avatar
James Bottomley committed
65 66 67 68
# Create a dependency chain in generated files
# to avoid concurrent invocations of the single
# rule that builds them all.
aicasm_macro_gram.c: aicasm_macro_gram.h
69 70 71 72 73 74 75
aicasm_macro_gram.c aicasm_macro_gram.h: aicasm_macro_gram.y
	$(YACC) $(YFLAGS) -b $(<:.y=) -p mm $<
	mv $(<:.y=).tab.c $(<:.y=.c)
	mv $(<:.y=).tab.h $(<:.y=.h)

aicasm_scan.c: aicasm_scan.l
	$(LEX) $(LFLAGS) -o$@ $<
Linus Torvalds's avatar
Linus Torvalds committed
76

77 78
aicasm_macro_scan.c: aicasm_macro_scan.l
	$(LEX) $(LFLAGS) -Pmm -o$@ $<