[109c83b] | 1 | CROSS_DIR := /opt/cross-m68k/bin
|
---|
| 2 | CROSS_TRI := m68k-none-elf
|
---|
| 3 | CROSS_PRE := $(CROSS_DIR)/$(CROSS_TRI)
|
---|
| 4 |
|
---|
| 5 | CROSS_GCC := $(CROSS_PRE)-gcc
|
---|
| 6 | CROSS_AS := $(CROSS_PRE)-as
|
---|
[9bf0f86] | 7 | CROSS_AR := $(CROSS_PRE)-ar
|
---|
[6dc5ea7] | 8 | CROSS_OBJC := $(CROSS_PRE)-objcopy
|
---|
[87361de] | 9 | CROSS_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] | 14 | FLAGS := -Os -m68000 -Wall -Wextra -gdwarf-4
|
---|
[bef53a9] | 15 |
|
---|
[6dc5ea7] | 16 | FLAGS_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 |
|
---|
[bef53a9] | 22 | FLAGS_ASM := $(FLAGS) -Wa,--register-prefix-optional
|
---|
[9bf0f86] | 23 | FLAGS_LNK := $(FLAGS) -mshort -std=c99 -ffreestanding -nostdlib
|
---|
[109c83b] | 24 |
|
---|
| 25 | HEADERS := $(wildcard include/*.h)
|
---|
| 26 |
|
---|
[87361de] | 27 | all: bios.img midas.abs
|
---|
[9bf0f86] | 28 |
|
---|
[109c83b] | 29 | PROLOG_C := croot.c
|
---|
| 30 | PROLOG_S := fsmain.s
|
---|
| 31 |
|
---|
| 32 | PROLOG_CO := $(PROLOG_C:.c=.o)
|
---|
| 33 | PROLOG_SO := $(PROLOG_S:.s=.o)
|
---|
| 34 | PROLOG_OBJ := $(PROLOG_CO:%=build/%) $(PROLOG_SO:%=build/%)
|
---|
| 35 |
|
---|
| 36 | build/%.o: prolog/%.c $(HEADERS) | build
|
---|
| 37 | $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
|
---|
[6dc5ea7] | 38 | $(CROSS_OBJC) --redefine-syms misc/rewrite.txt $@
|
---|
[109c83b] | 39 |
|
---|
| 40 | build/%.o: prolog/%.s $(HEADERS) | build
|
---|
| 41 | $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
|
---|
| 42 |
|
---|
[9bf0f86] | 43 | prolog.a: $(PROLOG_OBJ)
|
---|
| 44 | rm -f prolog.a
|
---|
| 45 | $(CROSS_AR) rcs prolog.a $(PROLOG_OBJ)
|
---|
| 46 |
|
---|
[109c83b] | 47 | LIBCIO_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 |
|
---|
| 54 | LIBCIO_S := ptcl12.s
|
---|
| 55 |
|
---|
| 56 | LIBCIO_CO := $(LIBCIO_C:.c=.o)
|
---|
| 57 | LIBCIO_SO := $(LIBCIO_S:.s=.o)
|
---|
| 58 | LIBCIO_OBJ := $(LIBCIO_CO:%=build/%) $(LIBCIO_SO:%=build/%)
|
---|
| 59 |
|
---|
| 60 | build/%.o: libcio/%.c $(HEADERS) | build
|
---|
| 61 | $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
|
---|
[6dc5ea7] | 62 | $(CROSS_OBJC) --redefine-syms misc/rewrite.txt $@
|
---|
[109c83b] | 63 |
|
---|
| 64 | build/%.o: libcio/%.s $(HEADERS) | build
|
---|
| 65 | $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
|
---|
| 66 |
|
---|
[9bf0f86] | 67 | libcio.a: $(LIBCIO_OBJ)
|
---|
| 68 | rm -f libcio.a
|
---|
| 69 | $(CROSS_AR) rcs libcio.a $(LIBCIO_OBJ)
|
---|
| 70 |
|
---|
[10afc24] | 71 | VLIB_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 |
|
---|
| 75 | VLIB_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 |
|
---|
| 79 | VLIB_CO := $(VLIB_C:.c=.o)
|
---|
| 80 | VLIB_SO := $(VLIB_S:.s=.o)
|
---|
| 81 | VLIB_OBJ := $(VLIB_CO:%=build/%) $(VLIB_SO:%=build/%)
|
---|
| 82 |
|
---|
| 83 | build/%.o: vlib/%.c $(HEADERS) | build
|
---|
| 84 | $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
|
---|
| 85 | $(CROSS_OBJC) --redefine-syms misc/rewrite.txt $@
|
---|
| 86 |
|
---|
| 87 | build/%.o: vlib/%.s $(HEADERS) | build
|
---|
| 88 | $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
|
---|
| 89 |
|
---|
| 90 | vlib.a: $(VLIB_OBJ)
|
---|
| 91 | rm -f vlib.a
|
---|
| 92 | $(CROSS_AR) rcs vlib.a $(VLIB_OBJ)
|
---|
| 93 |
|
---|
| 94 | IOLIB_C := dofmt.c mdump.c pause.c printf.c rawio.c sprintf.c waitcr.c
|
---|
| 95 | IOLIB_S := hwdefs.s rtraps.s setipl.s setsr.s traps.s
|
---|
| 96 |
|
---|
| 97 | IOLIB_CO := $(IOLIB_C:.c=.o)
|
---|
| 98 | IOLIB_SO := $(IOLIB_S:.s=.o)
|
---|
| 99 | IOLIB_OBJ := $(IOLIB_CO:%=build/%) $(IOLIB_SO:%=build/%)
|
---|
| 100 |
|
---|
| 101 | build/%.o: iolib/%.c $(HEADERS) | build
|
---|
| 102 | $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
|
---|
| 103 | $(CROSS_OBJC) --redefine-syms misc/rewrite.txt $@
|
---|
| 104 |
|
---|
| 105 | build/%.o: iolib/%.s $(HEADERS) | build
|
---|
| 106 | $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
|
---|
| 107 |
|
---|
| 108 | iolib.a: $(IOLIB_OBJ)
|
---|
| 109 | rm -f iolib.a
|
---|
| 110 | $(CROSS_AR) rcs iolib.a $(IOLIB_OBJ)
|
---|
| 111 |
|
---|
[109c83b] | 112 | LIBSM_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 |
|
---|
| 118 | LIBSM_CO := $(LIBSM_C:.c=.o)
|
---|
| 119 | LIBSM_OBJ := $(LIBSM_CO:%=build/%)
|
---|
| 120 |
|
---|
| 121 | build/%.o: libsm/%.c $(HEADERS) | build
|
---|
| 122 | $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
|
---|
[6dc5ea7] | 123 | $(CROSS_OBJC) --redefine-syms misc/rewrite.txt $@
|
---|
[109c83b] | 124 |
|
---|
[9bf0f86] | 125 | libsm.a: $(LIBSM_OBJ)
|
---|
| 126 | rm -f libsm.a
|
---|
| 127 | $(CROSS_AR) rcs libsm.a $(LIBSM_OBJ)
|
---|
| 128 |
|
---|
[109c83b] | 129 | LIB700_C := bitrev.c ctype.c ispow2.c mangle.c micons.c tolower.c toupper.c
|
---|
| 130 |
|
---|
| 131 | LIB700_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 |
|
---|
| 134 | LIB700_CO := $(LIB700_C:.c=.o)
|
---|
| 135 | LIB700_SO := $(LIB700_S:.s=.o)
|
---|
| 136 | LIB700_OBJ := $(LIB700_CO:%=build/%) $(LIB700_SO:%=build/%)
|
---|
| 137 |
|
---|
| 138 | build/%.o: lib700/%.c $(HEADERS) | build
|
---|
| 139 | $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
|
---|
[6dc5ea7] | 140 | $(CROSS_OBJC) --redefine-syms misc/rewrite.txt $@
|
---|
[109c83b] | 141 |
|
---|
| 142 | build/%.o: lib700/%.s $(HEADERS) | build
|
---|
| 143 | $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
|
---|
| 144 |
|
---|
[9bf0f86] | 145 | lib700.a: $(LIB700_OBJ)
|
---|
| 146 | rm -f lib700.a
|
---|
| 147 | $(CROSS_AR) rcs lib700.a $(LIB700_OBJ)
|
---|
| 148 |
|
---|
[109c83b] | 149 | ROM_C := booter.c romp.c
|
---|
[6dc5ea7] | 150 | ROM_S := bios.s timeint.s
|
---|
[109c83b] | 151 |
|
---|
| 152 | ROM_CO := $(ROM_C:.c=.o)
|
---|
| 153 | ROM_SO := $(ROM_S:.s=.o)
|
---|
[f394e7b] | 154 | # ROM_SO goes before ROM_CO, so that bios.o is first.
|
---|
| 155 | ROM_OBJ := $(ROM_SO:%=build/%) $(ROM_CO:%=build/%)
|
---|
[109c83b] | 156 |
|
---|
[6dc5ea7] | 157 | LOWRAM_S := lowram.s
|
---|
| 158 |
|
---|
| 159 | LOWRAM_SO := $(LOWRAM_S:.s=.o)
|
---|
| 160 | LOWRAM_OBJ := $(LOWRAM_SO:%=build/%)
|
---|
| 161 |
|
---|
[109c83b] | 162 | build/%.o: rom/%.c $(HEADERS) | build
|
---|
| 163 | $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
|
---|
[6dc5ea7] | 164 | $(CROSS_OBJC) --redefine-syms misc/rewrite.txt $@
|
---|
[109c83b] | 165 |
|
---|
| 166 | build/%.o: rom/%.s $(HEADERS) | build
|
---|
| 167 | $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
|
---|
| 168 |
|
---|
[62340ef] | 169 | bios.img: bios.elf
|
---|
| 170 | $(CROSS_OBJC) --output-target binary bios.elf bios.img
|
---|
| 171 |
|
---|
| 172 | bios.elf: $(ROM_OBJ) \
|
---|
[10afc24] | 173 | prolog.a libcio.a vlib.a iolib.a libsm.a lib700.a
|
---|
[f394e7b] | 174 | $(CROSS_GCC) $(FLAGS_LNK) -Wl,--script,misc/rom.ld,--entry,0x100000 \
|
---|
[62340ef] | 175 | -o bios.elf $(ROM_OBJ) \
|
---|
[6dc5ea7] | 176 | prolog.a libcio.a vlib.a iolib.a libsm.a lib700.a -lgcc
|
---|
[9bf0f86] | 177 |
|
---|
[c65a0e2] | 178 | RAM_C := addfpu.c adfield.c adselbx.c asgdsp.c asgvce.c barbadj.c chgsef.c \
|
---|
| 179 | chksec.c cminit.c ctcpos.c curset.c dbentr.c dcopy.c dec2fr.c delnote.c \
|
---|
| 180 | delpnts.c dformat.c dopatch.c enterit.c etaccn.c etadep.c etadyn.c \
|
---|
| 181 | etagch.c etagpt.c etains.c etaint.c etaopt.c etaprg.c etarat.c etatab.c \
|
---|
| 182 | etatun.c etavgr.c etdyn.c etiact.c eticnf.c etidin.c etimlt.c etinst.c \
|
---|
| 183 | etioas.c etiosc.c etipnt.c etires.c etitim.c etival.c etivce.c etiwsn.c \
|
---|
| 184 | etloc.c etmcfn.c etrel.c etres1.c etscor.c etsnbt.c etstrn.c ettpch.c \
|
---|
| 185 | ettrns.c etttab.c ettval.c etvel.c etwavs.c etwhar.c etwhrv.c etwoff.c \
|
---|
| 186 | etwpnt.c etwslt.c etwvce.c fcnote.c frfind.c gcurpos.c idfield.c idselbx.c \
|
---|
| 187 | im700.c infield.c initi.c instdsp.c itcpos.c kbobj.c lcdlbls.c ldfield.c \
|
---|
| 188 | ldselbx.c libdsp.c librw.c localkb.c m7menu.c midas.c msl.c msm.c nedacc.c \
|
---|
| 189 | pix2mid.c ptdisp.c ptdkey.c ptfield.c ptread.c ptselbx.c ptwrite.c puteq.c \
|
---|
| 190 | rscript.c scadv.c scfield.c scgoto.c scinit.c scope.c scordsp.c scread.c \
|
---|
| 191 | scselbx.c sctrak.c scwrite.c seccpy.c sedump.c select.c sendval.c setgc.c \
|
---|
| 192 | setv2gi.c setwq.c showcfg.c smscrl.c sqdisp.c sqdkey.c sqexec.c sqfield.c \
|
---|
| 193 | sqread.c sqscan.c sqselbx.c sqwrite.c stcpos.c stmproc.c swinit.c tdfield.c \
|
---|
| 194 | tdselbx.c ttcpos.c tundsp.c ucslice.c uslice.c vtyper.c wdfield.c wdselbx.c \
|
---|
| 195 | wheel.c wscalc.c wsdsp.c
|
---|
| 196 |
|
---|
| 197 | RAM_S := execins.s execkey.s fpuint.s procpfl.s sedisp.s seexec.s serintr.s \
|
---|
[283e7a6] | 198 | sreset.s timeint.s tofpu.s verdate.s
|
---|
[c65a0e2] | 199 |
|
---|
| 200 | RAM_CO := $(RAM_C:.c=.o)
|
---|
| 201 | RAM_SO := $(RAM_S:.s=.o)
|
---|
| 202 | RAM_OBJ := $(RAM_CO:%=build/%) $(RAM_SO:%=build/%)
|
---|
| 203 |
|
---|
| 204 | build/%.o: ram/%.c $(HEADERS) | build
|
---|
| 205 | $(CROSS_GCC) $(FLAGS_COM) -c -o $@ $<
|
---|
[6dc5ea7] | 206 | $(CROSS_OBJC) --redefine-syms misc/rewrite.txt $@
|
---|
[c65a0e2] | 207 |
|
---|
| 208 | build/%.o: ram/%.s $(HEADERS) | build
|
---|
| 209 | $(CROSS_GCC) $(FLAGS_ASM) -c -o $@ $<
|
---|
| 210 |
|
---|
[87361de] | 211 | midas.abs: midas.elf midas.img
|
---|
| 212 | misc/mkhd.sh $(CROSS_NM) midas.elf >/tmp/midas.hdr
|
---|
| 213 | cat /tmp/midas.hdr midas.img >midas.abs
|
---|
| 214 | rm /tmp/midas.hdr
|
---|
[62340ef] | 215 |
|
---|
| 216 | midas.img: midas.elf
|
---|
| 217 | $(CROSS_OBJC) --output-target binary midas.elf midas.img
|
---|
| 218 |
|
---|
| 219 | midas.elf: $(LOWRAM_OBJ) prolog.a $(RAM_OBJ) \
|
---|
[10afc24] | 220 | libcio.a vlib.a iolib.a libsm.a lib700.a
|
---|
[f394e7b] | 221 | $(CROSS_GCC) $(FLAGS_LNK) -Wl,--script,misc/ram.ld,--entry,0x10000 \
|
---|
[62340ef] | 222 | -o midas.elf $(LOWRAM_OBJ) prolog.a $(RAM_OBJ) \
|
---|
[6dc5ea7] | 223 | libcio.a vlib.a iolib.a libsm.a lib700.a -lgcc
|
---|
[109c83b] | 224 |
|
---|
| 225 | build:
|
---|
| 226 | mkdir build
|
---|
| 227 |
|
---|
[f8c95c4] | 228 | hatari/c.img: $(wildcard hatari/c/bin/*) $(wildcard hatari/c/work/*)
|
---|
[109c83b] | 229 | rm -f hatari/c.img
|
---|
[bef53a9] | 230 | atari-hd-image 16 hatari/c.img BUCHLA hatari/c
|
---|
[109c83b] | 231 |
|
---|
| 232 | emu: hatari/c.img
|
---|
| 233 | hatari \
|
---|
| 234 | --control-socket /tmp/buchla.sock \
|
---|
[bef53a9] | 235 | --memsize 14 \
|
---|
[109c83b] | 236 | --vdi-width 1280 --vdi-height 960 \
|
---|
| 237 | --drive-a false --drive-b false \
|
---|
| 238 | --acsi 0=hatari/c.img \
|
---|
| 239 | --harddrive hatari/d --gemdos-drive d
|
---|
| 240 |
|
---|
| 241 | rem:
|
---|
| 242 | hatari/rem.py
|
---|
| 243 |
|
---|
[6888aa2] | 244 | virt:
|
---|
| 245 | python3 -m venv --without-pip virt
|
---|
| 246 | wget https://bootstrap.pypa.io/get-pip.py -O virt/get-pip.py
|
---|
| 247 | cd virt; . bin/activate; python3 get-pip.py; pip install pycparser
|
---|
| 248 |
|
---|
[109c83b] | 249 | clean:
|
---|
| 250 | rm -rf build
|
---|
[9bf0f86] | 251 | rm -f prolog.a iolib.a libcio.a libsm.a lib700.a vlib.a
|
---|
[62340ef] | 252 | rm -f bios.elf bios.img bios.abs
|
---|
| 253 | rm -f midas.elf midas.img midas.abs
|
---|
[109c83b] | 254 | rm -f hatari/c.img
|
---|
| 255 | rm -f hatari/d/out/*
|
---|