6 VERSIONHI = @VERSIONHI@
7 VERSIONLO = @VERSIONLO@
16 INCDIR = $(PRJDIR)/device/include
18 CC = $(PRJDIR)/bin/sdcc
19 CPP = $(PRJDIR)/bin/sdcpp
22 exec_prefix = @exec_prefix@
26 includedir = @includedir@
28 man1dir = $(mandir)/man1
29 man2dir = $(mandir)/man2
33 lib_dir_suffix = @lib_dir_suffix@
35 sdcc_libdir = $(DESTDIR)$(datadir)/$(lib_dir_suffix)
37 CPPFLAGS = -I$(INCDIR)
38 CFLAGS = $(MODELFLAGS) --nostdinc
43 PORTDIR = $(BUILDDIR)/$(PORT)
45 SOURCES = _atof.c _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \
46 _decdptr.c _divsint.c _divslong.c _divuint.c \
47 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
48 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
49 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fscmp.c _fsmul.c \
50 _fsneq.c _fssub.c _gptrget.c _gptrgetc.c _gptrput.c \
51 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
52 _islower.c _isprint.c _ispunct.c _isspace.c \
53 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
55 _memcmp.c _memcpy.c _memmove.c _memset.c \
56 _modsint.c _modslong.c _moduint.c _modulong.c \
57 _mulint.c _mullong.c \
60 _strcat.c _strchr.c _strcmp.c _strcpy.c \
61 _strcspn.c _strlen.c _strncat.c _strncmp.c \
62 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
64 _uchar2fs.c _uint2fs.c _ulong2fs.c \
65 calloc.c malloc.c realloc.c free.c \
66 serial.c ser_ir.c printfl.c \
67 printf_large.c sprintf.c vprintf.c puts.c gets.c \
68 printf_fast.c printf_fast_f.c printf_tiny.c \
69 assert.c time.c bpx.c \
70 _fsget1arg.c _fsget2args.c _fsnormalize.c \
71 _fsreturnval.c _fsrshift.c _fsswapargs.c \
72 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
73 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
74 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
75 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
77 OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
79 Z80SOURCES = _atof.c _atoi.c \
80 _iscntrl.c _isdigit.c _isgraph.c \
81 _islower.c _isprint.c _ispunct.c _isspace.c \
82 _isupper.c _isxdigit.c \
83 _memcmp.c _memcpy.c _memmove.c _memset.c \
85 _strcat.c _strchr.c _strcmp.c _strcpy.c \
86 _strcspn.c _strlen.c _strncat.c _strncmp.c \
87 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
90 _modslong.c _modulong.c \
92 _divslong.c _divulong.c \
93 calloc.c malloc.c realloc.c free.c \
94 printf_large.c sprintf.c vprintf.c puts.c gets.c \
95 _fs2schar.c _fs2sint.c _fs2slong.c \
96 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
97 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
99 _uchar2fs.c _uint2fs.c \
101 _slong2fs.c _sint2fs.c _schar2fs.c
103 Z80OBJECTS = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
105 XA51SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
106 _divsint.c _divslong.c _divuint.c \
107 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
108 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
109 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
111 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
112 _islower.c _isprint.c _ispunct.c _isspace.c \
113 _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
114 _memcpy.c _memmove.c _memset.c _modsint.c _modslong.c \
115 _moduint.c _modulong.c _mulint.c _mullong.c \
116 _strcat.c _strchr.c _strcmp.c _strcpy.c \
117 _strcspn.c _strlen.c _strncat.c _strncmp.c \
118 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
119 _strstr.c _strtok.c \
120 _uchar2fs.c _uint2fs.c _ulong2fs.c \
121 calloc.c malloc.c realloc.c free.c \
123 printf_large.c puts.c gets.c \
125 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
126 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
127 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
128 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
130 XA51OBJECTS = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
132 HC08SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
133 _divsint.c _divslong.c \
134 _fs2schar.c _fs2sint.c _fs2slong.c \
135 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
136 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
138 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
139 _islower.c _isprint.c _ispunct.c _isspace.c \
140 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
142 _memcmp.c _memcpy.c _memmove.c _memset.c \
143 _modsint.c _modslong.c _moduint.c _modulong.c \
145 _strcat.c _strchr.c _strcmp.c _strcpy.c \
146 _strcspn.c _strlen.c _strncat.c _strncmp.c \
147 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
148 _strstr.c _strtok.c \
149 _uchar2fs.c _uint2fs.c _ulong2fs.c \
150 calloc.c malloc.c realloc.c free.c \
151 printf_large.c sprintf.c vprintf.c \
153 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
154 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
155 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
156 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
158 HC08OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
164 # Compiling entire program or any subproject
165 # ------------------------------------------
166 all: checkconf models model-ds390 model-ds400 model-z80 model-gbz80 model-hc08
170 objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate
173 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
174 for model in $(MODELS); do \
175 $(MAKE) MODELFLAGS="--model-$$model" PORT=$$model objects; \
179 model-mcs51-stack-auto:
180 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
181 for model in $(MODELS); do \
182 $(MAKE) MODELFLAGS="--model-$$model --stack-auto" PORT=$$model-stack-auto objects; \
186 model-mcs51-xstack-auto:
187 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
188 for model in $(MODELS); do \
189 $(MAKE) MODELFLAGS="--model-$$model --stack-auto --xstack" PORT=$$model-xstack-auto objects; \
194 if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
195 $(MAKE) MODELFLAGS="-mds390" PORT=ds390 objects; \
199 if [ "`grep ds400 ../../ports.build`" = ds400 ]; then \
200 $(MAKE) MODELFLAGS="-mds400" PORT=ds400 objects; \
204 if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
205 $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
208 objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
209 cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
212 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
213 $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
217 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
218 $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
221 objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate
222 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
225 if [ "`grep hc08 ../../ports.build`" = hc08 ]; then \
226 $(MAKE) MODELFLAGS="-mhc08" PORT=hc08 objects-hc08; \
229 objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
230 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
233 if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
234 $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
237 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
238 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
241 build-dir: $(PORTDIR)
246 port-specific-objects:
247 if [ -d $(PORT) ]; then \
248 $(MAKE) -C $(PORT); \
249 cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
252 port-specific-objects-pic16:
253 if [ -d $(PORT) ]; then \
254 $(MAKE) -C $(PORT); \
255 cp -f $(PORT)/bin/*.* $(PORTDIR); \
262 rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym
264 clean_intermediate-pic16:
265 $(MAKE) -C $(PORT) clean-intermediate
267 # Compiling and installing everything and runing test
268 # ---------------------------------------------------
269 install: all installdirs
270 cp -r -u $(BUILDDIR)/* $(sdcc_libdir)
271 cp -r -u ds390 ds400 gbz80 z80 hc08 *.c $(sdcc_libdir)/src
272 rm -r `find $(sdcc_libdir)/src -name '*.rel' -or -name '*.dump*' -or -name '*.sym' -or -name '*.o' -or -name '*.lst' -or -name '*.asm' -or -name 'CVS'`
274 # Deleting all the installed files
275 # --------------------------------
277 rm -rf $(sdcc_libdir)
279 # Performing self-test
280 # --------------------
284 # Performing installation test
285 # ----------------------------
289 # Creating installation directories
290 # ---------------------------------
292 [ -d $(sdcc_libdir) ] || mkdir -p $(sdcc_libdir)
293 for model in $(MODELS); do \
294 [ -d $(sdcc_libdir)/$$model ] || \
295 mkdir -p $(sdcc_libdir)/$$model; \
297 [ -d $(sdcc_libdir)/ds390 ] || mkdir -p $(sdcc_libdir)/ds390
298 [ -d $(sdcc_libdir)/ds400 ] || mkdir -p $(sdcc_libdir)/ds400
299 [ -d $(sdcc_libdir)/hc08 ] || mkdir -p $(sdcc_libdir)/hc08
300 [ -f $(sdcc_libdir)/pic16 ] || mkdir -p $(sdcc_libdir)/pic16
301 mkdir -p $(sdcc_libdir)/src
303 # Creating dependencies
304 # ---------------------
307 Makefile.dep: $(SOURCES) $(INCDIR)/*.h
309 for i in $(SOURCES); do \
310 $(CPP) -std=c99 -M $(CPPFLAGS) $$i >$${i}.dep; \
311 cat $${i}.dep >>Makefile.dep; \
323 $(PORTDIR)/%$(OEXT): %.c
324 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
326 # Remaking configuration
327 # ----------------------
329 @if [ -f $(PRJDIR)/devel ]; then\
330 $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
334 # End of main_in.mk/main.mk