cp on sparc-solaris (SunOS) does not support -u option
[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),SunOS)
16 CP_U    = $(CP)
17 else
18 CP_U    = $(CP) -p
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
48
49 BUILDDIR        = build
50 # Default
51 PORT            = z80
52 PORTDIR         = $(BUILDDIR)/$(PORT)
53
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 \
63                   _slong2fs.c \
64                   _memcmp.c _memcpy.c _memmove.c _memset.c \
65                   _modsint.c _modslong.c _moduint.c _modulong.c \
66                   _mulint.c _mullong.c \
67                   abs.c labs.c \
68                   _ser.c _setjmp.c \
69                   _spx.c _startup.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 \
73                   _strstr.c _strtok.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
86
87 OBJECTS         = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
88
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 \
94                   _startup.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 \
98                   _strstr.c _strtok.c \
99                   assert.c \
100                   _modslong.c _modulong.c \
101                   _mullong.c \
102                   abs.c labs.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 \
109                   _fsneq.c _fssub.c \
110                   _uchar2fs.c _uint2fs.c \
111                   _ulong2fs.c \
112                   _slong2fs.c _sint2fs.c _schar2fs.c
113
114 Z80OBJECTS      = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
115
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 \
121                   _fsneq.c _fssub.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 \
127                   abs.c labs.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 \
134                   puts.c gets.c \
135                   printf_large.c puts.c gets.c \
136                   assert.c time.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
141
142 XA51OBJECTS      = $(XA51SOURCES:%.c=$(PORTDIR)/%.rel)
143
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 \
149                   _fsneq.c _fssub.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 \
153                   _slong2fs.c \
154                   _memcmp.c _memcpy.c _memmove.c _memset.c \
155                   _modsint.c _modslong.c _moduint.c _modulong.c \
156                   abs.c labs.c \
157                   _spx.c _startup.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 \
165                   assert.c time.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
170
171 HC08OBJECTS     = $(patsubst %.c,$(PORTDIR)/%.rel,$(HC08SOURCES))
172
173 OEXT            = .rel
174
175 include incl.mk
176
177 # Compiling entire program or any subproject
178 # ------------------------------------------
179 all: checkconf models model-ds390 model-ds400 model-z80 model-gbz80 model-hc08 model-pic16
180
181 objects: build-dir $(OBJECTS) port-specific-objects lib-files clean_intermediate
182
183 models:
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; \
187           done \
188         fi
189
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; \
194           done \
195         fi
196
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; \
201           done \
202         fi
203
204 model-ds390:
205         if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
206           $(MAKE) MODELFLAGS="-mds390" PORT=ds390 PORTINCDIR=$(INCDIR)/mcs51 objects; \
207         fi
208
209 model-ds400:
210         if [ "`grep ds400 ../../ports.build`" = ds400 ]; then \
211           $(MAKE) MODELFLAGS="-mds400" PORT=ds400 PORTINCDIR=$(INCDIR)/mcs51 objects; \
212         fi
213
214 model-xa51:
215         if [ "`grep xa51 ../../ports.build`" = xa51 ]; then \
216           $(MAKE) MODELFLAGS="-mxa51" PORT=xa51 objects-xa51; \
217         fi
218
219 objects-xa51: build-dir $(XA51OBJECTS) port-specific-objects
220         cd $(PORTDIR); ls *$(OEXT) > lib$(PORT).lib
221
222 model-z80:
223         if [ "`grep z80 ../../ports.build`" = z80 ]; then \
224           $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
225         fi
226
227 model-gbz80:
228         if [ "`grep z80 ../../ports.build`" = z80 ]; then \
229           $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
230         fi
231
232 objects-z80: build-dir $(Z80OBJECTS) port-specific-objects clean_intermediate
233         cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
234
235 model-hc08:
236         if [ "`grep hc08 ../../ports.build`" = hc08 ]; then \
237           $(MAKE) MODELFLAGS="-mhc08" PORT=hc08 objects-hc08; \
238         fi
239
240 objects-hc08: build-dir $(HC08OBJECTS) port-specific-objects clean_intermediate
241         cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
242
243 model-pic16:
244         if [ "`grep pic16 ../../ports.build`" = pic16 ]; then \
245           $(MAKE) MODELFLAGS="-mpic16" PORT=pic16 OEXT=.lib objects-pic16; \
246         fi
247
248 objects-pic16: build-dir port-specific-objects-pic16 clean_intermediate-pic16
249         cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
250
251
252 build-dir: $(PORTDIR)
253
254 $(PORTDIR):
255         mkdir -p $(PORTDIR)
256
257 port-specific-objects:
258         if [ -d $(PORT) ]; then \
259           $(MAKE) -C $(PORT); \
260           cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
261         fi
262
263 port-specific-objects-pic16:
264         -if [ -d $(PORT) ]; then \
265           mkdir -p $(PORT)/bin; \
266           $(MAKE) -C $(PORT); \
267           cp -f $(PORT)/bin/*.* $(PORTDIR); \
268         fi
269
270 lib-files:
271         cp *.lib $(PORTDIR)
272
273 clean_intermediate:
274         rm -f $(PORTDIR)/*.lst $(PORTDIR)/*.sym
275
276 clean_intermediate-pic16:
277         $(MAKE) -C $(PORT) clean-intermediate
278
279 # Compiling and installing everything and runing test
280 # ---------------------------------------------------
281 install: all installdirs
282         $(CP_U) -r $(BUILDDIR)/* $(sdcc_libdir)
283         $(CP_U) -r ds390 ds400 gbz80 z80 hc08 *.c $(sdcc_libdir)/src
284         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'`
285
286 # Deleting all the installed files
287 # --------------------------------
288 uninstall:
289         rm -rf $(sdcc_libdir)
290
291 # Performing self-test
292 # --------------------
293 check:
294
295
296 # Performing installation test
297 # ----------------------------
298 installcheck:
299
300
301 # Creating installation directories
302 # ---------------------------------
303 installdirs:
304         [ -d $(sdcc_libdir) ] || mkdir -p $(sdcc_libdir)
305         for model in $(MODELS); do \
306          [ -d $(sdcc_libdir)/$$model ] || \
307          mkdir -p $(sdcc_libdir)/$$model; \
308         done
309         [ -d $(sdcc_libdir)/ds390 ] || mkdir -p $(sdcc_libdir)/ds390
310         [ -d $(sdcc_libdir)/ds400 ] || mkdir -p $(sdcc_libdir)/ds400
311         [ -d $(sdcc_libdir)/hc08 ] || mkdir -p $(sdcc_libdir)/hc08
312         [ -d $(sdcc_libdir)/pic16 ] || mkdir -p $(sdcc_libdir)/pic16
313         mkdir -p $(sdcc_libdir)/src
314
315 # Creating dependencies
316 # ---------------------
317 dep: Makefile.dep
318
319 Makefile.dep: $(SOURCES) $(INCDIR)/*.h $(PORTINCDIR)/*.h
320         rm -f Makefile.dep
321         for i in $(SOURCES); do \
322           $(CPP) -std=c99 -M $(CPPFLAGS) $$i >$${i}.dep; \
323           cat $${i}.dep >>Makefile.dep; \
324           rm $${i}.dep; \
325         done
326
327 include Makefile.dep
328 include clean.mk
329
330 # My rules
331 # --------
332
333 .SUFFIXES: .rel .o
334
335 $(PORTDIR)/%$(OEXT): %.c
336         $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
337
338 # Remaking configuration
339 # ----------------------
340 checkconf:
341         @if [ -f $(PRJDIR)/devel ]; then\
342           $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
343           freshconf;\
344         fi
345
346 # End of main_in.mk/main.mk