EXEEXT introduces to solve Cygwin problems
[fw/sdcc] / Makefile
1 #
2 #
3 #
4
5 SHELL           = /bin/sh
6
7 PRJDIR          = .
8
9 include $(PRJDIR)/Makefile.common
10
11 SDCC_MISC       = debugger/mcs51 sim/ucsim
12 SDCC_LIBS       = support/cpp2 support/makebin
13 SDCC_DOC        = doc
14
15 # Parts that are not normally compiled but need to be cleaned
16 SDCC_EXTRA      = support/regression
17
18 SDCC_ASLINK     = as/mcs51 as link
19 SDCC_PACKIHX    = packihx
20
21 TARGETS         = sdcc-libs sdcc-cc sdcc-aslink sdcc-doc
22
23 PKGS            = $(SDCC_LIBS) src $(SDCC_ASLINK) $(SDCC_DOC)
24
25 ifneq ($(OPT_ENABLE_UCSIM), no)
26 TARGETS         += sdcc-misc 
27 PKGS            += $(SDCC_MISC)
28 endif
29
30 ifneq ($(OPT_ENABLE_DEVICE_LIB_BUILD), no)
31 TARGETS         += sdcc-device
32 PKGS            += device/include device/lib
33 endif
34
35 ifneq ($(OPT_ENABLE_PACKIHX), no)
36 TARGETS         += sdcc-packihx
37 PKGS            += $(SDCC_PACKIHX)
38 endif
39
40 PKGS_TINI       = $(SDCC_LIBS) $(SDCC_ASLINK) \
41                   src device/include $(SDCC_PACKIHX)
42 PORTS           = $(shell cat ports.build)
43 ALLPORTS        = $(shell cat ports.all)
44
45 # Compiling entire program or any subproject
46 # ------------------------------------------
47 all: checkconf sdcc
48
49 tini: checkconf sdcc-tini
50
51 sdcc-libs:
52         for lib in $(SDCC_LIBS); do $(MAKE) -C $$lib; done
53
54 sdcc-cc: sdcc-libs
55         $(MAKE) -C src
56
57 sdcc-aslink:
58         for as in $(SDCC_ASLINK); do $(MAKE) -C $$as; done
59
60 sdcc-misc:
61         for misc in $(SDCC_MISC); do $(MAKE) -C $$misc; done
62
63 sdcc-packihx:
64         $(MAKE) -C $(SDCC_PACKIHX)
65
66 sdcc-device: sdcc-cc sdcc-aslink
67         $(MAKE) -C device/include
68         $(MAKE) -C device/lib
69
70 sdcc-device-tini:
71         $(MAKE) -C device/include
72         $(MAKE) -C device/lib modelDS390
73
74 # Empty for now, as doc depends on latex and latex2html
75 sdcc-doc:
76
77 sdcc: $(TARGETS)
78
79 sdcc-tini: sdcc-cc sdcc-aslink sdcc-device-tini sdcc-packihx
80         $(MAKE) -f main.mk all
81
82 # Some interesting sub rules
83 sdcc-bin: sdcc-cc sdcc-aslink sdcc-misc
84
85 sdcc-base: sdcc-cc sdcc-aslink
86
87 # Compiling and installing everything and runing test
88 # ---------------------------------------------------
89 install:
90         $(MAKE) -f main.mk install
91         @for pkg in $(PKGS); do\
92           $(MAKE) -C $$pkg install ;\
93         done
94
95 install-tini:
96         $(MAKE) -f main.mk install
97         @for pkg in $(PKGS_TINI); do\
98           $(MAKE) -C $$pkg install ;\
99         done
100         $(MAKE) -C device/lib installDS390
101
102
103
104 # Deleting all the installed files
105 # --------------------------------
106 uninstall:
107         $(MAKE) -f main.mk uninstall
108         @for pkg in $(PKGS); do\
109           $(MAKE) -C $$pkg uninstall ;\
110         done
111
112
113 # Deleting all files created by building the program
114 # --------------------------------------------------
115 clean:
116         @echo "+ Cleaning root of the project..."
117         $(MAKE) -f clean.mk clean
118         @echo "+ Cleaning packages in their directories..."
119         for pkg in $(PKGS); do\
120           $(MAKE) PORTS="$(PORTS)" EXEEXT=$(EXEEXT) -C $$pkg -f clean.mk clean ;\
121         done
122
123 # Deleting all files created by configuring or building the program
124 # -----------------------------------------------------------------
125 distclean:
126         @echo "+ DistCleaning root of the project..."
127         $(MAKE) -f clean.mk distclean
128         @echo "+ DistCleaning packages using clean.mk..."
129         for pkg in $(PKGS); do\
130           $(MAKE) -C $$pkg PORTS="$(PORTS)" EXEEXT=$(EXEEXT) -f clean.mk distclean ;\
131         done
132         for pkg in $(SDCC_EXTRA); do \
133           $(MAKE) -C $$pkg clean; \
134         done
135
136 # Like clean but some files may still exist
137 # -----------------------------------------
138 mostlyclean: clean
139         $(MAKE) -f clean.mk mostlyclean
140         for pkg in $(PKGS); do\
141           $(MAKE) -C $$pkg -f clean.mk PORTS="$(PORTS)" EXEEXT=$(EXEEXT) mostlyclean ;\
142         done
143
144
145 # Deleting everything that can reconstructed by this Makefile. It deletes
146 # everything deleted by distclean plus files created by bison, stc.
147 # -----------------------------------------------------------------------
148 realclean: distclean
149         $(MAKE) -f clean.mk realclean
150         for pkg in $(PKGS); do\
151           $(MAKE) -C $$pkg -f clean.mk PORTS="$(PORTS)" EXEEXT=$(EXEEXT) realclean ;\
152         done
153
154
155 # Creating distribution
156 # ---------------------
157 dist: distclean
158         @if [ -f devel ]; then\
159           rm -f devel; mkdist sdcc; touch devel;\
160         else\
161           mkdist sdcc;\
162         fi
163
164
165 # Performing self-test
166 # --------------------
167 check:
168
169
170 # Performing installation test
171 # ----------------------------
172 installcheck:
173
174
175 # Creating dependencies
176 # ---------------------
177 dep:
178         $(MAKE) -f main.mk dep
179         @for pkg in $(PKGS); do\
180           $(MAKE) -C $$pkg dep ;\
181         done
182
183
184 # My rules
185 # --------
186 newer: distclean
187         @if [ -f start ]; then \
188           tar cvf - \
189             `find . -newer start -type f -print` |\
190           gzip -9c >`date '+%m%d%H%M'`.tgz; \
191         else \
192           echo "start file not found.\n"; \
193           exit 1; \
194         fi
195
196 putcopyright:
197         'put(c)' -s $(STARTYEAR) *.cc *.h *.y *.l
198
199
200 # Remaking configuration
201 # ----------------------
202 configure: configure.in
203         $(SHELL) $(AUTOCONF)
204
205 main.mk: $(srcdir)/main_in.mk $(srcdir)/configure.in config.status
206         $(SHELL) ./config.status
207
208 Makefiles: makefiles
209
210 makefiles: config.status
211
212 config.status: configure
213         $(SHELL) ./config.status --recheck
214
215 makefiles:
216         $(SHELL) ./config.status
217
218 freshconf: main.mk
219
220 checkconf:
221         @if [ -f devel ]; then\
222           $(MAKE) freshconf;\
223         fi
224
225 # End of Makefile