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