#
# Makefile for testtok, part of m5.
# to be modified as m5 matures.

# uncomment this definition if you are using PGCC!
PGCC=1

CC = gcc
RM = del
ZIP = pkzip
CX = copy


EXPDIR = E:\newlook\


###
BASEDIR = D:\kei\c99\m5\

#OBJ = obj/djgpp
#LIBDEST = $(KEIDIR)/lib/
DJP = $(DJDIR)/bin/djp.exe

WFLAGS = -Wall -W -Werror -Wno-unused
#WFLAGS = -Wall -pedantic -W -Werror -Wno-unused
#WFLAGS = 

ifdef PGCC
OFLAGS = -mpentium -O6 -ffast-math -fomit-frame-pointer
else
OFLAGS = -m486 -O3 -ffast-math -fomit-frame-pointer
endif

#CFLAGS = -I. -I$(OBJ) $(WFLAGS) $(OFLAGS)
CFLAGS = -I. $(WFLAGS) $(OFLAGS)
#CFLAGS = -I. -I$(BASEDIR) $(WFLAGS) $(OFLAGS)


# targets.

wilson: muhahahahaha

muhahahahaha: mness tide vtest mism

all : mness

vtest: vtest.o screen.o rendlib.o foolib.o
	$(CC) vtest.o screen.o rendlib.o foolib.o -o vtest.exe -lalleg

tide: idetest.o screen.o rendlib.o foolib.o 
	$(CC) idetest.o screen.o rendlib.o foolib.o -o tide.exe -lalleg

mness: m5ness.o m1imp.o rendlib.o foolib.o parser.o screen.o
	$(CC) m5ness.o m1imp.o parser.o rendlib.o screen.o foolib.o -o mness.exe -lalleg

#later on I'll trade mness and mism or something...
# mism -> mness as time -> y2k.

mism: m5ism.o m1imp.o rendlib.o foolib.o parser.o screen.o st.o tokparse.o
	$(CC) m5ism.o st.o m1imp.o parser.o rendlib.o screen.o foolib.o tokparse.o -o mism.exe -lalleg

exmness: mnesszip
	$(CX) mness.zip $(EXPDIR)
	$(CX) mnesssrc.zip $(EXPDIR)


bisex : bisex.o 
	$(CC) bisex.o -o bisex.exe -lnet

testtok : testtok.o toklib.o toklist.o Trim.o
	$(CC) testtok.o toklib.o toklist.o Trim.o -o testtok.exe -lalleg

pack: m5
	$(DJP) m5.exe


distclean : veryclean
veryclean : spank
# as in "Spanking clean"
spank : clean
	$-echo "Cleaning up executable files..."
	$(RM) *.exe
	$-echo "Done. Now the place looks spanking clean!"

clean :
	$-echo "Cleaning up object files..."
	$(RM) *.o
	$-echo "Done claning unnecessary object files."

.c.o:
	@-echo "Making component -> $*.o"
	$(CC) $(CFLAGS) -c $<
#	$(CC)  $<

# now for the zip files

dist : zip
# dist is for distribution. note that log files are not included,
# as they only contain either (1) debugging info or (2) random personal
# thought about the project.

zip : srczip binzip datzip

datzip :
	$(ZIP) charset.zip char.rom

binzip : 
	$(ZIP) m5b.zip m5.exe readme.txt usage.txt testin.txt char.rom

srczip :
	$(ZIP) m5s.zip *.c *.h *.txt makefile

chipzip :
	$(ZIP) chip.zip *.c *.h *.exe *.txt makefile

mnesszip : mness
	$(DJP) mness.exe
	$(ZIP) mness.zip mness.exe readme.txt nessuse.txt testin.txt mautorun.txt
	$(ZIP) mnesssrc.zip m5ness.c screen.o rendlib.o parser.h parser.c foolib.c
	$(ZIP) mnesssrc.zip foolib.h rendlib.h screen.h nessuse.txt testin.txt
	$(ZIP) mnesssrc.zip mautorun.txt makefile mdefcon.h m1imp.h m1imp.c


m5ish: vtest
	$(DJP) vtest.exe
	$(ZIP) m5ish.zip vtest.exe rendlib.c rendlib.h mdefcon.h


extide: tide
	$(DJP) tide.exe
	$(ZIP) tide.zip tide.exe idetest.c
	$(CX) tide.zip $(EXPDIR)

# exporting to newlook...
exbin : binzip
	$(CX) m5b.zip $(EXPDIR)

exsrc : srczip
	$(CX) m5s.zip $(EXPDIR)

exdat : datzip
	$(CX) charset.zip $(EXPDIR)

exchip : chipzip
	$(CX) chip.zip $(EXPDIR)

exm5ish : m5ish
	$(CX) m5ish.zip $(EXPDIR)



export : exall
exall : exbin exsrc exdat

# dependencies go here. Do not delete!!!

Trim.o : Trim.c
toklib.o : toklist.c
toklist.o : toklist.c
testtok.o : testtok.c

screen.o : screen.c screen.h
rendlib.o : rendlib.c rendlib.h
vtest.o : vtest.c
foolib.o : foolib.c foolib.h

m5ness.o : m5ness.c
m1imp.o : m1imp.c m1imp.h
parser.o : parser.c parser.h

bisex.o : bisex.c
idetest.o : idetest.c

# zip dependancies. I now love GNU make. It's touchy but stable.

datzip : char.rom
binzip : testtok.exe 
srczip : *.c *.h *.txt makefile

# I can use make!!! Muhahahhaha!
