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
52 PORTDIR = $(BUILDDIR)/$(PORT)
54 SOURCES = _atof.c _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \
55 _decdptr.c _divsint.c _divslong.c _divuint.c \
56 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
57 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
58 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fscmp.c _fsmul.c \
59 _fsneq.c _fssub.c _gptrget.c _gptrgetc.c _gptrput.c \
60 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
61 _islower.c _isprint.c _ispunct.c _isspace.c \
62 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
64 _memcmp.c _memcpy.c _memmove.c _memset.c \
65 _modsint.c _modslong.c _moduint.c _modulong.c \
66 _mulint.c _mullong.c \
70 _strcat.c _strchr.c _strcmp.c _strcpy.c \
71 _strcspn.c _strlen.c _strncat.c _strncmp.c \
72 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
74 _uchar2fs.c _uint2fs.c _ulong2fs.c \
75 calloc.c malloc.c realloc.c free.c \
76 serial.c ser_ir.c printfl.c \
77 printf_large.c sprintf.c vprintf.c puts.c gets.c \
78 printf_fast.c printf_fast_f.c printf_tiny.c \
79 assert.c time.c bpx.c \
80 _fsget1arg.c _fsget2args.c _fsnormalize.c \
81 _fsreturnval.c _fsrshift.c _fsswapargs.c _logexpf.c \
82 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
83 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
84 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
85 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
87 OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
89 Z80SOURCES = _atof.c _atoi.c \
90 _iscntrl.c _isdigit.c _isgraph.c \
91 _islower.c _isprint.c _ispunct.c _isspace.c \
92 _isupper.c _isxdigit.c \
93 _memcmp.c _memcpy.c _memmove.c _memset.c \
95 _strcat.c _strchr.c _strcmp.c _strcpy.c \
96 _strcspn.c _strlen.c _strncat.c _strncmp.c \
97 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
100 _modslong.c _modulong.c \
103 _divslong.c _divulong.c \
104 calloc.c malloc.c realloc.c free.c \
105 printf_large.c sprintf.c vprintf.c puts.c gets.c \
106 _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 _uchar2fs.c _uint2fs.c \
112 _slong2fs.c _sint2fs.c _schar2fs.c
114 Z80OBJECTS = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
116 XA51SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
117 _divsint.c _divslong.c _divuint.c \
118 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
119 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
120 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
122 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
123 _islower.c _isprint.c _ispunct.c _isspace.c \
124 _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
125 _memcpy.c _memmove.c _memset.c _modsint.c _modslong.c \
126 _moduint.c _modulong.c _mulint.c _mullong.c \
128 _strcat.c _strchr.c _strcmp.c _strcpy.c \
129 _strcspn.c _strlen.c _strncat.c _strncmp.c \
130 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
131 _strstr.c _strtok.c \
132 _uchar2fs.c _uint2fs.c _ulong2fs.c \
133 calloc.c malloc.c realloc.c free.c \
135 printf_large.c puts.c gets.c \
137 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
138 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
139 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
140 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
142 XA51OBJECTS = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
144 HC08SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
145 _divsint.c _divslong.c \
146 _fs2schar.c _fs2sint.c _fs2slong.c \
147 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
148 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
150 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
151 _islower.c _isprint.c _ispunct.c _isspace.c \
152 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
154 _memcmp.c _memcpy.c _memmove.c _memset.c \
155 _modsint.c _modslong.c _moduint.c _modulong.c \
158 _strcat.c _strchr.c _strcmp.c _strcpy.c \
159 _strcspn.c _strlen.c _strncat.c _strncmp.c \
160 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
161 _strstr.c _strtok.c \
162 _uchar2fs.c _uint2fs.c _ulong2fs.c \
163 calloc.c malloc.c realloc.c free.c \
164 printf_large.c sprintf.c vprintf.c \
166 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
167 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
168 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
169 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
171 HC08OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
177 # Compiling entire program or any subproject
178 # ------------------------------------------
179 all: checkconf models model-ds390 model-ds400 model-z80 model-gbz80 model-hc08 model-pic16 model-pic14
181 objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate
184 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
185 for model in $(MODELS); do \
186 $(MAKE) MODELFLAGS="--model-$$model" PORT=$$model PORTINCDIR=$(INCDIR)/mcs51 objects; \
190 model-mcs51-stack-auto:
191 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
192 for model in $(MODELS); do \
193 $(MAKE) MODELFLAGS="--model-$$model --stack-auto" PORT=$$model-stack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
197 model-mcs51-xstack-auto:
198 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
199 for model in $(MODELS); do \
200 $(MAKE) MODELFLAGS="--model-$$model --stack-auto --xstack" PORT=$$model-xstack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
205 if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
206 $(MAKE) MODELFLAGS="-mds390" PORT=ds390 PORTINCDIR=$(INCDIR)/mcs51 objects; \
210 if [ "`grep ds400 ../../ports.build`" = ds400 ]; then \
211 $(MAKE) MODELFLAGS="-mds400" PORT=ds400 PORTINCDIR=$(INCDIR)/mcs51 objects; \
215 if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
216 $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
219 objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
220 cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
223 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
224 $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
228 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
229 $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
232 objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate
233 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
236 if [ "`grep hc08 ../../ports.build`" = hc08 ]; then \
237 $(MAKE) MODELFLAGS="-mhc08" PORT=hc08 objects-hc08; \
240 objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
241 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
244 if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
245 $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
248 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
249 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
251 # yes, we do reuse the objects-pic16 for pic14
253 if [ "`grep pic ../../ports.build | grep -v pic16`" = pic ]; then \
254 $(MAKE) MODELFLAGS="-mpic14" PORT=pic OEXT=.lib objects-pic16; \
257 build-dir: $(PORTDIR)
262 port-specific-objects:
263 if [ -d $(PORT) ]; then \
264 $(MAKE) -C $(PORT); \
265 cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
268 port-specific-objects-pic16:
269 -if [ -d $(PORT) ]; then \
270 mkdir -p $(PORT)/bin; \
271 $(MAKE) -C $(PORT); \
272 cp -f $(PORT)/bin/*.* $(PORTDIR); \
279 rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym
281 clean_intermediate-pic16:
282 $(MAKE) -C $(PORT) clean-intermediate
284 # Compiling and installing everything and runing test
285 # ---------------------------------------------------
286 install: all installdirs
287 $(CP_U) -r $(BUILDDIR)/* $(sdcc_libdir)
288 $(CP_U) -r ds390 ds400 gbz80 z80 hc08 *.c $(sdcc_libdir)/src
289 rm -r `find $(sdcc_libdir)/src -name '*.rel' -o -name '*.dump*' -o -name '*.sym' -o -name '*.o' -o -name '*.lst' -o -name '*.asm' -o -name 'CVS'`
291 # Deleting all the installed files
292 # --------------------------------
294 rm -rf $(sdcc_libdir)
296 # Performing self-test
297 # --------------------
301 # Performing installation test
302 # ----------------------------
306 # Creating installation directories
307 # ---------------------------------
309 [ -d $(sdcc_libdir) ] || mkdir -p $(sdcc_libdir)
310 for model in $(MODELS); do \
311 [ -d $(sdcc_libdir)/$$model ] || \
312 mkdir -p $(sdcc_libdir)/$$model; \
314 [ -d $(sdcc_libdir)/ds390 ] || mkdir -p $(sdcc_libdir)/ds390
315 [ -d $(sdcc_libdir)/ds400 ] || mkdir -p $(sdcc_libdir)/ds400
316 [ -d $(sdcc_libdir)/hc08 ] || mkdir -p $(sdcc_libdir)/hc08
317 [ -d $(sdcc_libdir)/pic16 ] || mkdir -p $(sdcc_libdir)/pic16
318 mkdir -p $(sdcc_libdir)/src
320 # Creating dependencies
321 # ---------------------
324 Makefile.dep: $(SOURCES) $(INCDIR)/*.h $(PORTINCDIR)/*.h
326 for i in $(SOURCES); do \
327 $(CPP) -std=c99 -M $(CPPFLAGS) $$i >$${i}.dep; \
328 cat $${i}.dep >>Makefile.dep; \
340 $(PORTDIR)/%$(OEXT): %.c
341 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
343 # Remaking configuration
344 # ----------------------
346 @if [ -f $(PRJDIR)/devel ]; then\
347 $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
351 # End of main_in.mk/main.mk