source: buchla-68k/Makefile@ ad89950

Last change on this file since ad89950 was 197ff76, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Validate FLOPVBL and FLOCK definitions in ram/timeint.s.

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