6084aa72a803b4c1e0ee41e5a5fd9d8ad3eea36c
[fw/sdcc] / src / Makefile.in
1 #
2 #
3 #
4
5 srcdir          = @srcdir@
6 top_srcdir      = @top_srcdir@
7 top_builddir    = @top_builddir@
8 VPATH =           @srcdir@
9
10 include $(top_builddir)Makefile.common
11
12 USE_ALT_LEX     = 0
13
14 PORTS           = $(shell cat ../ports.build)
15 ALLPORTS        = $(shell cat ../ports.all)
16 PORT_LIBS       = $(PORTS:%=%/port.a)
17
18 LIBS            = -lm @LIBS@
19
20 #CFLAGS          += -Werror
21 CPPFLAGS        += -I$(srcdir)
22
23 ifdef SDCC_SUB_VERSION
24 CFLAGS          += -DSDCC_SUB_VERSION_STR=\"$(SDCC_SUB_VERSION)\"
25 endif
26
27 SLIBOBJS        = SDCCerr.o NewAlloc.o MySystem.o BuildCmd.o dbuf.o findme.o
28
29 OBJECTS         = SDCCy.o SDCChasht.o SDCCmain.o \
30                   SDCCsymt.o SDCCopt.o SDCCast.o SDCCmem.o SDCCval.o \
31                   SDCCicode.o SDCCbitv.o SDCCset.o SDCClabel.o \
32                   SDCCBBlock.o SDCCloop.o SDCCcse.o SDCCcflow.o SDCCdflow.o \
33                   SDCClrange.o SDCCptropt.o SDCCpeeph.o SDCCglue.o \
34                   asm.o SDCCmacro.o SDCCutil.o SDCCdebug.o cdbFile.o SDCCdwarf2.o
35
36 SPECIAL         = SDCCy.h 
37 ifeq ($(USE_ALT_LEX), 1)
38 OBJECTS         += altlex.o
39 SPECIAL         += reswords.h
40 else
41 OBJECTS         += SDCClex.o
42 endif
43
44 SLIBSOURCES     = $(patsubst %.o,$(SLIB)/%.c,$(SLIBOBJS))
45 SOURCES         = $(patsubst %.o,%.c,$(OBJECTS))
46
47 TARGET          = $(top_builddir)bin/sdcc$(EXEEXT)
48
49 # Compiling entire program or any subproject
50 # ------------------------------------------
51 all: checkconf version.h $(TARGET)
52
53 $(PORT_LIBS): FORCE 
54         $(MAKE) -C $(dir $@)
55
56 FORCE:
57
58 $(top_builddir)support/gc/libgc.a:
59         $(MAKE) -C $(top_builddir)support/gc
60
61 # Compiling and installing everything and runing test
62 # ---------------------------------------------------
63 install: all installdirs
64         $(INSTALL) $(TARGET) `echo $(DESTDIR)$(bindir)/sdcc$(EXEEXT)|sed '$(transform)'`
65         $(STRIP) `echo $(DESTDIR)$(bindir)/sdcc$(EXEEXT)|sed '$(transform)'`
66
67
68 # Deleting all the installed files
69 # --------------------------------
70 uninstall:
71         rm -f $(DESTDIR)$(bindir)/sdcc$(EXEEXT)
72
73 # Performing self-test
74 # --------------------
75 check:
76
77
78 # Performing installation test
79 # ----------------------------
80 installcheck:
81
82
83 # Creating installation directories
84 # ---------------------------------
85 installdirs:
86         $(INSTALL) -d $(DESTDIR)$(bindir)
87
88
89 # Creating dependencies
90 # ---------------------
91 dep: version.h Makefile.dep
92
93 Makefile.dep: version.h $(SOURCES) $(SLIBSOURCES) $(SPECIAL)
94         $(CPP) $(CPPFLAGS) $(M_OR_MM) $(filter %.c,$^) >Makefile.dep
95
96 # don't include Makefile.dep for the listed targets:
97 ifeq "$(findstring $(MAKECMDGOALS),uninstall check installcheck installdirs checkconf \
98                                    clean distclean mostlyclean realclean)" ""
99   include Makefile.dep
100 endif
101 include $(srcdir)/clean.mk
102
103
104 # My rules
105 # --------
106 $(TARGET): $(SLIBOBJS) $(OBJECTS) $(PORT_LIBS)
107         $(CC) $(LDFLAGS) -o $@ $(SLIBOBJS) $(OBJECTS) $(PORT_LIBS) $(LIBDIRS) $(LIBS)
108
109 .c.o:
110         $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
111
112 $(SLIBOBJS):%.o:$(SLIB)/%.c
113         $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
114
115 reswords.h: reswords.gperf Makefile
116         gperf -o -k1,2,4 -t -C -N is_reserved_word $< > $@
117
118 altlex.o: altlex.c SDCCy.h reswords.h
119
120 SDCCy.h: SDCCy.c
121
122 SDCCy.c: SDCC.y
123         $(YACC) -d -v -o $@ $<
124
125 SDCClex.c: SDCC.lex SDCCy.h
126         $(LEX) -t $< >$@
127
128 version.h: ../ChangeLog
129         $(AWK) -f $(srcdir)/version.awk $< > $@
130
131 .y.c:
132         rm -f $*.cc $*.h
133         $(YACC) -d $<
134         mv y.tab.c $*.cc
135         mv y.tab.h $*.h
136
137 .l.c:
138         rm -f $*.cc
139         $(LEX) -t $< >$*.cc
140
141
142 # Remaking configuration
143 # ----------------------
144 checkconf:
145         @if [ -f $(top_builddir)devel ]; then\
146           $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" top_builddir="$(top_builddir)" \
147           freshconf;\
148         fi
149
150 # End of main_in.mk/main.mk