source: buchla-68k/Makefile@ c091ef8

Last change on this file since c091ef8 was 9bf0f86, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Build libraries, try to link.

  • Property mode set to 100644
File size: 7.7 KB
Line 
1CROSS_DIR := /opt/cross-m68k/bin
2CROSS_TRI := m68k-none-elf
3CROSS_PRE := $(CROSS_DIR)/$(CROSS_TRI)
4
5CROSS_GCC := $(CROSS_PRE)-gcc
6CROSS_AS := $(CROSS_PRE)-as
7CROSS_AR := $(CROSS_PRE)-ar
8
9# -mshort sets the size of an int to 16 bits; important for interop with
10# the hand-written assembly language code
11
12FLAGS := -Os -m68000 -Wall -Wextra
13
14FLAGS_COM := $(FLAGS) -mshort -std=c99 -ffreestanding -nostdinc \
15 -fno-strict-aliasing -fno-inline -fno-omit-frame-pointer \
16 -Wpedantic -Wcast-align -Wcast-qual -Wconversion -Wsign-conversion \
17 -Wshadow -Wmissing-declarations -Wredundant-decls \
18 -I include
19
20FLAGS_ASM := $(FLAGS) -Wa,--register-prefix-optional
21FLAGS_LNK := $(FLAGS) -mshort -std=c99 -ffreestanding -nostdlib
22
23HEADERS := $(wildcard include/*.h)
24
25all: rom.abs midas.abs
26
27PROLOG_C := croot.c
28PROLOG_S := fsmain.s
29
30PROLOG_CO := $(PROLOG_C:.c=.o)
31PROLOG_SO := $(PROLOG_S:.s=.o)
32
33PROLOG_SRC := $(PROLOG_C:%=prolog/%) $(PROLOG_S:%=prolog/%)
34PROLOG_OBJ := $(PROLOG_CO:%=build/%) $(PROLOG_SO:%=build/%)
35
36build/%.o: prolog/%.c $(HEADERS) | build
37 $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
38
39build/%.o: prolog/%.s $(HEADERS) | build
40 $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
41
42prolog.a: $(PROLOG_OBJ)
43 rm -f prolog.a
44 $(CROSS_AR) rcs prolog.a $(PROLOG_OBJ)
45
46IOLIB_C := dofmt.c mdump.c pause.c printf.c rawio.c sprintf.c waitcr.c
47IOLIB_S := hwdefs.s rtraps.s setipl.s setsr.s traps.s
48
49IOLIB_CO := $(IOLIB_C:.c=.o)
50IOLIB_SO := $(IOLIB_S:.s=.o)
51
52IOLIB_SRC := $(IOLIB_C:%=iolib/%) $(IOLIB_S:%=iolib/%)
53IOLIB_OBJ := $(IOLIB_CO:%=build/%) $(IOLIB_SO:%=build/%)
54
55build/%.o: iolib/%.c $(HEADERS) | build
56 $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
57
58build/%.o: iolib/%.s $(HEADERS) | build
59 $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
60
61iolib.a: $(IOLIB_OBJ)
62 rm -f iolib.a
63 $(CROSS_AR) rcs iolib.a $(IOLIB_OBJ)
64
65LIBCIO_C := atoi.c atol.c blkrd.c blkwr.c close.c clusmap.c conin.c conwr.c \
66 dirfns.c fgets.c filesys.c filname.c flread.c fopen.c fprintf.c \
67 fputs.c fread.c fscanf.c fseek.c fsinit.c fsize.c fstubs.c ftell.c \
68 fwrite.c getbuff.c getc.c getl.c getw.c lseek.c open.c posit.c putc.c \
69 putl.c putw.c read.c readrn.c rename.c scan.c setbuf.c ungetc.c \
70 unlink.c write.c writern.c
71
72LIBCIO_S := ptcl12.s
73
74LIBCIO_CO := $(LIBCIO_C:.c=.o)
75LIBCIO_SO := $(LIBCIO_S:.s=.o)
76
77LIBCIO_SRC := $(LIBCIO_C:%=libcio/%) $(LIBCIO_S:%=libcio/%)
78LIBCIO_OBJ := $(LIBCIO_CO:%=build/%) $(LIBCIO_SO:%=build/%)
79
80build/%.o: libcio/%.c $(HEADERS) | build
81 $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
82
83build/%.o: libcio/%.s $(HEADERS) | build
84 $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
85
86libcio.a: $(LIBCIO_OBJ)
87 rm -f libcio.a
88 $(CROSS_AR) rcs libcio.a $(LIBCIO_OBJ)
89
90LIBSM_C := index.c memccpy.c memchr.c memcmp.c memcmpu.c memcpy.c memcpyw.c \
91 memset.c memsetw.c rindex.c str2lc.c str2uc.c strcat.c strccpy.c \
92 strchr.c strcmp.c strcpy.c strcspn.c strfill.c strlcmp.c strlen.c \
93 strltrm.c strncat.c strncmp.c strncpy.c strpbrk.c strrchr.c strrev.c \
94 strrevi.c strrtrm.c strspn.c strtok.c strtol.c
95
96LIBSM_CO := $(LIBSM_C:.c=.o)
97
98LIBSM_SRC := $(LIBSM_C:%=libsm/%)
99LIBSM_OBJ := $(LIBSM_CO:%=build/%)
100
101build/%.o: libsm/%.c $(HEADERS) | build
102 $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
103
104libsm.a: $(LIBSM_OBJ)
105 rm -f libsm.a
106 $(CROSS_AR) rcs libsm.a $(LIBSM_OBJ)
107
108LIB700_C := bitrev.c ctype.c ispow2.c mangle.c micons.c tolower.c toupper.c
109
110LIB700_S := aldiv.s almul.s alrem.s blkfill.s blkmove.s finalone.s jumpto.s \
111 ldiv.s lmul.s lrem.s rand24.s setjmp.s uldiv.s
112
113LIB700_CO := $(LIB700_C:.c=.o)
114LIB700_SO := $(LIB700_S:.s=.o)
115
116LIB700_SRC := $(LIB700_C:%=lib700/%) $(LIB700_S:%=lib700/%)
117LIB700_OBJ := $(LIB700_CO:%=build/%) $(LIB700_SO:%=build/%)
118
119build/%.o: lib700/%.c $(HEADERS) | build
120 $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
121
122build/%.o: lib700/%.s $(HEADERS) | build
123 $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
124
125lib700.a: $(LIB700_OBJ)
126 rm -f lib700.a
127 $(CROSS_AR) rcs lib700.a $(LIB700_OBJ)
128
129VLIB_C := cg2.c cg3.c glcinit.c lseg.c vbfill4.c vclrs.c vhinit.c vmput.c \
130 vobjfns.c vputs.c vputsv.c vsetpal.c vsinit.c vspray4.c vtext.c \
131 vwputm.c
132
133VLIB_S := acctrl.s glcplot.s tsplot4.s vbank.s vclrav.s vcputs.s vcputsv.s \
134 viint.s vputa.s vputc.s vputcv.s vputp.s vsetav.s vsetcv.s vsplot4.s \
135 vvputsv.s vwputp.s vwputs.s
136
137VLIB_CO := $(VLIB_C:.c=.o)
138VLIB_SO := $(VLIB_S:.s=.o)
139
140VLIB_SRC := $(VLIB_C:%=vlib/%) $(VLIB_S:%=vlib/%)
141VLIB_OBJ := $(VLIB_CO:%=build/%) $(VLIB_SO:%=build/%)
142
143build/%.o: vlib/%.c $(HEADERS) | build
144 $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
145
146build/%.o: vlib/%.s $(HEADERS) | build
147 $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
148
149vlib.a: $(VLIB_OBJ)
150 rm -f vlib.a
151 $(CROSS_AR) rcs vlib.a $(VLIB_OBJ)
152
153ROM_C := booter.c romp.c
154ROM_S := bios.s lowram.s timeint.s
155
156ROM_CO := $(ROM_C:.c=.o)
157ROM_SO := $(ROM_S:.s=.o)
158
159ROM_SRC := $(ROM_C:%=rom/%) $(ROM_S:%=rom/%)
160ROM_OBJ := $(ROM_CO:%=build/%) $(ROM_SO:%=build/%)
161
162build/%.o: rom/%.c $(HEADERS) | build
163 $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
164
165build/%.o: rom/%.s $(HEADERS) | build
166 $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
167
168rom.abs: prolog.a iolib.a libcio.a libsm.a lib700.a vlib.a $(ROM_OBJ)
169 $(CROSS_GCC) $(FLAGS_LNK) -o rom.abs $(ROM_OBJ) \
170 prolog.a libcio.a vlib.a iolib.a libsm.a lib700.a
171
172RAM_C := addfpu.c adfield.c adselbx.c asgdsp.c asgvce.c barbadj.c chgsef.c \
173 chksec.c cminit.c ctcpos.c curset.c dbentr.c dcopy.c dec2fr.c delnote.c \
174 delpnts.c dformat.c dopatch.c enterit.c etaccn.c etadep.c etadyn.c \
175 etagch.c etagpt.c etains.c etaint.c etaopt.c etaprg.c etarat.c etatab.c \
176 etatun.c etavgr.c etdyn.c etiact.c eticnf.c etidin.c etimlt.c etinst.c \
177 etioas.c etiosc.c etipnt.c etires.c etitim.c etival.c etivce.c etiwsn.c \
178 etloc.c etmcfn.c etrel.c etres1.c etscor.c etsnbt.c etstrn.c ettpch.c \
179 ettrns.c etttab.c ettval.c etvel.c etwavs.c etwhar.c etwhrv.c etwoff.c \
180 etwpnt.c etwslt.c etwvce.c fcnote.c frfind.c gcurpos.c idfield.c idselbx.c \
181 im700.c infield.c initi.c instdsp.c itcpos.c kbobj.c lcdlbls.c ldfield.c \
182 ldselbx.c libdsp.c librw.c localkb.c m7menu.c midas.c msl.c msm.c nedacc.c \
183 pix2mid.c ptdisp.c ptdkey.c ptfield.c ptread.c ptselbx.c ptwrite.c puteq.c \
184 rscript.c scadv.c scfield.c scgoto.c scinit.c scope.c scordsp.c scread.c \
185 scselbx.c sctrak.c scwrite.c seccpy.c sedump.c select.c sendval.c setgc.c \
186 setv2gi.c setwq.c showcfg.c smscrl.c sqdisp.c sqdkey.c sqexec.c sqfield.c \
187 sqread.c sqscan.c sqselbx.c sqwrite.c stcpos.c stmproc.c swinit.c tdfield.c \
188 tdselbx.c ttcpos.c tundsp.c ucslice.c uslice.c vtyper.c wdfield.c wdselbx.c \
189 wheel.c wscalc.c wsdsp.c
190
191RAM_S := execins.s execkey.s fpuint.s procpfl.s sedisp.s seexec.s serintr.s \
192 sreset.s timeint.s tofpu.s verdate.s
193
194RAM_CO := $(RAM_C:.c=.o)
195RAM_SO := $(RAM_S:.s=.o)
196
197RAM_SRC := $(RAM_C:%=rom/%) $(RAM_S:%=rom/%)
198RAM_OBJ := $(RAM_CO:%=build/%) $(RAM_SO:%=build/%)
199
200build/%.o: ram/%.c $(HEADERS) | build
201 $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
202
203build/%.o: ram/%.s $(HEADERS) | build
204 $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
205
206midas.abs: prolog.a iolib.a libcio.a libsm.a lib700.a vlib.a $(RAM_OBJ)
207 $(CROSS_GCC) $(FLAGS_LNK) -o midas.abs $(RAM_OBJ) \
208 prolog.a libcio.a vlib.a iolib.a libsm.a lib700.a
209
210build:
211 mkdir build
212
213hatari/c.img: $(wildcard hatari/c/bin/*) $(wildcard hatari/c/work/*)
214 rm -f hatari/c.img
215 atari-hd-image 16 hatari/c.img BUCHLA hatari/c
216
217emu: hatari/c.img
218 hatari \
219 --control-socket /tmp/buchla.sock \
220 --memsize 14 \
221 --vdi-width 1280 --vdi-height 960 \
222 --drive-a false --drive-b false \
223 --acsi 0=hatari/c.img \
224 --harddrive hatari/d --gemdos-drive d
225
226rem:
227 hatari/rem.py
228
229clean:
230 rm -rf build
231 rm -f prolog.a iolib.a libcio.a libsm.a lib700.a vlib.a
232 rm -f rom.abs midas.abs
233 rm -f hatari/c.img
234 rm -f hatari/d/out/*
Note: See TracBrowser for help on using the repository browser.