# only need to compile netscript with a single command, so this isn't going to
# look typical.
CC=gcc
ECHO=echo
RM=rm
CHMOD=chmod

all:
	@$(ECHO) "Usage: make <platform>, or <function>"
	@$(ECHO) "* where <platform> is: linux, bsd, obsd, irix, sunos, or generic."
	@$(ECHO) "* where <platform> is: nlinux, nbsd, nobsd, nirix, or nsunos. (ncurses)"
	@$(ECHO) "* where <platform> is: glinux, gbsd, gobsd, girix, or gsunos. (gui)"
	@$(ECHO) "* where <platform> is: gnlinux, gnbsd, gnobsd, gnirix, or gnsunos. (gui+ncurses)"
	@$(ECHO) "* where <function> is: clean."

# for the ./automake support. (using uname)
Linux: linux
FreeBSD: bsd
NetBSD: bsd
OpenBSD: obsd
BSD/OS: bsd
IRIX: irix
SunOS: sunos
# for any confusion.
Solaris: sunos
solaris: sunos
NLinux: nlinux
NFreeBSD: nbsd
NNetBSD: nbsd
NOpenBSD: nobsd
NBSD/OS: nbsd
NIRIX: nirix
NSunOS: nsunos
NSolaris: nsunos
Nsolaris: nsunos
GLinux: glinux
GFreeBSD: gbsd
GNetBSD: gbsd
GOpenBSD: gobsd
GBSD/OS: gbsd
GIRIX: girix
GSunOS: gsunos
GSolaris: gsunos
Gsolaris: gsunos
GNLinux: gnlinux
GNFreeBSD: gnbsd
GNNetBSD: gnbsd
GNOpenBSD: gnobsd
GNBSD/OS: gnbsd
GNIRIX: gnirix
GNSunOS: gnsunos
GNSolaris: gnsunos
GNsolaris: gnsunos

# the make functions, mostly minor differences.
linux:
	@$(ECHO) "* Compiling linux-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared
	@$(CC) nssound.c -o nssound -shared

nlinux:
	@$(ECHO) "* Compiling NCURSES-linux-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared -DNCURSES
	@$(CC) nssound.c -o nssound -shared

glinux:
	@$(ECHO) "* Compiling GTK-linux-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared -DGTK
	@$(CC) nssound.c -o nssound -shared

gnlinux:
	@$(ECHO) "* Compiling GTK-NCURSES-linux-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared -DGTK -DNCURSES
	@$(CC) nssound.c -o nssound -shared

bsd:
	@$(ECHO) "* Compiling bsd-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared
	@$(CC) nssound.c -o nssound -shared

nbsd:
	@$(ECHO) "* Compiling NCURSES-bsd-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared -DNCURSES
	@$(CC) nssound.c -o nssound -shared

gbsd:
	@$(ECHO) "* Compiling GTK-bsd-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared -DGTK
	@$(CC) nssound.c -o nssound -shared

gnbsd:
	@$(ECHO) "* Compiling GTK-NCURSES-bsd-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared -DGTK -DNCURSES
	@$(CC) nssound.c -o nssound -shared

obsd:
	@$(ECHO) "* Compiling bsd-variant style modules..."
	@$(CC) -c nsansi.c -o nsansi
	@$(CC) -c nssound.c -o nssound

nobsd:
	@$(ECHO) "* Compiling NCURSES-bsd-variant style modules..."
	@$(CC) -c nsansi.c -o nsansi -DNCURSES
	@$(CC) -c nssound.c -o nssound

gobsd:
	@$(ECHO) "* Compiling GTK-bsd-variant style modules..."
	@$(CC) -c nsansi.c -o nsansi -DGTK
	@$(CC) -c nssound.c -o nssound

gnobsd:
	@$(ECHO) "* Compiling GTK-NCURSES-bsd-variant style modules..."
	@$(CC) -c nsansi.c -o nsansi -DGTK -DNCURSES
	@$(CC) -c nssound.c -o nssound

irix:
	@$(ECHO) "* Compiling irix-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared
	@$(CC) nssound.c -o nssound -shared

nirix:
	@$(ECHO) "* Compiling NCURSES-irix-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared -DNCURSES
	@$(CC) nssound.c -o nssound -shared

girix:
	@$(ECHO) "* Compiling GTK-irix-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared -DGTK
	@$(CC) nssound.c -o nssound -shared

gnirix:
	@$(ECHO) "* Compiling GTK-NCURSES-irix-variant style modules..."
	@$(CC) nsansi.c -o nsansi -shared -DGTK -DNCURSES
	@$(CC) nssound.c -o nssound -shared

sunos:
	@$(ECHO) "* Compiling sunos-variant style modules..."
	@$(CC) -c nsansi.c -o nsansi
	@$(CC) -c nssound.c -o nssound

nsunos:
	@$(ECHO) "* Compiling NCURSES-sunos-variant style modules..."
	@$(CC) -c nsansi.c -o nsansi -DNCURSES
	@$(CC) -c nssound.c -o nssound

gsunos:
	@$(ECHO) "* Compiling GTK-sunos-variant style modules..."
	@$(CC) -c nsansi.c -o nsansi -DGTK
	@$(CC) -c nssound.c -o nssound

gnsunos:
	@$(ECHO) "* Compiling GTK-NCURSES-sunos-variant style modules..."
	@$(CC) -c nsansi.c -o nsansi -DGTK -DNCURSES
	@$(CC) -c nssound.c -o nssound

generic:
	@$(ECHO) "* Compiling generic style modules..."
	@$(CC) nsansi.c -o nsansi -shared
	@$(CC) nssound.c -o nssound -shared

clean:
	@$(ECHO) "* Cleaning local netscript module file(s)..."
	@$(RM) -rf nsansi nssound
