#
# 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\m6\

#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: spank mness mil vtest mism bitch.exe


all : mness mil vtest mism mdefcon.h

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

mil : ident.exe 

ident.exe : idedrv.o idelib.o screen.o rendlib.o foolib.o tokparse.o parse3.o m1imp.o 
	$(CC) idedrv.o idelib.o screen.o rendlib.o foolib.o tokparse.o parse3.o m1imp.o -o ident.exe -lalleg
	$(DJP) ident.exe

bitch.exe : idedrv.o idelib.o screen.o rendlib.o foolib.o tokparse.o parse4.o m1imp.o 
	$(CC) idedrv.o idelib.o screen.o rendlib.o foolib.o tokparse.o parse4.o m1imp.o -o bitch.exe -lalleg


mness: m5ness.o m1imp.o rendlib.o foolib.o parser.o screen.o mm.o 
	$(CC) m5ness.o m1imp.o parser.o rendlib.o screen.o foolib.o mm.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)




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 : binzip datzip

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

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

mnesszip : mness
	$(DJP) mness.exe
	$(ZIP) mness.zip mness.exe readme.txt nessuse.txt testin.cas mautorun.cas
	$(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.cas
	$(ZIP) mnesssrc.zip mautorun.cas makefile mdefcon.h m1imp.h m1imp.c


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

exvtest: vtest
	$(DJP) vtest.exe
	$(ZIP) vtest.zip vtest.exe char.rom c64.sp2 vtest.txt
	$(CX) vtest.zip $(EXPDIR)

exmil: mil
	$(ZIP) ident.zip ident.exe ident.txt initide.cas ident.clg
	$(ZIP) ident.zip tokparse.txt toklist.cas
	$(ZIP) ident.zip m6casuse.txt test2.cas
	$(CX) ident.zip $(EXPDIR)

# exporting to newlook...

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

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

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



export : extide exmness exm5ish
exall : exbin exsrc exdat

# dependencies go here. Do not delete!!!


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

mm.o : mm.c mm.h
idetest.o : idetest.c

brac.o : brac.c
parse2.o : parse2.c parser.h
ide.o : ide.c

ty.o : ty.c
#--- this seems unecessary.. hmm.. must RTFM sometime.

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

datzip : char.rom
 

# I can use make!!! Muhahahhaha!
