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 _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 assert.c time.c printf_fast.c printf_tiny.c bpx.c \
69 _fsget1arg.c _fsget2args.c _fsnormalize.c \
70 _fsreturnval.c _fsrshift.c _fsswapargs.c \
71 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
72 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
73 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
74 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
76 OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
78 Z80SOURCES = _atof.c _atoi.c \
79 _iscntrl.c _isdigit.c _isgraph.c \
80 _islower.c _isprint.c _ispunct.c _isspace.c \
81 _isupper.c _isxdigit.c \
82 _memcmp.c _memcpy.c _memmove.c _memset.c \
84 _strcat.c _strchr.c _strcmp.c _strcpy.c \
85 _strcspn.c _strlen.c _strncat.c _strncmp.c \
86 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
89 _modslong.c _modulong.c \
91 _divslong.c _divulong.c \
92 calloc.c malloc.c realloc.c free.c \
93 printf_large.c sprintf.c vprintf.c puts.c gets.c \
94 _fs2schar.c _fs2sint.c _fs2slong.c \
95 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
96 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
98 _uchar2fs.c _uint2fs.c \
100 _slong2fs.c _sint2fs.c _schar2fs.c
102 Z80OBJECTS = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
104 XA51SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
105 _divsint.c _divslong.c _divuint.c \
106 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
107 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
108 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
110 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
111 _islower.c _isprint.c _ispunct.c _isspace.c \
112 _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
113 _memcpy.c _memmove.c _memset.c _modsint.c _modslong.c \
114 _moduint.c _modulong.c _mulint.c _mullong.c \
115 _strcat.c _strchr.c _strcmp.c _strcpy.c \
116 _strcspn.c _strlen.c _strncat.c _strncmp.c \
117 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
118 _strstr.c _strtok.c \
119 _uchar2fs.c _uint2fs.c _ulong2fs.c \
120 calloc.c malloc.c realloc.c free.c \
122 printf_large.c puts.c gets.c \
124 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
125 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
126 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
127 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
129 XA51OBJECTS = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
131 HC08SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
132 _divsint.c _divslong.c \
133 _fs2schar.c _fs2sint.c _fs2slong.c \
134 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
135 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
137 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
138 _islower.c _isprint.c _ispunct.c _isspace.c \
139 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
141 _memcmp.c _memcpy.c _memmove.c _memset.c \
142 _modsint.c _modslong.c _moduint.c _modulong.c \
144 _strcat.c _strchr.c _strcmp.c _strcpy.c \
145 _strcspn.c _strlen.c _strncat.c _strncmp.c \
146 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
147 _strstr.c _strtok.c \
148 _uchar2fs.c _uint2fs.c _ulong2fs.c \
149 calloc.c malloc.c realloc.c free.c \
150 printf_large.c sprintf.c vprintf.c \
152 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
153 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
154 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
155 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
157 HC08OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
163 # Compiling entire program or any subproject
164 # ------------------------------------------
165 all: checkconf models model-ds390 model-ds400 model-z80 model-gbz80 model-hc08
169 objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate
172 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
173 for model in $(MODELS); do \
174 $(MAKE) MODELFLAGS="--model-$$model" PORT=$$model objects; \
178 model-mcs51-stack-auto:
179 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
180 for model in $(MODELS); do \
181 $(MAKE) MODELFLAGS="--model-$$model --stack-auto" PORT=$$model-stack-auto objects; \
185 model-mcs51-xstack-auto:
186 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
187 for model in $(MODELS); do \
188 $(MAKE) MODELFLAGS="--model-$$model --stack-auto --xstack" PORT=$$model-xstack-auto objects; \
193 if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
194 $(MAKE) MODELFLAGS="-mds390" PORT=ds390 objects; \
198 if [ "`grep ds400 ../../ports.build`" = ds400 ]; then \
199 $(MAKE) MODELFLAGS="-mds400" PORT=ds400 objects; \
203 if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
204 $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
207 objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
208 cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
211 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
212 $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
216 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
217 $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
220 objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate
221 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
224 if [ "`grep hc08 ../../ports.build`" = hc08 ]; then \
225 $(MAKE) MODELFLAGS="-mhc08" PORT=hc08 objects-hc08; \
228 objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
229 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
232 if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
233 $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
236 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
237 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
240 build-dir: $(PORTDIR)
245 port-specific-objects:
246 if [ -d $(PORT) ]; then \
247 $(MAKE) -C $(PORT); \
248 cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
251 port-specific-objects-pic16:
252 if [ -d $(PORT) ]; then \
253 $(MAKE) -C $(PORT); \
254 cp -f $(PORT)/bin/*.* $(PORTDIR); \
261 rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym
263 clean_intermediate-pic16:
264 $(MAKE) -C $(PORT) clean-intermediate
266 # Compiling and installing everything and runing test
267 # ---------------------------------------------------
268 install: all installdirs
269 cp -r -u $(BUILDDIR)/* $(sdcc_libdir)
270 cp -r -u ds390 ds400 gbz80 z80 hc08 *.c $(sdcc_libdir)/src
271 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'`
273 # Deleting all the installed files
274 # --------------------------------
276 rm -rf $(sdcc_libdir)
278 # Performing self-test
279 # --------------------
283 # Performing installation test
284 # ----------------------------
288 # Creating installation directories
289 # ---------------------------------
291 [ -d $(sdcc_libdir) ] || mkdir -p $(sdcc_libdir)
292 for model in $(MODELS); do \
293 [ -d $(sdcc_libdir)/$$model ] || \
294 mkdir -p $(sdcc_libdir)/$$model; \
296 [ -d $(sdcc_libdir)/ds390 ] || mkdir -p $(sdcc_libdir)/ds390
297 [ -d $(sdcc_libdir)/ds400 ] || mkdir -p $(sdcc_libdir)/ds400
298 [ -d $(sdcc_libdir)/hc08 ] || mkdir -p $(sdcc_libdir)/hc08
299 [ -f $(sdcc_libdir)/pic16 ] || mkdir -p $(sdcc_libdir)/pic16
300 mkdir -p $(sdcc_libdir)/src
302 # Creating dependencies
303 # ---------------------
306 Makefile.dep: $(SOURCES) $(INCDIR)/*.h
308 for i in $(SOURCES); do \
309 $(CPP) -std=c99 -M $(CPPFLAGS) $$i >$${i}.dep; \
310 cat $${i}.dep >>Makefile.dep; \
322 $(PORTDIR)/%$(OEXT): %.c
323 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
325 # Remaking configuration
326 # ----------------------
328 @if [ -f $(PRJDIR)/devel ]; then\
329 $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
333 # End of main_in.mk/main.mk