+ifdef CMD_EXE
+ NULLDEV = nul:
+ DEL = -del /f
+ RMDIR = rmdir /s /q
+else
+ NULLDEV = /dev/null
+ DEL = $(RM)
+ RMDIR = $(RM) -r
+endif
+
+ifdef CC65_HOME
+ AS = $(CC65_HOME)/bin/ca65
+ CC = $(CC65_HOME)/bin/cc65
+ CL = $(CC65_HOME)/bin/cl65
+ LD = $(CC65_HOME)/bin/ld65
+else
+ AS := $(if $(wildcard ../bin/ca65*),../bin/ca65,ca65)
+ CC := $(if $(wildcard ../bin/cc65*),../bin/cc65,cc65)
+ CL := $(if $(wildcard ../bin/cl65*),../bin/cl65,cl65)
+ LD := $(if $(wildcard ../bin/ld65*),../bin/ld65,ld65)
+endif
+
+TARGET_PATH := $(shell $(CL) --print-target-path)
+
+EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*)
+MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*)
+TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*)
+
+# This one comes with VICE
+C1541 ?= c1541
+
+# For this one see http://applecommander.sourceforge.net/
+AC ?= ac.jar
+
+# For this one see http://www.horus.com/~hias/atari/
+DIR2ATR ?= dir2atr
+
+DISK_c64 = samples.d64
+DISK_apple2 = samples.dsk
+DISK_apple2enh = samples.dsk
+DISK_atari = samples.atr
+DISK_atarixl = samples.atr
+
+# --------------------------------------------------------------------------
+# System-dependent settings
+
+# The Apple machines need the start address adjusted when using TGI
+LDFLAGS_mandelbrot_apple2 = --start-addr 0x4000
+LDFLAGS_mandelbrot_apple2enh = --start-addr 0x4000
+LDFLAGS_tgidemo_apple2 = --start-addr 0x4000
+LDFLAGS_tgidemo_apple2enh = --start-addr 0x4000
+
+# The Apple ][ needs the start address adjusted for the mousetest
+LDFLAGS_mousetest_apple2 = --start-addr 0x4000
+
+# The Apple machines need the end address adjusted for large programs
+LDFLAGS_gunzip65_apple2 = -D __HIMEM__=0xBF00
+LDFLAGS_gunzip65_apple2enh = -D __HIMEM__=0xBF00
+
+# The atari target needs to reserve some memory when using TGI
+LDFLAGS_mandelbrot_atari = -D __RESERVED_MEMORY__=0x2000
+LDFLAGS_tgidemo_atari = -D __RESERVED_MEMORY__=0x2000
+
+# The atarixl target needs the start address adjusted when using TGI
+LDFLAGS_mandelbrot_atarixl = --start-addr 0x4000
+LDFLAGS_tgidemo_atarixl = --start-addr 0x4000