Makefile (e5451c8f8330e03ad3cfa16048b4daf961af434f) Makefile (516b7db593f3a541e2e98867575c3c697f41a247)
1PROG= aicasm
2
1PROG= aicasm
2
3OUTDIR ?= ./
4
3.SUFFIXES= .l .y .c .h
4
5CSRCS= aicasm.c aicasm_symbol.c
6YSRCS= aicasm_gram.y aicasm_macro_gram.y
7LSRCS= aicasm_scan.l aicasm_macro_scan.l
8
5.SUFFIXES= .l .y .c .h
6
7CSRCS= aicasm.c aicasm_symbol.c
8YSRCS= aicasm_gram.y aicasm_macro_gram.y
9LSRCS= aicasm_scan.l aicasm_macro_scan.l
10
9GENHDRS= aicdb.h $(YSRCS:.y=.h)
10GENSRCS= $(YSRCS:.y=.c) $(LSRCS:.l=.c)
11GENHDRS= $(addprefix ${OUTDIR}/,aicdb.h $(YSRCS:.y=.h))
12GENSRCS= $(addprefix ${OUTDIR}/,$(YSRCS:.y=.c) $(LSRCS:.l=.c))
11
12SRCS= ${CSRCS} ${GENSRCS}
13LIBS= -ldb
14clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
15# Override default kernel CFLAGS. This is a userland app.
13
14SRCS= ${CSRCS} ${GENSRCS}
15LIBS= -ldb
16clean-files:= ${GENSRCS} ${GENHDRS} $(YSRCS:.y=.output) $(PROG)
17# Override default kernel CFLAGS. This is a userland app.
16AICASM_CFLAGS:= -I/usr/include -I.
18AICASM_CFLAGS:= -I/usr/include -I. -I$(OUTDIR)
17LEX= flex
18YACC= bison
19YFLAGS= -d
20
21NOMAN= noman
22
23ifneq ($(HOSTCC),)
24AICASM_CC= $(HOSTCC)
25else
26AICASM_CC= $(CC)
27endif
28
29ifdef DEBUG
30CFLAGS+= -DDEBUG -g
31YFLAGS+= -t -v
32LFLAGS= -d
33endif
34
19LEX= flex
20YACC= bison
21YFLAGS= -d
22
23NOMAN= noman
24
25ifneq ($(HOSTCC),)
26AICASM_CC= $(HOSTCC)
27else
28AICASM_CC= $(CC)
29endif
30
31ifdef DEBUG
32CFLAGS+= -DDEBUG -g
33YFLAGS+= -t -v
34LFLAGS= -d
35endif
36
35$(PROG): ${GENHDRS} $(SRCS)
36 $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(PROG) $(LIBS)
37$(PROG): $(OUTDIR) ${GENHDRS} $(SRCS)
38 $(AICASM_CC) $(AICASM_CFLAGS) $(SRCS) -o $(OUTDIR)/$(PROG) $(LIBS)
37
39
38aicdb.h:
40$(OUTDIR):
41 mkdir -p $(OUTDIR)
42
43$(OUTDIR)/aicdb.h:
39 @if [ -e "/usr/include/db4/db_185.h" ]; then \
44 @if [ -e "/usr/include/db4/db_185.h" ]; then \
40 echo "#include <db4/db_185.h>" > aicdb.h; \
45 echo "#include <db4/db_185.h>" > $@; \
41 elif [ -e "/usr/include/db3/db_185.h" ]; then \
46 elif [ -e "/usr/include/db3/db_185.h" ]; then \
42 echo "#include <db3/db_185.h>" > aicdb.h; \
47 echo "#include <db3/db_185.h>" > $@; \
43 elif [ -e "/usr/include/db2/db_185.h" ]; then \
48 elif [ -e "/usr/include/db2/db_185.h" ]; then \
44 echo "#include <db2/db_185.h>" > aicdb.h; \
49 echo "#include <db2/db_185.h>" > $@; \
45 elif [ -e "/usr/include/db1/db_185.h" ]; then \
50 elif [ -e "/usr/include/db1/db_185.h" ]; then \
46 echo "#include <db1/db_185.h>" > aicdb.h; \
51 echo "#include <db1/db_185.h>" > $@; \
47 elif [ -e "/usr/include/db/db_185.h" ]; then \
52 elif [ -e "/usr/include/db/db_185.h" ]; then \
48 echo "#include <db/db_185.h>" > aicdb.h; \
53 echo "#include <db/db_185.h>" > $@; \
49 elif [ -e "/usr/include/db_185.h" ]; then \
54 elif [ -e "/usr/include/db_185.h" ]; then \
50 echo "#include <db_185.h>" > aicdb.h; \
55 echo "#include <db_185.h>" > $@; \
51 else \
52 echo "*** Install db development libraries"; \
53 fi
54
55clean:
56 rm -f $(clean-files)
57
58# Create a dependency chain in generated files
59# to avoid concurrent invocations of the single
60# rule that builds them all.
56 else \
57 echo "*** Install db development libraries"; \
58 fi
59
60clean:
61 rm -f $(clean-files)
62
63# Create a dependency chain in generated files
64# to avoid concurrent invocations of the single
65# rule that builds them all.
61aicasm_gram.c: aicasm_gram.h
62aicasm_gram.c aicasm_gram.h: aicasm_gram.y
66$(OUTDIR)/aicasm_gram.c: $(OUTDIR)/aicasm_gram.h
67$(OUTDIR)/aicasm_gram.c $(OUTDIR)/aicasm_gram.h: aicasm_gram.y
63 $(YACC) $(YFLAGS) -b $(<:.y=) $<
68 $(YACC) $(YFLAGS) -b $(<:.y=) $<
64 mv $(<:.y=).tab.c $(<:.y=.c)
65 mv $(<:.y=).tab.h $(<:.y=.h)
69 mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c)
70 mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h)
66
67# Create a dependency chain in generated files
68# to avoid concurrent invocations of the single
69# rule that builds them all.
71
72# Create a dependency chain in generated files
73# to avoid concurrent invocations of the single
74# rule that builds them all.
70aicasm_macro_gram.c: aicasm_macro_gram.h
71aicasm_macro_gram.c aicasm_macro_gram.h: aicasm_macro_gram.y
75$(OUTDIR)/aicasm_macro_gram.c: $(OUTDIR)/aicasm_macro_gram.h
76$(OUTDIR)/aicasm_macro_gram.c $(OUTDIR)/aicasm_macro_gram.h: aicasm_macro_gram.y
72 $(YACC) $(YFLAGS) -b $(<:.y=) -p mm $<
77 $(YACC) $(YFLAGS) -b $(<:.y=) -p mm $<
73 mv $(<:.y=).tab.c $(<:.y=.c)
74 mv $(<:.y=).tab.h $(<:.y=.h)
78 mv $(<:.y=).tab.c $(OUTDIR)/$(<:.y=.c)
79 mv $(<:.y=).tab.h $(OUTDIR)/$(<:.y=.h)
75
80
76aicasm_scan.c: aicasm_scan.l
77 $(LEX) $(LFLAGS) -o$@ $<
81$(OUTDIR)/aicasm_scan.c: aicasm_scan.l
82 $(LEX) $(LFLAGS) -o $@ $<
78
83
79aicasm_macro_scan.c: aicasm_macro_scan.l
80 $(LEX) $(LFLAGS) -Pmm -o$@ $<
84$(OUTDIR)/aicasm_macro_scan.c: aicasm_macro_scan.l
85 $(LEX) $(LFLAGS) -Pmm -o $@ $<