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