6 VERSIONHI
= @VERSIONHI@
7 VERSIONLO
= @VERSIONLO@
13 AR_S
= @AR@ @AR_S_FLAG@
17 ifeq ($(shell uname
-s
),Linux
)
23 top_builddir
= @top_builddir@
24 top_srcdir
= @top_srcdir@
27 INCDIR
= $(top_srcdir
)/device
/include
29 PORTINCDIR
= $(INCDIR
)/mcs51
32 CC
= $(top_builddir
)/bin
/sdcc
33 CPP
= $(top_builddir
)/bin
/sdcpp
36 exec_prefix = @
exec_prefix@
40 datarootdir
= @datarootdir@
41 includedir = @
includedir@
43 man1dir = $(mandir)/man1
44 man2dir = $(mandir)/man2
47 non_free_lib_dir_suffix
= @non_free_lib_dir_suffix@
49 sdcc_libdir
= $(DESTDIR
)$(datadir)/$(non_free_lib_dir_suffix
)
51 CPPFLAGS
= -I
$(INCDIR
) -I
$(PORTINCDIR
)
52 CFLAGS
= $(MODELFLAGS
) --nostdinc
--std-c99
58 PORTDIR
= $(BUILDDIR
)/$(PORT
)
61 OPT_DISABLE_AVR
= @OPT_DISABLE_AVR@
62 OPT_DISABLE_DS390
= @OPT_DISABLE_DS390@
63 OPT_DISABLE_DS400
= @OPT_DISABLE_DS400@
64 OPT_DISABLE_GBZ80
= @OPT_DISABLE_GBZ80@
65 OPT_DISABLE_HC08
= @OPT_DISABLE_HC08@
66 OPT_DISABLE_MCS51
= @OPT_DISABLE_MCS51@
67 OPT_DISABLE_PIC14
= @OPT_DISABLE_PIC14@
68 OPT_DISABLE_PIC16
= @OPT_DISABLE_PIC16@
69 OPT_DISABLE_XA51
= @OPT_DISABLE_XA51@
70 OPT_DISABLE_Z80
= @OPT_DISABLE_Z80@
72 OBJECTS_FLOAT
= $(SOURCES_FLOAT
:%.c
=$(PORT
)/%.rel
)
73 OBJECTS_INT
= $(SOURCES_INT
:%.c
=$(PORT
)/%.rel
)
74 OBJECTS_LONG
= $(SOURCES_LONG
:%.c
=$(PORT
)/%.rel
)
75 OBJECTS_SDCC
= $(SOURCES_SDCC
:%.c
=$(PORT
)/%.rel
)
77 OBJECTS
= $(OBJECTS_FLOAT
) $(OBJECTS_INT
) $(OBJECTS_LONG
) $(OBJECTS_SDCC
)
79 XA51_FLOAT
= $(COMMON_FLOAT
)
81 XA51_INT
= $(COMMON_INT
) \
88 XA51_LONG
= $(COMMON_LONG
) \
92 XA51_SDCC
= $(COMMON_SDCC
) \
97 XA51SOURCES
= $(XA51_FLOAT
) $(XA51_INT
) $(XA51_LONG
) $(XA51_SDCC
)
98 XA51OBJECTS
= $(XA51SOURCES
:%.c
=$(PORT
)/%.rel
)
100 LIB_FILES
= $(PORTDIR
)/libfloat.lib
$(PORTDIR
)/libint.lib
$(PORTDIR
)/liblong.lib
$(PORTDIR
)/libsdcc.lib
104 include $(srcdir)/incl.mk
106 ifeq ($(OPT_DISABLE_PIC14
), 0)
107 TARGETS
+= model-pic14
110 ifeq ($(OPT_DISABLE_PIC16
), 0)
111 TARGETS
+= model-pic16
114 ENABLED_PORTS
= $(TARGETS
:model-
%=%)
116 # Compiling entire program or any subproject
117 # ------------------------------------------
127 $(MAKE
) port-specific-objects
129 $(MAKE
) clean_intermediate
132 if grep
'^mcs51\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
133 for model in
$(MODELS
); do \
134 $(MAKE
) MODELFLAGS
="--model-$$model" PORT
=$$model PORTINCDIR
=$(INCDIR
)/mcs51 objects
; \
138 small-mcs51-stack-auto
:
139 if grep
'^mcs51\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
140 mkdir
-p small-stack-auto
; cp small
/Makefile small-stack-auto
; \
141 $(MAKE
) MODELFLAGS
="--model-small --stack-auto" PORT
=small-stack-auto PORTDIR
=$(BUILDDIR
)/small-stack-auto PORTINCDIR
=$(INCDIR
)/mcs51 objects
; \
144 model-mcs51-stack-auto
:
145 if grep
'^mcs51\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
146 for model in
$(MODELS
); do \
147 mkdir
-p
$${model}-stack-auto
; cp
$${model}/Makefile
$${model}-stack-auto
; \
148 $(MAKE
) MODELFLAGS
="--model-$$model --stack-auto" PORT
=$${model}-stack-auto PORTDIR
=$(BUILDDIR
)/$${model}-stack-auto PORTINCDIR
=$(INCDIR
)/mcs51 objects
; \
152 model-mcs51-xstack-auto
:
153 if grep
'^mcs51\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
154 for model in
$(MODELS
); do \
155 mkdir
-p
$${model}-xstack-auto
; cp
$${model}/Makefile
$${model}-xstack-auto
; \
156 $(MAKE
) MODELFLAGS
="--model-$$model --stack-auto --xstack" PORT
=$${model}-xstack-auto PORTDIR
=$(BUILDDIR
)/$${model}-xstack-auto PORTINCDIR
=$(INCDIR
)/mcs51 objects
; \
161 if grep
'^ds390\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
162 $(MAKE
) MODELFLAGS
="-mds390" PORT
=ds390 PORTINCDIR
=$(INCDIR
)/mcs51 objects
; \
166 if grep
'^ds400\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
167 $(MAKE
) MODELFLAGS
="-mds400" PORT
=ds400 PORTINCDIR
=$(INCDIR
)/mcs51 objects
; \
171 if grep
'^xa51\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
172 $(MAKE
) MODELFLAGS
="-mxa51" PORT
=xa51 objects-xa51
; \
177 $(MAKE
) $(XA51OBJECTS
)
178 $(MAKE
) port-specific-objects
180 $(PORTDIR
)/lib
$(PORT
).lib
: $(XA51OBJECTS
)
181 ifeq ($(LIB_TYPE
), SDCCLIB
)
182 ..
/..
/bin
/sdcclib
-a
$(PORTDIR
)/lib
$(PORT
).lib
$(XA51OBJECTS
)
184 ifeq ($(LIB_TYPE
), AR
)
185 $(AR_S
) -q
$(PORTDIR
)/lib
$(PORT
).lib
$(XA51OBJECTS
)
187 ifeq ($(LIB_TYPE
), RANLIB
)
188 $(AR_S
) -q
$(PORTDIR
)/lib
$(PORT
).lib
$(XA51OBJECTS
)
189 $(top_builddir
)/bin
/sdranlib
$(PORTDIR
)/lib
$(PORT
).lib
191 rm -f
$(PORTDIR
)/lib
$(PORT
).lib
192 for i in
$(notdir $(basename $(XA51OBJECTS
))); do echo
$$i >> $(PORTDIR
)/lib
$(PORT
).lib
; done
193 cp
$(XA51OBJECTS
) $(PORTDIR
)
199 if grep
'^z80\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
200 $(MAKE
) MODELFLAGS
="-mz80" PORT
=z80 objects-z80 OEXT
=.o
; \
204 if grep
'^z80\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
205 $(MAKE
) MODELFLAGS
="-mgbz80" PORT
=gbz80 objects-z80 OEXT
=.o
; \
210 $(MAKE
) port-specific-objects
211 $(MAKE
) clean_intermediate
214 if grep
'^hc08\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
215 $(MAKE
) MODELFLAGS
="-mhc08" PORT
=hc08 objects-hc08
; \
220 $(MAKE
) port-specific-objects
221 $(MAKE
) clean_intermediate
224 if grep
'^pic16\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
225 $(MAKE
) PORT
=pic16 objects-pic16
; \
230 $(MAKE
) port-specific-objects-pic16
231 $(MAKE
) clean_intermediate-pic16
234 if grep
'^pic14\>' $(top_builddir
)/ports.build
> /dev
/null
; then \
235 $(MAKE
) PORT
=pic14 objects-pic14
; \
240 $(MAKE
) port-specific-objects-pic14
241 $(MAKE
) clean_intermediate-pic14
253 port-specific-objects
:
254 -if
[ -f
$(PORT
)/Makefile
]; then \
255 $(MAKE
) -C
$(PORT
) PORT
=$(PORT
); \
258 port-specific-objects-pic16
:
259 -if
[ -f
$(PORT
)/Makefile
]; then \
260 $(MAKE
) -C
$(PORT
); \
261 for i in
$(PORT
)/*/lib
*.a
; do cp
-f
$$i $(PORTDIR
)/`basename $$i .a`.lib
; done
; \
264 port-specific-objects-pic14
:
265 -if
[ -f
$(PORT
)/Makefile
]; then \
266 mkdir
-p
$(PORT
)/bin
; \
267 $(MAKE
) -C
$(PORT
); \
268 cp
-f
$(PORT
)/bin
/*.
* $(PORTDIR
); \
271 ifeq ($(LIB_TYPE
), SDCCLIB
)
273 $(PORTDIR
)/libfloat.lib
: $(OBJECTS_FLOAT
)
274 ..
/..
/bin
/sdcclib
-a
$(PORTDIR
)/libfloat.lib
$(OBJECTS_FLOAT
)
276 $(PORTDIR
)/libint.lib
: $(OBJECTS_INT
)
277 ..
/..
/bin
/sdcclib
-a
$(PORTDIR
)/libint.lib
$(OBJECTS_INT
)
279 $(PORTDIR
)/liblong.lib
: $(OBJECTS_LONG
)
280 ..
/..
/bin
/sdcclib
-a
$(PORTDIR
)/liblong.lib
$(OBJECTS_LONG
)
282 $(PORTDIR
)/libsdcc.lib
: $(OBJECTS_SDCC
)
283 ..
/..
/bin
/sdcclib
-a
$(PORTDIR
)/libsdcc.lib
$(OBJECTS_SDCC
)
286 ifeq ($(LIB_TYPE
), AR
)
288 $(PORTDIR
)/libfloat.lib
: $(OBJECTS_FLOAT
)
289 $(AR_S
) -cq
$(PORTDIR
)/libfloat.lib
$(OBJECTS_FLOAT
)
291 $(PORTDIR
)/libint.lib
: $(OBJECTS_INT
)
292 $(AR_S
) -cq
$(PORTDIR
)/libint.lib
$(OBJECTS_INT
)
294 $(PORTDIR
)/liblong.lib
: $(OBJECTS_LONG
)
295 $(AR_S
) -cq
$(PORTDIR
)/liblong.lib
$(OBJECTS_LONG
)
297 $(PORTDIR
)/libsdcc.lib
: $(OBJECTS_SDCC
)
298 $(AR_S
) -cq
$(PORTDIR
)/libsdcc.lib
$(OBJECTS_SDCC
)
301 ifeq ($(LIB_TYPE
), RANLIB
)
303 $(PORTDIR
)/libfloat.lib
: $(OBJECTS_FLOAT
)
304 $(AR_S
) -cq
$(PORTDIR
)/libfloat.lib
$(OBJECTS_FLOAT
); $(top_builddir
)/bin
/sdranlib
$(PORTDIR
)/libfloat.lib
306 $(PORTDIR
)/libint.lib
: $(OBJECTS_INT
)
307 $(AR_S
) -cq
$(PORTDIR
)/libint.lib
$(OBJECTS_INT
); $(top_builddir
)/bin
/sdranlib
$(PORTDIR
)/libint.lib
309 $(PORTDIR
)/liblong.lib
: $(OBJECTS_LONG
)
310 $(AR_S
) -cq
$(PORTDIR
)/liblong.lib
$(OBJECTS_LONG
); $(top_builddir
)/bin
/sdranlib
$(PORTDIR
)/liblong.lib
312 $(PORTDIR
)/libsdcc.lib
: $(OBJECTS_SDCC
)
313 $(AR_S
) -cq
$(PORTDIR
)/libsdcc.lib
$(OBJECTS_SDCC
); $(top_builddir
)/bin
/sdranlib
$(PORTDIR
)/libsdcc.lib
317 $(PORTDIR
)/libfloat.lib
: $(OBJECTS_FLOAT
)
318 rm -f
$(PORTDIR
)/libfloat.lib
319 for i in
$(notdir $(basename $(OBJECTS_FLOAT
))); do echo
$$i >> $(PORTDIR
)/libfloat.lib
; done
320 cp
$(OBJECTS_FLOAT
) $(PORTDIR
)
322 $(PORTDIR
)/libint.lib
: $(OBJECTS_INT
)
323 rm -f
$(PORTDIR
)/libint.lib
324 for i in
$(notdir $(basename $(OBJECTS_INT
))); do echo
$$i >> $(PORTDIR
)/libint.lib
; done
325 cp
$(OBJECTS_INT
) $(PORTDIR
)
327 $(PORTDIR
)/liblong.lib
: $(OBJECTS_LONG
)
328 rm -f
$(PORTDIR
)/liblong.lib
329 for i in
$(notdir $(basename $(OBJECTS_LONG
))); do echo
$$i >> $(PORTDIR
)/liblong.lib
; done
330 cp
$(OBJECTS_LONG
) $(PORTDIR
)
332 $(PORTDIR
)/libsdcc.lib
: $(OBJECTS_SDCC
)
333 rm -f
$(PORTDIR
)/libsdcc.lib
334 for i in
$(notdir $(basename $(OBJECTS_SDCC
))); do echo
$$i >> $(PORTDIR
)/libsdcc.lib
; done
335 cp
$(OBJECTS_SDCC
) $(PORTDIR
)
342 rm -f
$(PORTDIR
)/*.lst
$(PORTDIR
)/*.sym
344 clean_intermediate-pic16
:
345 $(MAKE
) -C
$(PORT
) clean-intermediate
347 clean_intermediate-pic14
:
348 $(MAKE
) -C
$(PORT
) clean-intermediate
350 # Compiling and installing everything and runing test
351 # ---------------------------------------------------
353 install: all installdirs
355 [ ! -d
"$(BUILDDIR)" ] ||
$(CP_U
) -r
$(BUILDDIR
)/* $(sdcc_libdir
)
356 $(CP_U
) -r
$(foreach p
, $(ENABLED_PORTS
), $(srcdir)/$(p
)) $(sdcc_libdir
)/src
358 for src in
$(ENABLED_PORTS
); do \
359 find
$(sdcc_libdir
)/src
/$$src -depth \
360 \
( -name
'*.rel' -o
-name
'*.dump*' -o
-name
'*.sym' -o
-name
'*.o' -o
-name
'*.lib' -o \
361 -name
'*.lst' -o
-name
'*.asm' -o
-name
'.svn' -o
-name
'autom4te.cache' -o \
362 -name
'build' -o
-name
'bin' -o
-name
'Makefile*' -o
-name
'config*' -o \
363 -name
'depcomp' -o
-name
'missing' -o
-name
'install-sh' -o \
364 -name
'bootstrap.sh' \
) \
365 -exec
rm -rf
{} + ; \
369 # Deleting all the installed files
370 # --------------------------------
372 rm -rf
$(sdcc_libdir
)
374 # Performing self-test
375 # --------------------
379 # Performing installation test
380 # ----------------------------
384 # Creating installation directories
385 # ---------------------------------
388 for
libdir in
$(ENABLED_PORTS
); do \
389 mkdir
-p
$(sdcc_libdir
)/$$libdir; \
391 mkdir
-p
$(sdcc_libdir
)/src
394 # Creating dependencies
395 # ---------------------
398 Makefile.dep
: $(INCDIR
)/*.h
$(PORTINCDIR
)/*.h
400 for i in
$(filter %.c
,$^
); do \
401 $(CPP
) -std
=c99
-M
$(CPPFLAGS
) $$i >$${i}.dep
; \
402 cat
$${i}.dep
>>Makefile.dep
; \
406 ifeq "$(findstring $(MAKECMDGOALS),uninstall check installcheck installdirs checkconf \
407 clean distclean mostlyclean realclean)" ""
408 -include Makefile.dep
410 include $(srcdir)/clean.mk
417 $(PORT
)/%$(OEXT
): %.c
418 $(CC
) $(CPPFLAGS
) $(CFLAGS
) -c
$< -o
$@
420 # Remaking configuration
421 # ----------------------
423 @if
[ -f
$(top_builddir
)/devel
]; then\
424 $(MAKE
) -f
$(srcdir)/conf.mk
srcdir="$(srcdir)" top_builddir
="$(top_builddir)" \
428 # End of main_in.mk/main.mk