#
# Makefile for the New Arcade Graphics Editor (AGE 2 / New Age / Turaco)
#
#  Written by Ivan Mackintosh (ivan@rcp.co.uk)
#         and Scott "Jerry" Lawrence (jerry@mail.csh.rit.edu)
#


# if you're using DEGUI, this next line should read:
#   LIBS = -ldegui -lalleg
# if you don't want to use DEGUI, the next line should read:
#   LIBS = -lalleg

LIBS = -lalleg -ldegui

# also if you're using degui, the following line should read:
#  DEGUI = -DUSE_DEGUI
# otherwise remove the line

DEGUI = -DUSE_DEGUI


# the name of the .zip files
SOURCE_ZIP = nage_bak.zip

OLD_SOURCE_ZIP = nage_old.zip

# distributions
DISTZIP = turaco10.zip

DRIVZIP = driver10.zip


#
# Compiler flags
#

# first the flags that are the same for all configurations...
SFLAGS = -m486 -s -Wall -Iinclude

# now the specific ones... (uncomment your favorite)
# 
#CFLAGS = $(SFLAGS)
#  yields big executable (and compiles the fastest!)
#
#CFLAGS = $(SFLAGS) -O3 -finline-functions -funroll-all-loops -fomit-frame-pointer 
#  yields smaller executable
#
#CFLAGS = $(SFLAGS) -O3 
#  yields even smaller executable
#
CFLAGS = $(SFLAGS) -O2 -fomit-frame-pointer
#  yields still yet smaller executable
#
# -O2 is great for size reduction, -O3 turns on -finline-functions
#  which chews up lotsa space for the executable.  
#  Since it doesn't need to be superfast, -O2 should be enough


OBJS = \
	gui/bitmaped.o \
	gui/sprtplte.o \
	gui/guipal.o \
	gui/button.o \
	gui/drivsel.o \
	gui/util.o \
	src/main.o \
	src/list.o \
	src/dlg.o \
	src/config.o \
	src/snap.o \
	src/editmenu.o \
	src/toolmenu.o \
	src/editmode.o \
	src/help.o \
	src/sprite.o \
	src/fileio.o \
	src/palette.o \
	src/texted.o \
	src/maped.o \
	src/inidriv.o \
	src/gamedesc.o \
	src/coding.o


all: turaco.exe

# build the main executable:
turaco.exe: $(OBJS) $(MAPED) 
	gcc -g -o turaco.exe $(OBJS) $(LIBS)
	
%.o:   %.c 
	gcc $(CFLAGS) $(DEGUI) -c -o $@ $<


# I streamlined this a bit.  DJP is not required anymore, as it gets
# compressed with pkzip.  I also removed the whole distrib dir.  It's not
# really necessary.
driverzip: 
	pkzip -ex -rP $(DRIVZIP) drivers\*.*

distrib: driverzip clean turaco.exe
	strip turaco.exe
	pkzip -ex $(DISTZIP) turaco.exe
	pkzip -ex $(DISTZIP) turaco.ini
	pkzip -ex $(DISTZIP) txt\whatsnew*.txt
	pkzip -ex $(DISTZIP) txt\readme*.txt

# clean target
clean:
	if exist gui\*.o del gui\*.o
	if exist src\*.o del src\*.o
	if exist snapshot\*.pcx del snapshot\*.pcx
	if exist turaco.exe del turaco.exe
	if exist $(DISTZIP) rm $(DISTZIP)
	if exist $(DRIVZIP) rm $(DRIVZIP)

# if you don't have the unix-style commands: rm, mv, cp, you need to 
# get them from the File Utils package available at any DJGPP/GCC 
# distribution site..   ya need them for this part...
backup: clean
	if exist \zip\$(OLD_SOURCE_ZIP) del \zip\$(OLD_SOURCE_ZIP)
	if exist \zip\$(SOURCE_ZIP) copy \zip\$(SOURCE_ZIP) \zip\$(OLD_SOURCE_ZIP)
	if exist \zip\$(SOURCE_ZIP) del \zip\$(SOURCE_ZIP)
	pkzip -rp -ex \zip\$(SOURCE_ZIP) *.*

# make a backup onto a floppy disk 
#   -- good for develpment on multiple machines
floppy: backup
	if exist a:\$(SOURCE_ZIP) del a:\$(SOURCE_ZIP)
	copy \zip\$(SOURCE_ZIP) a:\


# and another two so I can start it going as I get a bite
# to eat from the kitchen...

# clean, backup, then regenerate the executable
lunch: backup turaco.exe

# clean, backup, backup to floppy, then regenerate the executable
dinner: floppy turaco.exe

# clean, backup, backup to floppy, executable, distrib (the whole shebang)
wholeshebang: floppy distrib
	if exist a:\$(DISTZIP) del a:\$(DISTZIP)
	if exist a:\$(DRIVZIP) del a:\$(DRIVZIP)
	mv $(DISTZIP) $(DRIVZIP) a:


