source: buchla-68k/Makefile@ 703d4d0

Last change on this file since 703d4d0 was 499da16, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Fix permissions.

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