ff320931886016891984cef4bfaa1fdfdd411721
[fw/sdcc] / src / Makefile.in
1 #
2 #
3 #
4
5 PRJDIR          = ..
6
7 include $(PRJDIR)/Makefile.common
8
9 USE_ALT_LEX     = 0
10
11 PORTS           = mcs51 z80 avr ds390
12 PORT_LIBS       = $(PORTS:%=%/port.a)
13
14 LIBS            = -lgc -lm @LIBS@
15 ifeq ($(HAVE_LIBGC), 1)
16 else
17 LIBDIRS         = -L$(PRJDIR)/support/gc
18 LIBGC           = $(PRJDIR)/support/gc/libgc.a
19 endif
20
21 #CFLAGS          += -Werror
22
23 ifdef SDCC_SUB_VERSION
24 CFLAGS          += -DSDCC_SUB_VERSION_STR=\"$(SDCC_SUB_VERSION)\"
25 endif
26
27 OBJECTS         = SDCCy.o SDCCerr.o SDCChasht.o SDCCmain.o \
28                   SDCCsymt.o SDCCopt.o SDCCast.o SDCCmem.o SDCCval.o \
29                   SDCCicode.o SDCCbitv.o SDCCset.o SDCClabel.o \
30                   SDCCBBlock.o SDCCloop.o SDCCcse.o SDCCcflow.o SDCCdflow.o \
31                   SDCClrange.o SDCCptropt.o SDCCpeeph.o SDCCglue.o spawn.o \
32                   asm.o
33
34 SPECIAL         = SDCCy.h 
35 ifeq ($(USE_ALT_LEX), 1)
36 OBJECTS         += altlex.o
37 SPECIAL         += reswords.h
38 else
39 OBJECTS         += SDCClex.o
40 endif
41
42 SOURCES         = $(patsubst %.o,%.c,$(OBJECTS))
43
44 TARGET          = $(PRJDIR)/bin/sdcc
45
46 # Compiling entire program or any subproject
47 # ------------------------------------------
48 all: ports checkconf $(LIBGC) $(TARGET)
49
50 ports:
51         for i in $(PORTS); do $(MAKE) -C $$i; done
52
53 $(PRJDIR)/support/gc/libgc.a:
54         cd $(PRJDIR)/support/gc && $(MAKE)
55
56 # Compiling and installing everything and runing test
57 # ---------------------------------------------------
58 install: all installdirs
59         $(INSTALL) -s $(TARGET) $(bindir)/sdcc
60
61
62 # Deleting all the installed files
63 # --------------------------------
64 uninstall:
65         rm -f $(bindir)/sdcc
66         rm -f $(bindir)/packihx
67
68 # Performing self-test
69 # --------------------
70 check:
71
72
73 # Performing installation test
74 # ----------------------------
75 installcheck:
76
77
78 # Creating installation directories
79 # ---------------------------------
80 installdirs:
81         $(INSTALL) -d $(bindir)
82
83
84 # Creating dependencies
85 # ---------------------
86 dep: Makefile.dep
87
88 Makefile.dep: $(SOURCES) $(SPECIAL) *.h $(PRJDIR)/*.h
89         $(CPP) $(CPPFLAGS) $(M_OR_MM) $(SOURCES) >Makefile.dep
90
91 include Makefile.dep
92 include clean.mk
93
94
95 # My rules
96 # --------
97 $(TARGET): $(OBJECTS) $(PORT_LIBS)
98         $(CC) -o $@ $(OBJECTS) $(PORT_LIBS) $(LIBDIRS) $(LIBS)
99
100 .c.o:
101         $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
102
103 reswords.h: reswords.gperf Makefile
104         gperf -o -k1,2,4 -t -C -N is_reserved_word $< > $@
105
106 altlex.o: altlex.c SDCCy.h reswords.h
107
108 SDCCy.h: SDCCy.c
109
110 SDCCy.c: SDCC.y
111         $(YACC) -d -v -o $@ $<
112
113 SDCClex.c: SDCC.lex SDCCy.h
114         $(LEX) -t $< >$@
115
116 .y.c:
117         rm -f $*.cc $*.h
118         $(YACC) -d $<
119         mv y.tab.c $*.cc
120         mv y.tab.h $*.h
121
122 .l.c:
123         rm -f $*.cc
124         $(LEX) -t $< >$*.cc
125
126
127 # Remaking configuration
128 # ----------------------
129 checkconf:
130         @if [ -f $(PRJDIR)/devel ]; then\
131           $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
132           freshconf;\
133         fi
134
135 # End of main_in.mk/main.mk
136