#
# Populate the tools directory
#

MANIFEST-AMIGA-BOOT =     "m68k amiga bootstrap support programs"
MANIFEST-AMIGA-AMIBOOT =  "m68k amiga bootstrap program"

MANIFEST-ATARI-BOOTARGS = "m68k atari bootstrap settings"
MANIFEST-ATARI-BOOTSTRA = "m68k atari bootstrap program"
MANIFEST-ATARI-RAWWRITE = "m68k atari floppy writing program"

MANIFEST-MAC-PENGUIN =    "m68k mac bootstrap from MacOS"
MANIFEST-MAC-PENGHFS =    "m68k mac bootstrap from MacOS on floppy"


TOOLS_AMIGA = $(SOME_DEST)/tools/amiga
TOOLS_ATARI = $(SOME_DEST)/tools/atari
TOOLS_MAC   = $(SOME_DEST)/tools/mac

TOOLS_AMIGA_SRC = /usr/share/amiboot
TOOLS_ATARI_SRC = /usr/share/atari-bootstrap
TOOLS_MAC_PENGSRC = /usr/share/penguin

#
# atari tools
#

$(TEMP)/bootstra.tos: $(TOOLS_ATARI_SRC)/ataboot.ttp.gz
	gzip -cd $< > $@

$(TOOLS_ATARI)/bootstra.tos: $(TEMP)/bootstra.tos
	install -m 644 -D $< $@
	update-manifest $@ $(MANIFEST-ATARI-BOOTSTRA)

$(TOOLS_ATARI)/bootargs: boot/m68k/atari-bootargs-cdrom
	sed -e "s,linux,$(KERNELNAME)," $< > $(TEMP)/bootargs
	install -m 644 -D $(TEMP)/bootargs $@
	update-manifest $@ $(MANIFEST-ATARI-BOOTARGS)

$(TOOLS_ATARI)/rawwrite.ttp: $(TOOLS_ATARI_SRC)/rawwrite.ttp.gz
	gzip -cd $< > $@
	update-manifest $@ $(MANIFEST-ATARI-RAWWRITE)

ATARITOOLS = $(TOOLS_ATARI)/bootstra.tos $(TOOLS_ATARI)/bootargs $(TOOLS_ATARI)/rawwrite.ttp

#
# amiga tools
#

# valid AmigaOS path `/' means `one up' (and `:' means `root'),
# so ../../cdrom/initrd.gz => //cdrom/initrd.gz  ???

STARTINSTALL = "amiboot -d -k //kernels/$(KERNELNAME) -r //cdrom/initrd.gz root=/dev/ram nomodeset"

$(TOOLS_AMIGA)/StartInstall:
	echo $(STARTINSTALL) > $(TEMP)/$(@F)
	install -m 644 -D $(TEMP)/$(@F) $@

$(TOOLS_AMIGA)/StartInstall_CV3D:
	echo $(STARTINSTALL) video=virge:640x480-8 > $(TEMP)/$(@F)
	install -m 644 -D $(TEMP)/$(@F) $@

$(TOOLS_AMIGA)/StartInstall_CV64:
	echo $(STARTINSTALL) video=cyber:640x480-8 > $(TEMP)/$(@F)
	install -m 644 -D $(TEMP)/$(@F) $@

$(TOOLS_AMIGA)/StartInstall_clgen:
	echo $(STARTINSTALL) video=clgen: > $(TEMP)/$(@F)
	install -m 644 -D $(TEMP)/$(@F) $@

$(TOOLS_AMIGA)/StartInstall_retz3:
	echo $(STARTINSTALL) video=retz3:640x480 > $(TEMP)/$(@F)
	install -m 644 -D $(TEMP)/$(@F) $@

$(TOOLS_AMIGA)/StartInstall.info: boot/m68k/amiga/StartInstall.info
	install -m 755 -d $(@D)
	install -m 644 $(<D)/StartInstall*.info $(<D)/amiga.info $(<D)/*.txt $(<D)/*.txt.info $(@D)
	update-manifest tools/amiga $(MANIFEST-AMIGA-BOOT)

AMIGATOOLS = $(TOOLS_AMIGA)/StartInstall.info $(TOOLS_AMIGA)/StartInstall $(TOOLS_AMIGA)/StartInstall_CV3D $(TOOLS_AMIGA)/StartInstall_CV64 $(TOOLS_AMIGA)/StartInstall_clgen $(TOOLS_AMIGA)/StartInstall_retz3

# support for the future amiboot package
ifeq (0,$(shell test -f $(TOOLS_AMIGA_SRC)/amiboot.gz && echo 0))
$(TOOLS_AMIGA)/amiboot: $(TOOLS_AMIGA_SRC)/amiboot.gz
	gzip -cd $< > $(TEMP)/amiboot
	install -m 755 -D $(TEMP)/amiboot $@
	update-manifest $@ $(MANIFEST-AMIGA-AMIBOOT)

AMIGATOOLS += $(TOOLS_AMIGA)/amiboot
endif

#
# mac tools
#

# support for the future penguin package
ifeq (0,$(shell test -d $(TOOLS_MAC_PENGSRC) && echo 0))
$(TOOLS_MAC)/penguin.hfs: $(TOOLS_MAC_PENGSRC)/penguin.hfs
	install -m 644 -D $< $@
	update-manifest $@ $(MANIFEST-MAC-PENGHFS)

$(TOOLS_MAC)/Penguin-19.hqx: $(TOOLS_MAC_PENGSRC)/Penguin-19.hqx $(TOOLS_MAC_PENGSRC)/PenguinColors.hqx $(TOOLS_MAC_PENGSRC)/PenguinPrefs.hqx
	install -m 644 -D $^ $(@D)
	update-manifest $@ $(MANIFEST-MAC-PENGUIN)

MACTOOLS += $(TOOLS_MAC)/penguin.hfs $(TOOLS_MAC)/Penguin-19.hqx
endif


TOOLS = $(ATARITOOLS) $(AMIGATOOLS) $(MACTOOLS)
