* support/regression/ports/host/spec.mk: Updated to compile with the new...
[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 PRJDIR          = ../..
16 INCDIR          = $(PRJDIR)/device/include
17
18 CC              = $(PRJDIR)/bin/sdcc
19 CPP             = $(PRJDIR)/bin/sdcpp
20
21 prefix          = @prefix@
22 exec_prefix     = @exec_prefix@
23 bindir          = @bindir@
24 libdir          = @libdir@
25 datadir         = @datadir@
26 sdcc_datadir    = @sdcc_datadir@
27 includedir      = @includedir@
28 mandir          = @mandir@
29 man1dir         = $(mandir)/man1
30 man2dir         = $(mandir)/man2
31 infodir         = @infodir@
32 srcdir          = @srcdir@
33
34 CPPFLAGS        = -I$(INCDIR)
35 CFLAGS          = $(MODELFLAGS) --nostdinc --nostdlib
36
37 BUILDDIR        = build
38 # Default
39 PORT            = z80
40 PORTDIR         = $(BUILDDIR)/$(PORT)
41
42 SOURCES         = _atoi.c _atol.c _autobaud.c _bp.c _schar2fs.c \
43                   _decdptr.c _divsint.c _divslong.c _divuint.c \
44                   _divulong.c _fs2schar.c _fs2sint.c _fs2slong.c \
45                   _fs2uchar.c _fs2uint.c _fs2ulong.c _fsadd.c \
46                   _fsdiv.c _fseq.c _fsgt.c _fslt.c _fsmul.c \
47                   _fsneq.c _fssub.c _gptrget.c _gptrput.c \
48                   _sint2fs.c _iscntrl.c _isdigit.c _isgraph.c \
49                   _islower.c _isprint.c _ispunct.c _isspace.c \
50                   _isupper.c _isxdigit.c _slong2fs.c _memcmp.c \
51                   _memcpy.c _memset.c _modsint.c _modslong.c \
52                   _moduint.c _modulong.c _mulsint.c _muluint.c \
53                   _mululong.c _mulslong.c _ser.c _setjmp.c \
54                   _spx.c _startup.c _strchr.c _strcmp.c _strcpy.c \
55                   _strcspn.c _strlen.c _strncat.c _strncmp.c \
56                   _strncpy.c _strpbrk.c _strrchr.c _strspn.c \
57                   _strstr.c _strtok.c _uchar2fs.c _uint2fs.c \
58                   _ulong2fs.c malloc.c serial.c ser_ir.c printfl.c \
59                   printf_large.c vprintf.c puts.c gets.c \
60                   assert.c _strcat.c time.c printf_fast.c \
61                   _mulint.c _mullong.c
62
63 OBJECTS         = $(patsubst %.c,$(PORTDIR)/%.rel,$(SOURCES))
64
65 Z80SOURCES      = _atoi.c \
66                   _iscntrl.c _isdigit.c _isgraph.c \
67                   _islower.c _isprint.c _ispunct.c _isspace.c \
68                   _isupper.c _isxdigit.c _memcmp.c \
69                   _memcpy.c _memset.c \
70                   _startup.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                   puts.c gets.c \
75                   assert.c _strcat.c \
76                   _modslong.c _modulong.c \
77                   _mullong.c \
78                   _divslong.c _divulong.c
79
80 Z80OBJECTS      = $(Z80SOURCES:%.c=$(PORTDIR)/%.o)
81
82 OEXT            = .rel
83
84 include incl.mk
85
86 # Compiling entire program or any subproject
87 # ------------------------------------------
88 all: checkconf models model-ds390 model-z80 model-gbz80
89
90 objects: build-dir $(OBJECTS) port-specific-objects lib-files
91
92 models:
93         if [ "`grep mcs51 ../../ports.build`" = mcs51 ]; then \
94           for model in $(MODELS); do \
95             $(MAKE) MODELFLAGS="--model-$$model" PORT=$$model objects; \
96           done \
97         fi
98
99 model-ds390:
100         if [ "`grep ds390 ../../ports.build`" = ds390 ]; then \
101           $(MAKE) MODELFLAGS="-mds390" PORT=ds390 objects; \
102         fi
103
104 model-z80:
105         if [ "`grep z80 ../../ports.build`" = z80 ]; then \
106           $(MAKE) MODELFLAGS="-mz80" PORT=z80 objects-z80 OEXT=.o; \
107         fi
108
109 model-gbz80:
110         if [ "`grep z80 ../../ports.build`" = z80 ]; then \
111           $(MAKE) MODELFLAGS="-mgbz80" PORT=gbz80 objects-z80 OEXT=.o; \
112         fi
113
114 objects-z80: build-dir $(Z80OBJECTS) port-specific-objects
115         cd $(PORTDIR); ls *$(OEXT) > $(PORT).lib
116
117 build-dir: $(PORTDIR)
118
119 $(PORTDIR):
120         mkdir -p $(PORTDIR)
121
122 port-specific-objects:
123         if [ -d $(PORT) ]; then \
124           $(MAKE) -C $(PORT); \
125           cp -f $(PORT)/*.lib $(PORT)/*$(OEXT) $(PORTDIR); \
126         fi
127
128 lib-files:
129         cp *.lib $(PORTDIR)
130
131 # Compiling and installing everything and runing test
132 # ---------------------------------------------------
133 install: all installdirs
134         cp -r $(BUILDDIR)/* $(sdcc_datadir)/lib
135         cp -r ds390 gbz80 z80 *.c $(sdcc_datadir)/lib/src
136         rm `find $(sdcc_datadir)/lib/src -name '*.rel' -or -name '*.dump*' -or -name '*.sym' -or -name '*.o' -or -name '*.lst' -or -name '*.asm'`
137
138 # Deleting all the installed files
139 # --------------------------------
140 uninstall:
141         for hdr in ../include/*.h; do rm -f $(sdcc_datadir)/include/$$hdr; done
142         for cfl in *.c; do rm -f $(sdcc_datadir)/lib/$$cfl; done
143         for model in $(MODELS); do \
144           rm -rf $(sdcc_datadir)/lib/$$model; \
145         done
146         rm -rf $(sdcc_datadir)/lib/ds390
147
148
149 # Performing self-test
150 # --------------------
151 check:
152
153
154 # Performing installation test
155 # ----------------------------
156 installcheck:
157
158
159 # Creating installation directories
160 # ---------------------------------
161 installdirs:
162         [ -d $(sdcc_datadir)/lib ] || mkdir -p $(sdcc_datadir)/lib
163         for model in $(MODELS); do \
164          [ -d $(sdcc_datadir)/lib/$$model ] || \
165          mkdir -p $(sdcc_datadir)/lib/$$model; \
166         done
167         [ -d $(sdcc_datadir)/lib/ds390 ] || mkdir -p $(sdcc_datadir)/lib/ds390
168         mkdir -p $(sdcc_datadir)/lib/src
169
170 # Creating dependencies
171 # ---------------------
172 dep: Makefile.dep
173
174 Makefile.dep: $(SOURCES) $(INCDIR)/*.h
175         rm -f Makefile.dep
176         for i in $(SOURCES); do \
177           $(CPP) -lang-c++ -M $(CPPFLAGS) $$i >$${i}.dep; \
178           cat $${i}.dep >>Makefile.dep; \
179           rm $${i}.dep; \
180         done
181
182 include Makefile.dep
183 include clean.mk
184
185 # My rules
186 # --------
187
188 .SUFFIXES: .rel .o
189
190 $(PORTDIR)/%$(OEXT): %.c
191         $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
192         mv -f `basename $@` $@
193         mv -f `basename $@ $(OEXT)`.asm $(PORTDIR)
194
195 # Remaking configuration
196 # ----------------------
197 checkconf:
198         @if [ -f $(PRJDIR)/devel ]; then\
199           $(MAKE) -f $(srcdir)/conf.mk srcdir="$(srcdir)" PRJDIR="$(PRJDIR)" \
200           freshconf;\
201         fi
202
203 # End of main_in.mk/main.mk