source: buchla-68k/Makefile@ ff9ab1a

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

Assembly code clobbers d2 and a2.

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