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