6 VERSIONHI = @VERSIONHI@
7 VERSIONLO = @VERSIONLO@
16 INCDIR = $(PRJDIR)/device/include
18 PORTINCDIR = $(INCDIR)/mcs51
21 CC = $(PRJDIR)/bin/sdcc
22 CPP = $(PRJDIR)/bin/sdcpp
25 exec_prefix = @exec_prefix@
29 includedir = @includedir@
31 man1dir = $(mandir)/man1
32 man2dir = $(mandir)/man2
36 lib_dir_suffix = @lib_dir_suffix@
38 sdcc_libdir = $(DESTDIR)$(datadir)/$(lib_dir_suffix)
40 CPPFLAGS = -I$(INCDIR) -I$(PORTINCDIR)
41 CFLAGS = $(MODELFLAGS) --nostdinc
46 PORTDIR = $(BUILDDIR)/$(PORT)
48 SOURCES = _atof.c _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \
49 _decdptr.c _divsint.c _divslong.c _divuint.c \
50 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
51 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
52 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fscmp.c _fsmul.c \
53 _fsneq.c _fssub.c _gptrget.c _gptrgetc.c _gptrput.c \
54 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
55 _islower.c _isprint.c _ispunct.c _isspace.c \
56 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
58 _memcmp.c _memcpy.c _memmove.c _memset.c \
59 _modsint.c _modslong.c _moduint.c _modulong.c \
60 _mulint.c _mullong.c \
64 _strcat.c _strchr.c _strcmp.c _strcpy.c \
65 _strcspn.c _strlen.c _strncat.c _strncmp.c \
66 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
68 _uchar2fs.c _uint2fs.c _ulong2fs.c \
69 calloc.c malloc.c realloc.c free.c \
70 serial.c ser_ir.c printfl.c \
71 printf_large.c sprintf.c vprintf.c puts.c gets.c \
72 printf_fast.c printf_fast_f.c printf_tiny.c \
73 assert.c time.c bpx.c \
74 _fsget1arg.c _fsget2args.c _fsnormalize.c \
75 _fsreturnval.c _fsrshift.c _fsswapargs.c _logexpf.c \
76 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
77 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
78 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
79 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
81 OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
83 Z80SOURCES = _atof.c _atoi.c \
84 _iscntrl.c _isdigit.c _isgraph.c \
85 _islower.c _isprint.c _ispunct.c _isspace.c \
86 _isupper.c _isxdigit.c \
87 _memcmp.c _memcpy.c _memmove.c _memset.c \
89 _strcat.c _strchr.c _strcmp.c _strcpy.c \
90 _strcspn.c _strlen.c _strncat.c _strncmp.c \
91 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
94 _modslong.c _modulong.c \
97 _divslong.c _divulong.c \
98 calloc.c malloc.c realloc.c free.c \
99 printf_large.c sprintf.c vprintf.c puts.c gets.c \
100 _fs2schar.c _fs2sint.c _fs2slong.c \
101 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
102 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
104 _uchar2fs.c _uint2fs.c \
106 _slong2fs.c _sint2fs.c _schar2fs.c
108 Z80OBJECTS = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
110 XA51SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
111 _divsint.c _divslong.c _divuint.c \
112 _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
113 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
114 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
116 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
117 _islower.c _isprint.c _ispunct.c _isspace.c \
118 _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
119 _memcpy.c _memmove.c _memset.c _modsint.c _modslong.c \
120 _moduint.c _modulong.c _mulint.c _mullong.c \
122 _strcat.c _strchr.c _strcmp.c _strcpy.c \
123 _strcspn.c _strlen.c _strncat.c _strncmp.c \
124 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
125 _strstr.c _strtok.c \
126 _uchar2fs.c _uint2fs.c _ulong2fs.c \
127 calloc.c malloc.c realloc.c free.c \
129 printf_large.c puts.c gets.c \
131 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
132 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
133 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
134 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
136 XA51OBJECTS = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
138 HC08SOURCES = _atof.c _atoi.c _atol.c _schar2fs.c \
139 _divsint.c _divslong.c \
140 _fs2schar.c _fs2sint.c _fs2slong.c \
141 _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
142 _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
144 _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
145 _islower.c _isprint.c _ispunct.c _isspace.c \
146 _isupper.c _isxdigit.c _itoa.c _ltoa.c \
148 _memcmp.c _memcpy.c _memmove.c _memset.c \
149 _modsint.c _modslong.c _moduint.c _modulong.c \
152 _strcat.c _strchr.c _strcmp.c _strcpy.c \
153 _strcspn.c _strlen.c _strncat.c _strncmp.c \
154 _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
155 _strstr.c _strtok.c \
156 _uchar2fs.c _uint2fs.c _ulong2fs.c \
157 calloc.c malloc.c realloc.c free.c \
158 printf_large.c sprintf.c vprintf.c \
160 fabsf.c frexpf.c ldexpf.c expf.c powf.c sincosf.c sinf.c \
161 cosf.c logf.c log10f.c sqrtf.c tancotf.c tanf.c cotf.c \
162 asincosf.c asinf.c acosf.c atanf.c atan2f.c sincoshf.c \
163 sinhf.c coshf.c tanhf.c floorf.c ceilf.c modff.c errno.c
165 HC08OBJECTS = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
171 # Compiling entire program or any subproject
172 # ------------------------------------------
173 all: checkconf models model-ds390 model-ds400 model-z80 model-gbz80 model-hc08 model-pic16
175 objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate
178 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
179 for model in $(MODELS); do \
180 $(MAKE) MODELFLAGS="--model-$$model" PORT=$$model PORTINCDIR=$(INCDIR)/mcs51 objects; \
184 model-mcs51-stack-auto:
185 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
186 for model in $(MODELS); do \
187 $(MAKE) MODELFLAGS="--model-$$model --stack-auto" PORT=$$model-stack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
191 model-mcs51-xstack-auto:
192 if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
193 for model in $(MODELS); do \
194 $(MAKE) MODELFLAGS="--model-$$model --stack-auto --xstack" PORT=$$model-xstack-auto PORTINCDIR=$(INCDIR)/mcs51 objects; \
199 if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
200 $(MAKE) MODELFLAGS="-mds390" PORT=ds390 PORTINCDIR=$(INCDIR)/mcs51 objects; \
204 if [ "`grep ds400 ../../ports.build`" = ds400 ]; then \
205 $(MAKE) MODELFLAGS="-mds400" PORT=ds400 PORTINCDIR=$(INCDIR)/mcs51 objects; \
209 if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
210 $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
213 objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
214 cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
217 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
218 $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
222 if [ "`grep z80 ../../ports.build`" = z80 ]; then \
223 $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
226 objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate
227 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
230 if [ "`grep hc08 ../../ports.build`" = hc08 ]; then \
231 $(MAKE) MODELFLAGS="-mhc08" PORT=hc08 objects-hc08; \
234 objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
235 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
238 if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
239 $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
242 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
243 cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
246 build-dir: $(PORTDIR)
251 port-specific-objects:
252 if [ -d $(PORT) ]; then \
253 $(MAKE) -C $(PORT); \
254 cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
257 port-specific-objects-pic16:
258 if [ -d $(PORT) ]; then \
259 mkdir -p $(PORT)/bin; \
260 $(MAKE) -C $(PORT); \
261 cp -f $(PORT)/bin/* $(PORTDIR); \
268 rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym
270 clean_intermediate-pic16:
271 $(MAKE) -C $(PORT) clean-intermediate
273 # Compiling and installing everything and runing test
274 # ---------------------------------------------------
275 install: all installdirs
276 cp -r -u $(BUILDDIR)/* $(sdcc_libdir)
277 cp -r -u ds390 ds400 gbz80 z80 hc08 *.c $(sdcc_libdir)/src
278 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'`
280 # Deleting all the installed files
281 # --------------------------------
283 rm -rf $(sdcc_libdir)
285 # Performing self-test
286 # --------------------
290 # Performing installation test
291 # ----------------------------
295 # Creating installation directories
296 # ---------------------------------
298 [ -d $(sdcc_libdir) ] || mkdir -p $(sdcc_libdir)
299 for model in $(MODELS); do \
300 [ -d $(sdcc_libdir)/$$model ] || \
301 mkdir -p $(sdcc_libdir)/$$model; \
303 [ -d $(sdcc_libdir)/ds390 ] || mkdir -p $(sdcc_libdir)/ds390
304 [ -d $(sdcc_libdir)/ds400 ] || mkdir -p $(sdcc_libdir)/ds400
305 [ -d $(sdcc_libdir)/hc08 ] || mkdir -p $(sdcc_libdir)/hc08
306 [ -d $(sdcc_libdir)/pic16 ] || mkdir -p $(sdcc_libdir)/pic16
307 mkdir -p $(sdcc_libdir)/src
309 # Creating dependencies
310 # ---------------------
313 Makefile.dep: $(SOURCES) $(INCDIR)/*.h $(PORTINCDIR)/*.h
315 for i in $(SOURCES); do \
316 $(CPP) -std=c99 -M $(CPPFLAGS) $$i >$${i}.dep; \
317 cat $${i}.dep >>Makefile.dep; \
329 $(PORTDIR)/%$(OEXT): %.c
330 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
332 # Remaking configuration
333 # ----------------------
335 @if [ -f $(PRJDIR)/devel ]; then\
336 $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
340 # End of main_in.mk/main.mk