source: buchla-68k/Makefile@ 62340ef

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

Create output files via ELF files.

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