BUILD_OPTS = GOOS=windows GOARCH=amd64
BUILD = ${BUILD_OPTS} go build
EXT = .exe

all: door32${EXT} testdoor/testdoor${EXT} space-ace/space-ace${EXT} yt2000/yt2000${EXT} mines/mines${EXT}

mines/mines: mines/*.go
	cd mines; ${BUILD}

# The old utility:
# font-out: font-out.go
#	go build font-out.go
#	cd font-show; go build

# font-util does it all! show, extract, list
font-util/font-util:
	cd font-util; ${BUILD}

door32${EXT}: door32.go convert.go
	${BUILD_OPTS} go build door32.go convert.go

# door32: door32.c
#	gcc -g -o door32d door32.c
#	gcc -o door32 door32.c

testdoor/fonts.go: font-util/font-util
	./font-util/font-util extract -f "Amazon Cyan,Anarchy Blue,Unchained,Asylum,ArmageonRed,BrainDmgBlu,Boner,Descent,Remorse,Dungeon" TDFONTS.TDF TDFONTS2.TDF TDFONTS9.TDF > testdoor/fonts.go

# Extract font, change colors, rename font to RedGreen.
testdoor/rgfont.go: font-util/font-util
	./font-util/font-util extract -f Armageddon -c 7,1 -c 4,2 TDFONTS2.TDF > testdoor/rgfont.go
	sed -i 's/Armageddon/RedGreen/g' testdoor/rgfont.go

ansi-to-go/ansi-to-go: ansi-to-go/ansi-to-go.go
	cd ansi-to-go; ${BUILD}

testdoor/art.go: testdoor/growl.ans ansi-to-go/ansi-to-go
	./ansi-to-go/ansi-to-go testdoor/growl.ans > testdoor/art.go

space-ace/space.go: space-ace/space.ans
	./ansi-to-go/ansi-to-go space-ace/space.ans > space-ace/space.go
	
# ./ansi-to-go.py main space.ans > space-ace/space.go

testdoor/testdoor${EXT}: testdoor/art.go testdoor/fonts.go testdoor/rgfont.go testdoor/*.go door/*.go
	cd testdoor; ${BUILD}

# This builds just for amd64.  (I might not be amd64...)
# cd testdoor; GOOS=linux GOARCH=amd64 go build

# Build a windows exe, because we can!
# testdoor/testdoor.exe: testdoor/art.go testdoor/fonts.go testdoor/rgfont.go testdoor/*.go door/*.go
#	cd testdoor; GOOS=windows GOARCH=amd64 go build

# Build, with static link of sqlite.
space-ace/space-ace${EXT}: space-ace/*.go door/*.go space-ace/space.go
	cd space-ace; ${BUILD} -ldflags="-extldflags=-static" -tags sqlite_omit_load_extension


#	./font-out -f "Amazon Cyan,Medieval,Anarchy Blue" TDFONTS.TDF 
#	./font-out -f Unchained,Asylum,ArmageonRed,BrainDmgBlu TDFONTS2.TDF
#	./font-out -f Boner,Descent,Remorse,Dungeon TDFONTS9.TDF

yt2000/ytopen.go: yt2000/ytopen.ans
	./ansi-to-go/ansi-to-go yt2000/ytopen.ans > yt2000/ytopen.go

yt2000/cyberwar.go:
	./font-util/font-util extract -f CyberWar *.TDF > yt2000/cyberwar.go

yt2000/armagedonred.go:
	./font-util/font-util extract -f ArmagedonRed *.TDF > yt2000/armagedonred.go

yt2000/yt2000${EXT}: yt2000/yt.go yt2000/ytopen.go yt2000/cyberwar.go
	cd yt2000; ${BUILD}