6 VERSIONHI = @VERSIONHI@
7 VERSIONLO = @VERSIONLO@
15 ifeq ($(shell uname -s),Linux)
22 INCDIR = $(PRJDIR)/device/include
24 PORTINCDIR = $(INCDIR)/mcs51
27 CC = $(PRJDIR)/bin/sdcc
28 CPP = $(PRJDIR)/bin/sdcpp
31 exec_prefix = @exec_prefix@
35 includedir = @includedir@
37 man1dir = $(mandir)/man1
38 man2dir = $(mandir)/man2
42 lib_dir_suffix = @lib_dir_suffix@
44 sdcc_libdir = $(DESTDIR)$(datadir)/$(lib_dir_suffix)
46 CPPFLAGS = -I$(INCDIR) -I$(PORTINCDIR)
47 CFLAGS = $(MODELFLAGS) --nostdinc --std-sdcc99
53 PORTDIR = $(BUILDDIR)/$(PORT)
56 SOURCES = _atof.c _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \
57 _decdptr.c _divsint.c _divslong.c _divuint.c \
58 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
59 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
60 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fscmp.c _fsmul.c \
61 _fsneq.c _fssub.c _gptrget.c _gptrgetc.c _gptrput.c \
62 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
63 _islower.c _isprint.c _ispunct.c _isspace.c \
64 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
66 _memcmp.c _memcpy.c _memmove.c _memset.c \
67 _modsint.c _modslong.c _moduint.c _modulong.c \
68 _mulint.c _mullong.c \
72 _strcat.c _strchr.c _strcmp.c _strcpy.c \
73 _strcspn.c _strlen.c _strncat.c _strncmp.c \
74 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
76 _uchar2fs.c _uint2fs.c _ulong2fs.c \
77 calloc.c malloc.c realloc.c free.c \
78 serial.c ser_ir.c printfl.c \
79 printf_large.c sprintf.c vprintf.c puts.c gets.c \
80 printf_fast.c printf_fast_f.c printf_tiny.c \
81 assert.c time.c bpx.c \
82 _fsget1arg.c _fsget2args.c _fsnormalize.c \
83 _fsreturnval.c _fsrshift.c _fsswapargs.c _logexpf.c \
84 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
85 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
86 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
87 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
89 OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
91 Z80SOURCES = _atof.c _atoi.c \
92 _iscntrl.c _isdigit.c _isgraph.c \
93 _islower.c _isprint.c _ispunct.c _isspace.c \
94 _isupper.c _isxdigit.c \
95 _memcmp.c _memcpy.c _memmove.c _memset.c \
97 _strcat.c _strchr.c _strcmp.c _strcpy.c \
98 _strcspn.c _strlen.c _strncat.c _strncmp.c \
99 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
100 _strstr.c _strtok.c \
102 _modslong.c _modulong.c \
105 _divslong.c _divulong.c \
106 calloc.c malloc.c realloc.c free.c \
107 printf_large.c sprintf.c vprintf.c puts.c gets.c \
108 _fs2schar.c _fs2sint.c _fs2slong.c \
109 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
110 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
112 _uchar2fs.c _uint2fs.c \
114 _slong2fs.c _sint2fs.c _schar2fs.c
116 Z80OBJECTS = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
118 XA51SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
119 _divsint.c _divslong.c _divuint.c \
120 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
121 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
122 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
124 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
125 _islower.c _isprint.c _ispunct.c _isspace.c \
126 _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
127 _memcpy.c _memmove.c _memset.c _modsint.c _modslong.c \
128 _moduint.c _modulong.c _mulint.c _mullong.c \
130 _strcat.c _strchr.c _strcmp.c _strcpy.c \
131 _strcspn.c _strlen.c _strncat.c _strncmp.c \
132 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
133 _strstr.c _strtok.c \
134 _uchar2fs.c _uint2fs.c _ulong2fs.c \
135 calloc.c malloc.c realloc.c free.c \
137 printf_large.c puts.c gets.c \
139 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
140 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
141 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
142 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
144 XA51OBJECTS = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
146 HC08SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
147 _divsint.c _divslong.c \
148 _fs2schar.c _fs2sint.c _fs2slong.c \
149 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
150 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
152 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
153 _islower.c _isprint.c _ispunct.c _isspace.c \
154 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
156 _memcmp.c _memcpy.c _memmove.c _memset.c \
157 _modsint.c _modslong.c _moduint.c _modulong.c \
160 _strcat.c _strchr.c _strcmp.c _strcpy.c \
161 _strcspn.c _strlen.c _strncat.c _strncmp.c \
162 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
163 _strstr.c _strtok.c \
164 _uchar2fs.c _uint2fs.c _ulong2fs.c \
165 calloc.c malloc.c realloc.c free.c \
166 printf_large.c sprintf.c vprintf.c \
168 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
169 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
170 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
171 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
173 HC08OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
179 # Compiling entire program or any subproject
180 # ------------------------------------------
181 all: checkconf models small-mcs51-stack-auto model-ds390 model-ds400 model-z80 model-gbz80 model-hc08 model-pic16 model-pic14
183 objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate
186 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
187 for model in $(MODELS); do \
188 $(MAKE) MODELFLAGS="--model-$$model" PORT=$$model PORTINCDIR=$(INCDIR)/mcs51 objects; \
192 small-mcs51-stack-auto:
193 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
194 $(MAKE) MODELFLAGS="--model-small --stack-auto" PORT=small PORTDIR=$(BUILDDIR)/small-stack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
197 model-mcs51-stack-auto:
198 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
199 for model in $(MODELS); do \
200 $(MAKE) MODELFLAGS="--model-$$model --stack-auto" PORT=$$model PORTDIR=$(BUILDDIR)/$$model-stack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
204 model-mcs51-xstack-auto:
205 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
206 for model in $(MODELS); do \
207 $(MAKE) MODELFLAGS="--model-$$model --stack-auto --xstack" PORT=$$model PORTDIR=$(BUILDDIR)/$$model-xstack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
212 if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
213 $(MAKE) MODELFLAGS="-mds390" PORT=ds390 PORTINCDIR=$(INCDIR)/mcs51 objects; \
217 if [ "`grep ds400 ../../ports.build`" = ds400 ]; then \
218 $(MAKE) MODELFLAGS="-mds400" PORT=ds400 PORTINCDIR=$(INCDIR)/mcs51 objects; \
222 if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
223 $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
226 objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
227 cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
230 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
231 $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
235 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
236 $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
239 objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate
240 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
243 if [ "`grep hc08 ../../ports.build`" = hc08 ]; then \
244 $(MAKE) MODELFLAGS="-mhc08" PORT=hc08 objects-hc08; \
247 objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
248 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
251 if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
252 $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
255 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
256 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
258 # yes, we do reuse the *-pic16 rules for pic14
260 if [ "`grep pic ../../ports.build | grep -v pic16`" = pic ]; then \
261 $(MAKE) MODELFLAGS="-mpic14" PORT=pic OEXT=.lib objects-pic16; \
264 build-dir: $(PORTDIR)
269 port-specific-objects:
270 if [ -d $(PORT) ]; then \
271 $(MAKE) -C $(PORT); \
272 cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
275 port-specific-objects-pic16:
276 -if [ -d $(PORT) ]; then \
277 mkdir -p $(PORT)/bin; \
278 $(MAKE) -C $(PORT); \
279 cp -f $(PORT)/bin/*.* $(PORTDIR); \
286 rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym
288 clean_intermediate-pic16:
289 $(MAKE) -C $(PORT) clean-intermediate
291 # Compiling and installing everything and runing test
292 # ---------------------------------------------------
293 install: all installdirs
294 $(CP_U) -r $(BUILDDIR)/* $(sdcc_libdir)
295 $(CP_U) -r $(MODELS) mcs51 ds390 ds400 gbz80 z80 hc08 pic pic16 *.c $(sdcc_libdir)/src
296 for srcdir in $(MODELS) ds390 ds400 gbz80 z80 hc08 pic pic16; do \
297 find $(sdcc_libdir)/src/$$srcdir -depth \
298 \( -name '*.rel' -o -name '*.dump*' -o -name '*.sym' -o -name '*.o' -o -name '*.lib' -o \
299 -name '*.lst' -o -name '*.asm' -o -name 'CVS' -o -name 'build' -o -name 'bin' \) \
300 -exec rm -r {} \; ; \
302 find $(sdcc_libdir)/src/mcs51 -depth \
303 \( -name '*.rel' -o -name '*.dump*' -o -name '*.sym' -o -name '*.o' -o -name '*.lib' -o \
304 -name '*.lst' -o -name 'CVS' -o -name 'build' -o -name 'bin' \) \
307 # Deleting all the installed files
308 # --------------------------------
310 rm -rf $(sdcc_libdir)
312 # Performing self-test
313 # --------------------
317 # Performing installation test
318 # ----------------------------
322 # Creating installation directories
323 # ---------------------------------
325 [ -d $(sdcc_libdir) ] || mkdir -p $(sdcc_libdir)
326 for model in $(MODELS); do \
327 [ -d $(sdcc_libdir)/$$model ] || \
328 mkdir -p $(sdcc_libdir)/$$model; \
330 for libdir in small-stack-auto ds390 ds400 hc08 pic16 pic; do \
331 [ -d $(sdcc_libdir)/$$libdir ] || mkdir -p $(sdcc_libdir)/$$libdir; \
333 mkdir -p $(sdcc_libdir)/src
335 # Creating dependencies
336 # ---------------------
339 Makefile.dep: $(SOURCES) $(INCDIR)/*.h $(PORTINCDIR)/*.h
341 for i in $(SOURCES); do \
342 $(CPP) -std=c99 -M $(CPPFLAGS) $$i >$${i}.dep; \
343 cat $${i}.dep >>Makefile.dep; \
355 $(PORTDIR)/%$(OEXT): %.c
356 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
358 # Remaking configuration
359 # ----------------------
361 @if [ -f $(PRJDIR)/devel ]; then\
362 $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
366 # End of main_in.mk/main.mk