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