<?xml version="1.0" encoding="UTF-8"?>
<project name="Davex" default="all" basedir="..">
	<property name="builddir" value="${basedir}/build" />
	<property file="${builddir}/Davex.properties"/>
	<property file="${builddir}/Davex-default.properties"/>
	<property name="projdir" value="${basedir}" />
	<property name="acJar" value="${builddir}/lib/AppleCommander-1.3.5.6-ac.jar" />
	<target name="all" description="Bulid everything." depends="clean, assemble, builddsk">
	</target>
	<target name="clean">
		<!--
		Clean up everything
		-->
	</target>

	<target name="assemble" description="Assemble source.">
		<!--
		Assemble the Davex source
		-->
		<echo message="Assembling Davex source..."/>
		<exec dir="${projdir}/src" executable="${assemblerPath}/ca65">
			<arg line="-t none -l Shell/Davex.lst Shell/Davex.asm" />
		</exec>

		<echo message="Linking Davex..."/>
		<exec dir="${projdir}/src" executable="${assemblerPath}/ld65">
			<arg line="-o DAVEX.SYSTEM -m Davex.map -C Shell/Davex.cfg Shell/Davex.o" />
		</exec>

		<echo message="Assembling Davex extensions..."/>
		<exec dir="${projdir}/src/xtn" executable="${assemblerPath}/ca65">
			<arg line="-t none -l alias.lst alias.asm" />
		</exec>
		<exec dir="${projdir}/src/xtn" executable="${assemblerPath}/ca65">
			<arg line="-t none -l cal.lst cal.asm" />
		</exec>

		<echo message="Linking extensions..."/>
		<exec dir="${projdir}/src/xtn" executable="${assemblerPath}/ld65">
			<arg line="-o alias -m alias.map -C xtn.cfg alias.o" />
		</exec>
		<exec dir="${projdir}/src/xtn" executable="${assemblerPath}/ld65">
			<arg line="-o cal -m cal.map -C xtn.cfg cal.o" />
		</exec>
	</target>
	<target name="builddsk">
		<!--
		Start disk images containing the release number
		-->
		<delete file="${builddir}/Davex.dsk" />
		<copy file="${builddir}/DavexBase.dsk" tofile="${builddir}/Davex.dsk" />
		<!--
		Put the assembled programs on the disk images
		-->
		<echo message="Adding files to 5.25 disk image..."/>
		<java jar="${acJar}" fork="true" dir="${builddir}" input="${projdir}/src/DAVEX.SYSTEM">
			<jvmarg line="-Dconsole.encoding=ISO-8859-15" />
			<arg line="-p ${builddir}/Davex.dsk DAVEX sys 8192" />
		</java>
		<java jar="${acJar}" fork="true" dir="${builddir}" input="${projdir}/src/xtn/alias">
			<jvmarg line="-Dconsole.encoding=ISO-8859-15" />
			<arg line="-p ${builddir}/Davex.dsk alias p8c 8192" />
		</java>
		<java jar="${acJar}" fork="true" dir="${builddir}" input="${projdir}/src/xtn/cal">
			<jvmarg line="-Dconsole.encoding=ISO-8859-15" />
			<arg line="-p ${builddir}/Davex.dsk cal p8c 8192" />
		</java>
	</target>
</project>
