* .version: bumped version to 2.5.6 (pic14 ABI changed)
[fw/sdcc] / device / lib / Makefile.in
1 #
2 #
3 #
4
5 VERSION         = @VERSION@
6 VERSIONHI       = @VERSIONHI@
7 VERSIONLO       = @VERSIONLO@
8 VERSIONP        = @VERSIONP@
9
10 SHELL           = /bin/sh
11 CPP             = @CPP@
12 INSTALL         = @INSTALL@
13 CP              = @CP@
14
15 ifeq ($(shell uname -s),Linux)
16 CP_U    = $(CP) -u
17 else
18 CP_U    = $(CP)
19 endif
20
21 PRJDIR          = ../..
22 INCDIR          = $(PRJDIR)/device/include
23 ifndef PORTINCDIR
24 PORTINCDIR      = $(INCDIR)/mcs51
25 endif
26
27 CC              = $(PRJDIR)/bin/sdcc
28 CPP             = $(PRJDIR)/bin/sdcpp
29
30 prefix          = @prefix@
31 exec_prefix     = @exec_prefix@
32 bindir          = @bindir@
33 libdir          = @libdir@
34 datadir         = @datadir@
35 includedir      = @includedir@
36 mandir          = @mandir@
37 man1dir         = $(mandir)/man1
38 man2dir         = $(mandir)/man2
39 infodir         = @infodir@
40 srcdir          = @srcdir@
41
42 lib_dir_suffix  = @lib_dir_suffix@
43
44 sdcc_libdir     = $(DESTDIR)$(datadir)/$(lib_dir_suffix)
45
46 CPPFLAGS        = -I$(INCDIR) -I$(PORTINCDIR)
47 CFLAGS          = $(MODELFLAGS) --nostdinc --std-sdcc99
48
49 BUILDDIR        = build
50 # Default
51 PORT            = z80
52 ifndef PORTDIR
53 PORTDIR         = $(BUILDDIR)/$(PORT)
54 endif
55
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 \
65                   _slong2fs.c \
66                   _memcmp.c _memcpy.c _memmove.c _memset.c \
67                   _modsint.c _modslong.c _moduint.c _modulong.c \
68                   _mulint.c _mullong.c \
69                   abs.c labs.c \
70                   _ser.c _setjmp.c \
71                   _spx.c _startup.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 \
75                   _strstr.c _strtok.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
88
89 OBJECTS         = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
90
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 \
96                   _startup.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 \
101                   assert.c \
102                   _modslong.c _modulong.c \
103                   _mullong.c \
104                   abs.c labs.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 \
111                   _fsneq.c _fssub.c \
112                   _uchar2fs.c _uint2fs.c \
113                   _ulong2fs.c \
114                   _slong2fs.c _sint2fs.c _schar2fs.c
115
116 Z80OBJECTS      = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
117
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 \
123                   _fsneq.c _fssub.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 \
129                   abs.c labs.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 \
136                   puts.c gets.c \
137                   printf_large.c puts.c gets.c \
138                   assert.c time.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
143
144 XA51OBJECTS      = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
145
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 \
151                   _fsneq.c _fssub.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 \
155                   _slong2fs.c \
156                   _memcmp.c _memcpy.c _memmove.c _memset.c \
157                   _modsint.c _modslong.c _moduint.c _modulong.c \
158                   abs.c labs.c \
159                   _spx.c _startup.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 \
167                   assert.c time.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
172
173 HC08OBJECTS     = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
174
175 OEXT            = .rel
176
177 include incl.mk
178
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
182
183 objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate
184
185 models:
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; \
189           done \
190         fi
191
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; \
195         fi
196
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; \
201           done \
202         fi
203
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; \
208           done \
209         fi
210
211 model-ds390:
212         if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
213           $(MAKE) MODELFLAGS="-mds390" PORT=ds390 PORTINCDIR=$(INCDIR)/mcs51 objects; \
214         fi
215
216 model-ds400:
217         if [ "`grep ds400 ../../ports.build`" = ds400 ]; then \
218           $(MAKE) MODELFLAGS="-mds400" PORT=ds400 PORTINCDIR=$(INCDIR)/mcs51 objects; \
219         fi
220
221 model-xa51:
222         if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
223           $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
224         fi
225
226 objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
227         cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
228
229 model-z80:
230         if [ "`grep z80 ../../ports.build`" = z80 ]; then \
231           $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
232         fi
233
234 model-gbz80:
235         if [ "`grep z80 ../../ports.build`" = z80 ]; then \
236           $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
237         fi
238
239 objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate
240         cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
241
242 model-hc08:
243         if [ "`grep hc08 ../../ports.build`" = hc08 ]; then \
244           $(MAKE) MODELFLAGS="-mhc08" PORT=hc08 objects-hc08; \
245         fi
246
247 objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
248         cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
249
250 model-pic16:
251         if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
252           $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
253         fi
254
255 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
256         -cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
257
258 # yes, we do reuse the *-pic16 rules for pic14
259 model-pic14:
260         if [ "`grep pic ../../ports.build | grep -v pic16`" = pic ]; then \
261           $(MAKE) MODELFLAGS="-mpic14" PORT=pic OEXT=.lib objects-pic16; \
262         fi
263
264 build-dir: $(PORTDIR)
265
266 $(PORTDIR):
267         mkdir -p $(PORTDIR)
268
269 port-specific-objects:
270         if [ -d $(PORT) ]; then \
271           $(MAKE) -C $(PORT); \
272           cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
273         fi
274
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); \
280         fi
281
282 lib-files:
283         cp *.lib $(PORTDIR)
284
285 clean_intermediate:
286         rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym
287
288 clean_intermediate-pic16:
289         $(MAKE) -C $(PORT) clean-intermediate
290
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 {} \; ; \
301         done
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' \) \
305           -exec rm -r {} \;
306
307 # Deleting all the installed files
308 # --------------------------------
309 uninstall:
310         rm -rf $(sdcc_libdir)
311
312 # Performing self-test
313 # --------------------
314 check:
315
316
317 # Performing installation test
318 # ----------------------------
319 installcheck:
320
321
322 # Creating installation directories
323 # ---------------------------------
324 installdirs:
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; \
329         done
330         for libdir in small-stack-auto ds390 ds400 hc08 pic16 pic; do \
331           [ -d $(sdcc_libdir)/$$libdir ] || mkdir -p $(sdcc_libdir)/$$libdir; \
332         done
333         mkdir -p $(sdcc_libdir)/src
334
335 # Creating dependencies
336 # ---------------------
337 dep: Makefile.dep
338
339 Makefile.dep: $(SOURCES) $(INCDIR)/*.h $(PORTINCDIR)/*.h
340         rm -f Makefile.dep
341         for i in $(SOURCES); do \
342           $(CPP) -std=c99 -M $(CPPFLAGS) $$i >$${i}.dep; \
343           cat $${i}.dep >>Makefile.dep; \
344           rm $${i}.dep; \
345         done
346
347 include Makefile.dep
348 include clean.mk
349
350 # My rules
351 # --------
352
353 .SUFFIXES: .rel .o
354
355 $(PORTDIR)/%$(OEXT): %.c
356         $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
357
358 # Remaking configuration
359 # ----------------------
360 checkconf:
361         @if [ -f $(PRJDIR)/devel ]; then\
362           $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
363           freshconf;\
364         fi
365
366 # End of main_in.mk/main.mk