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 bpx.c \
69 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
70 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
71 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
72 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
74 OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
76 Z80SOURCES = _atof.c _atoi.c \
77 _iscntrl.c _isdigit.c _isgraph.c \
78 _islower.c _isprint.c _ispunct.c _isspace.c \
79 _isupper.c _isxdigit.c \
80 _memcmp.c _memcpy.c _memmove.c _memset.c \
82 _strcat.c _strchr.c _strcmp.c _strcpy.c \
83 _strcspn.c _strlen.c _strncat.c _strncmp.c \
84 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
87 _modslong.c _modulong.c \
89 _divslong.c _divulong.c \
90 calloc.c malloc.c realloc.c free.c \
91 printf_large.c sprintf.c vprintf.c puts.c gets.c \
92 _fs2schar.c _fs2sint.c _fs2slong.c \
93 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
94 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
96 _uchar2fs.c _uint2fs.c \
98 _slong2fs.c _sint2fs.c _schar2fs.c
100 Z80OBJECTS = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
102 XA51SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
103 _divsint.c _divslong.c _divuint.c \
104 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
105 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
106 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
108 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
109 _islower.c _isprint.c _ispunct.c _isspace.c \
110 _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
111 _memcpy.c _memmove.c _memset.c _modsint.c _modslong.c \
112 _moduint.c _modulong.c _mulint.c _mullong.c \
113 _strcat.c _strchr.c _strcmp.c _strcpy.c \
114 _strcspn.c _strlen.c _strncat.c _strncmp.c \
115 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
116 _strstr.c _strtok.c \
117 _uchar2fs.c _uint2fs.c _ulong2fs.c \
118 calloc.c malloc.c realloc.c free.c \
120 printf_large.c puts.c gets.c \
122 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
123 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
124 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
125 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
127 XA51OBJECTS = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
129 HC08SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
130 _divsint.c _divslong.c \
131 _fs2schar.c _fs2sint.c _fs2slong.c \
132 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
133 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
135 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
136 _islower.c _isprint.c _ispunct.c _isspace.c \
137 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
139 _memcmp.c _memcpy.c _memmove.c _memset.c \
140 _modsint.c _modslong.c _moduint.c _modulong.c \
142 _strcat.c _strchr.c _strcmp.c _strcpy.c \
143 _strcspn.c _strlen.c _strncat.c _strncmp.c \
144 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
145 _strstr.c _strtok.c \
146 _uchar2fs.c _uint2fs.c _ulong2fs.c \
147 calloc.c malloc.c realloc.c free.c \
148 printf_large.c sprintf.c vprintf.c \
150 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
151 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
152 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
153 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
155 HC08OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
161 # Compiling entire program or any subproject
162 # ------------------------------------------
163 all: checkconf models model-ds390 model-ds400 model-z80 model-gbz80 model-hc08
167 objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate
170 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
171 for model in $(MODELS); do \
172 $(MAKE) MODELFLAGS="--model-$$model" PORT=$$model objects; \
176 model-mcs51-stack-auto:
177 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
178 for model in $(MODELS); do \
179 $(MAKE) MODELFLAGS="--model-$$model --stack-auto" PORT=$$model-stack-auto objects; \
183 model-mcs51-xstack-auto:
184 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
185 for model in $(MODELS); do \
186 $(MAKE) MODELFLAGS="--model-$$model --stack-auto --xstack" PORT=$$model-xstack-auto objects; \
191 if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
192 $(MAKE) MODELFLAGS="-mds390" PORT=ds390 objects; \
196 if [ "`grep ds400 ../../ports.build`" = ds400 ]; then \
197 $(MAKE) MODELFLAGS="-mds400" PORT=ds400 objects; \
201 if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
202 $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
205 objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
206 cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
209 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
210 $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
214 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
215 $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
218 objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate
219 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
222 if [ "`grep hc08 ../../ports.build`" = hc08 ]; then \
223 $(MAKE) MODELFLAGS="-mhc08" PORT=hc08 objects-hc08; \
226 objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
227 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
230 if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
231 $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
234 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
235 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
238 build-dir: $(PORTDIR)
243 port-specific-objects:
244 if [ -d $(PORT) ]; then \
245 $(MAKE) -C $(PORT); \
246 cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
249 port-specific-objects-pic16:
250 if [ -d $(PORT) ]; then \
251 $(MAKE) -C $(PORT); \
252 cp -f $(PORT)/bin/*.* $(PORTDIR); \
259 rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym
261 clean_intermediate-pic16:
262 $(MAKE) -C $(PORT) clean-intermediate
264 # Compiling and installing everything and runing test
265 # ---------------------------------------------------
266 install: all installdirs
267 cp -r -u $(BUILDDIR)/* $(sdcc_libdir)
268 cp -r -u ds390 ds400 gbz80 z80 hc08 *.c $(sdcc_libdir)/src
269 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'`
271 # Deleting all the installed files
272 # --------------------------------
274 rm -rf $(sdcc_libdir)
276 # Performing self-test
277 # --------------------
281 # Performing installation test
282 # ----------------------------
286 # Creating installation directories
287 # ---------------------------------
289 [ -d $(sdcc_libdir) ] || mkdir -p $(sdcc_libdir)
290 for model in $(MODELS); do \
291 [ -d $(sdcc_libdir)/$$model ] || \
292 mkdir -p $(sdcc_libdir)/$$model; \
294 [ -d $(sdcc_libdir)/ds390 ] || mkdir -p $(sdcc_libdir)/ds390
295 [ -d $(sdcc_libdir)/ds400 ] || mkdir -p $(sdcc_libdir)/ds400
296 [ -d $(sdcc_libdir)/hc08 ] || mkdir -p $(sdcc_libdir)/hc08
297 [ -f $(sdcc_libdir)/pic16 ] || mkdir -p $(sdcc_libdir)/pic16
298 mkdir -p $(sdcc_libdir)/src
300 # Creating dependencies
301 # ---------------------
304 Makefile.dep: $(SOURCES) $(INCDIR)/*.h
306 for i in $(SOURCES); do \
307 $(CPP) -std=c99 -M $(CPPFLAGS) $$i >$${i}.dep; \
308 cat $${i}.dep >>Makefile.dep; \
320 $(PORTDIR)/%$(OEXT): %.c
321 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
323 # Remaking configuration
324 # ----------------------
326 @if [ -f $(PRJDIR)/devel ]; then\
327 $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
331 # End of main_in.mk/main.mk