1# Makefile to build the Atari test program and other required files
2# for the TOS tester and to run it with minimal or fairly full
3# set of options.
4
5# default target is 'test', everything else gets build as its deps
6all: test
7
8# targets without corresponding file
9.PHONY: clean test test-all
10
11
12# tos/ subdir should be either symlink to where you have your TOS
13# images, or real directory with symlinks to TOS images you want
14# to test with this. Or TOSDIR variable needs to point where they are:
15#   TOSDIR=/path/to/toses/ make
16
17TOSDIR ?= tos
18
19# TOSDIR should contain at least this!
20BUILD_TOS = $(TOSDIR)/etos512k.img
21
22# Hatari machine config for AHCC build
23BUILD_CONFIG = -m --machine tt --tos $(BUILD_TOS)
24
25# where the code & test programs are
26DIR = disk
27
28# AHCC related files expected for building by disk/ahcc-* hconsole scripts
29AHCC_FILES  = $(DIR)/ahcc_p.ttp $(DIR)/include $(DIR)/lib
30BUILD_TOOLS = $(AHCC_FILES) $(BUILD_TOS)
31
32.PHONY: toolcheck
33
34
35# Building test programs requires:
36# - EmuTOS, AHCC and installed Hatari
37#
38# before running make:
39# - symlink etos512k.img and ahcc_p.ttp + its include & lib dirs
40#   under $(DIR)/ subdir
41#
42# -> otherwise toolcheck fails
43
44toolcheck:
45	@which hatari
46	@for i in $(BUILD_TOOLS); do \
47		if [ \! -e $$i ]; then \
48			echo "ERROR: required re-build file '$$i' missing!"; \
49			false; \
50		fi; \
51	done
52
53
54# build the full and minimal GEMDOS emu testers.
55
56
57GEMDOS_TEST   = $(DIR)/GEMDOS.PRG
58GEMDOS_SCRIPT = $(DIR)/ahcc-gemdos
59GEMDOS_DEP    = $(DIR)/gemdos.c $(DIR)/common.c $(DIR)/gemdos.prj toolcheck
60
61# build the full GEMDOS tester
62$(GEMDOS_TEST): $(GEMDOS_DEP)
63	$(RM) $(DIR)/*.O $(DIR)/*.MAP $(DIR)/*.tmp
64	../../tools/hconsole/hconsole.py $(GEMDOS_SCRIPT) -- $(BUILD_CONFIG) $(DIR)
65	[ -f $(DIR)/GEMDOS.O ] && [ \! -f $(DIR)/ldfile.tmp ] # verify compiling & linking succeeded
66
67
68MINIMAL_TEST   = $(DIR)/MINIMAL.PRG
69MINIMAL_SCRIPT = $(DIR)/ahcc-minimal
70MINIMAL_DEP    = $(DIR)/minimal.c $(DIR)/common.c $(DIR)/minimal.prj toolcheck
71
72# build the minimal GEMDOS tester
73$(MINIMAL_TEST): $(MINIMAL_DEP)
74	$(RM) $(DIR)/*.O $(DIR)/*.MAP $(DIR)/*.tmp
75	../../tools/hconsole/hconsole.py $(MINIMAL_SCRIPT) -- $(BUILD_CONFIG) $(DIR)
76	[ -f $(DIR)/MINIMAL.O ] && [ \! -f $(DIR)/ldfile.tmp ] # verify compiling & linking succeeded
77
78
79clean:
80	$(RM) $(DIR)/*.O $(DIR)/*.MAP $(DIR)/*.tmp
81
82
83# create blank DD floppy image
84blank-a.st.gz:
85	dd if=/dev/zero of=blank-a.st bs=1024 count=720
86	mformat -a -t 80 -h 2 -n 9 -i blank-a.st ::
87	gzip blank-a.st
88
89
90# create 360KB (single side) test floppy that autoruns test program using *.INF file.
91# requires:
92# - mformat & mcopy from mtools
93bootdesk.st.gz: $(MINIMAL_TEST) $(DIR)/TEXT floppy/*.INF
94	dd if=/dev/zero of=bootdesk.st bs=1024 count=360
95	mformat -a -t 80 -h 1 -n 9 -i bootdesk.st ::
96	MTOOLS_NO_VFAT=1 mcopy -i bootdesk.st -spmv $+ ::
97	$(RM) $@
98	gzip bootdesk.st
99
100# create 360KB (single side) test floppy that autoruns test program from auto/
101# as very old TOS versions don't like the *.INF file autorun feature.
102# requires:
103# - mformat, mcopy & mmd from mtools
104bootauto.st.gz: $(MINIMAL_TEST) $(DIR)/TEXT
105	dd if=/dev/zero of=bootauto.st bs=1024 count=360
106	mformat -a -t 80 -h 1 -n 9 -i bootauto.st ::
107	MTOOLS_NO_VFAT=1 mmd -i bootauto.st ::AUTO
108	MTOOLS_NO_VFAT=1 mcopy -i bootauto.st -pmv $(DIR)/TEXT ::
109	MTOOLS_NO_VFAT=1 mcopy -i bootauto.st -pmv $(MINIMAL_TEST) ::AUTO
110	$(RM) $@
111	gzip bootauto.st
112
113
114# optional 16MB HD image for EmuTOS/ACSI testing without HD drivers
115# converts floppy desktop infos for HD (A: -> C:)
116hd.img: $(MINIMAL_TEST) $(DIR)/TEXT floppy/*.INF
117	mkdir tmp
118	cp -a $(MINIMAL_TEST) $(DIR)/TEXT tmp/
119	for i in floppy/*.INF; do sed -e 's/A:/C:/g' < $$i > tmp/$${i##*/}; done
120	../../tools/atari-hd-image.sh 16 $@ LABEL tmp
121	$(RM) -r tmp
122
123
124# requires:
125# - Building of floppies & GEMDOS_TEST to have succeeded
126# - Latest Hatari to be installed, or to run this with something like:
127#   PATH=../../build/src:$PATH make
128test: blank-a.st.gz bootauto.st.gz bootdesk.st.gz $(GEMDOS_TEST)
129	./tos_tester.py --disks floppy,gemdos --graphics mono --memsizes 4 --machines ste $(BUILD_TOS)
130
131# run all default tests
132test-full: blank-a.st.gz bootauto.st.gz bootdesk.st.gz
133	./tos_tester.py $(TOSDIR)/*.img
134