source: buchla-68k/Makefile@ 210d896

Last change on this file since 210d896 was 53a8288, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Use absolute path for objdump.

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