#TargetD64 makefile
#(c) 1999 Karlheinz Langguth under the terms of GPL
#TargetD64 homepage at
#http://skyscraper.fortunecity.com/quadra/251/targetd64.html
#Contact the author by mailto:klangguth@netscape.net
#
#Sorry, no configure - actually there is not much to configure
#This makefile is tested on SuSE linux 6.0 with
#gcc version egcs-2.91.57 19980901 (egcs-1.1 release).
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

VERSION=0_3

#compile switches for TargetD64 original sources
CXXFLAGS = -c -g -I $(ZLIB_SRCDIR) -I$(VICE_SRCDIR) -I$(LHA_SRCDIR) -I$(GUI_SRCDIR) \
-DTD64_MODIFIED -D_DEBUG -pedantic-errors -pedantic
#compile switches for VICE sources
CXXFLAGS_VICE = $(CXXFLAGS) -I$(SRCDIR)
#compile switches for zlib and lha sources
CCFLAGS = -c -g -DTD64_MODIFIED -D_DEBUG
#link switches
LDFLAGS =  -g 

#TargetD64 source directory
SRCDIR=../src
#VICE source directory
VICE_SRCDIR=../src_foreign/VICE
#Zlib source directory
ZLIB_SRCDIR=../src_foreign/zlib
#lha source directory
LHA_SRCDIR=../src_foreign/lha
#GUI source directory
GUI_SRCDIR=../src/linux
#distribution directory (to produce a distribution into)
DISTDIR=../distribution
#testsuite directory
TSTDIR=../testsuite

#this will include all the configuration specific variables
#the previous defined variables are (partially) overwritten
#it differs for debug, trace, release configuration
sinclude makefile.inc


ZLIB_HEADERS = \
$(ZLIB_SRCDIR)/infblock.h \
$(ZLIB_SRCDIR)/inffast.h \
$(ZLIB_SRCDIR)/inftrees.h \
$(ZLIB_SRCDIR)/unzip.h  \
$(ZLIB_SRCDIR)/zlib.h \
$(ZLIB_SRCDIR)/infcodes.h \
$(ZLIB_SRCDIR)/inffixed.h \
$(ZLIB_SRCDIR)/infutil.h \
$(ZLIB_SRCDIR)/zconf.h \
$(ZLIB_SRCDIR)/zutil.h

LHA_HEADERS = \
$(LHA_SRCDIR)/intrface.h \
$(LHA_SRCDIR)/lharc.h \
$(LHA_SRCDIR)/slidehuf.h


#objects to link together
OBJS = TargetD64.o \
	   Options.o \
	   Profile.o \
	   Archive.o \
	   C64Archive.o \
	   HostArchive.o \
	   Tracing.o \
	   Exception.o \
	   MultiPart.o \
	   DiskImage.o \
	   TapeImage.o \
	   LynxImage.o \
	   Image.o \
	   ZlibAdapter.o \
	   GUI.o \
	   c1541.o \
	   zipcode.o \
	   adler32.o \
	   crc32.o \
	   gzio.o \
	   infblock.o \
	   infcodes.o \
	   inffast.o \
	   inflate.o \
	   inftrees.o \
	   infutil.o \
	   unzip.o \
	   zutil.o \
	   crcio.o \
	   dhuf.o \
	   extract.o \
	   header.o \
	   huf.o \
	   larc.o \
	   lharc.o \
	   lhext.o \
	   maketbl.o \
	   shuf.o \
	   slide.o \
	   util.o


local: targetd64 

TargetD64.o: $(SRCDIR)/TargetD64.cpp \
	$(SRCDIR)/Application.h\
	$(SRCDIR)/Archive.h\
	$(SRCDIR)/DiskImage.h\
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/HostArchive.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/Options.h\
	$(SRCDIR)/Profile.h\
	$(SRCDIR)/TargetD64.h\
	$(SRCDIR)/Tracing.h\
	$(GUI_SRCDIR)/GUI.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/TargetD64.cpp

Options.o: $(SRCDIR)/Options.cpp \
	$(SRCDIR)/Options.h\
	$(SRCDIR)/Tracing.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/Options.cpp

Profile.o: $(SRCDIR)/Profile.cpp \
	$(SRCDIR)/Profile.h\
	$(SRCDIR)/Tracing.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/Profile.cpp

Archive.o: $(SRCDIR)/Archive.cpp \
	$(SRCDIR)/Archive.h\
	$(SRCDIR)/C64Archive.h\
	$(SRCDIR)/DiskImage.h\
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/HostArchive.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/MultiPart.h\
	$(SRCDIR)/Options.h\
	$(SRCDIR)/Profile.h\
	$(SRCDIR)/TargetD64.h\
	$(SRCDIR)/Tracing.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/Archive.cpp

C64Archive.o: $(SRCDIR)/C64Archive.cpp \
	$(SRCDIR)/Archive.h\
	$(SRCDIR)/C64Archive.h\
	$(SRCDIR)/DiskImage.h\
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/LynxImage.h\
	$(SRCDIR)/MultiPart.h\
	$(SRCDIR)/TapeImage.h\
	$(SRCDIR)/Tracing.h\
	$(VICE_SRCDIR)/vdrive.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/C64Archive.cpp

HostArchive.o: $(SRCDIR)/HostArchive.cpp \
	$(SRCDIR)/Archive.h\
	$(SRCDIR)/C64Archive.h\
	$(SRCDIR)/DiskImage.h\
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/HostArchive.h\
	$(SRCDIR)/Image.h\
	$(LHA_SRCDIR)/lharc.h\
	$(SRCDIR)/MultiPart.h\
	$(SRCDIR)/Tracing.h\
	$(SRCDIR)/ZlibAdapter.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/HostArchive.cpp

MultiPart.o: $(SRCDIR)/MultiPart.cpp \
	$(SRCDIR)/Archive.h\
	$(SRCDIR)/DiskImage.h\
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/MultiPart.h\
	$(SRCDIR)/Tracing.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/MultiPart.cpp

Tracing.o: $(SRCDIR)/Tracing.cpp \
	$(SRCDIR)/Tracing.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/Tracing.cpp
	
Exception.o: $(SRCDIR)/Exception.cpp \
	$(SRCDIR)/Exception.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/Exception.cpp
	
Image.o: $(SRCDIR)/Image.cpp \
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/Tracing.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/Image.cpp
	
DiskImage.o: $(SRCDIR)/DiskImage.cpp \
	$(SRCDIR)/DiskImage.h\
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/Tracing.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/DiskImage.cpp
	
TapeImage.o: $(SRCDIR)/TapeImage.cpp \
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/TapeImage.h\
	$(SRCDIR)/Tracing.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/TapeImage.cpp
	
LynxImage.o: $(SRCDIR)/LynxImage.cpp \
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/LynxImage.h\
	$(SRCDIR)/Tracing.h\
	$(VICE_SRCDIR)/vdrive.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/LynxImage.cpp
	
ZlibAdapter.o: $(SRCDIR)/ZlibAdapter.cpp \
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/Tracing.h\
	$(ZLIB_SRCDIR)/unzip.h\
	$(ZLIB_SRCDIR)/zconf.h\
	$(ZLIB_SRCDIR)/zlib.h\
	$(SRCDIR)/ZlibAdapter.h
	$(CXX) $(CXXFLAGS) $(SRCDIR)/ZlibAdapter.cpp

#GUI sources
GUI.o: $(GUI_SRCDIR)/GUI.cpp $(GUI_SRCDIR)/GUI.h
	$(CXX) $(CXXFLAGS) $(GUI_SRCDIR)/GUI.cpp

#VICE sources
c1541.o: $(VICE_SRCDIR)/c1541.cpp \
	$(SRCDIR)/Exception.h\
	$(SRCDIR)/Image.h\
	$(SRCDIR)/LynxImage.h\
	$(VICE_SRCDIR)/vdrive.h\
	$(VICE_SRCDIR)/zipcode.h
	$(CXX) $(CXXFLAGS_VICE) $(VICE_SRCDIR)/c1541.cpp
	
zipcode.o: $(VICE_SRCDIR)/zipcode.cpp \
	$(VICE_SRCDIR)/zipcode.h
	$(CXX) $(CXXFLAGS_VICE) $(VICE_SRCDIR)/zipcode.cpp



#Zlib sources
adler32.o: $(ZLIB_SRCDIR)/adler32.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/adler32.c 	
		
crc32.o: $(ZLIB_SRCDIR)/crc32.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/crc32.c 	
		
gzio.o: $(ZLIB_SRCDIR)/gzio.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/gzio.c 	
		
infblock.o: $(ZLIB_SRCDIR)/infblock.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/infblock.c 	
		
infcodes.o: $(ZLIB_SRCDIR)/infcodes.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/infcodes.c 	
		
inffast.o: $(ZLIB_SRCDIR)/inffast.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/inffast.c 	
		
inflate.o: $(ZLIB_SRCDIR)/inflate.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/inflate.c 	
		
inftrees.o: $(ZLIB_SRCDIR)/inftrees.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/inftrees.c 	
		
infutil.o: $(ZLIB_SRCDIR)/infutil.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/infutil.c 	
		
unzip.o: $(ZLIB_SRCDIR)/unzip.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/unzip.c 	
		
zutil.o: $(ZLIB_SRCDIR)/zutil.c $(ZLIB_HEADERS)
	$(CC) $(CCFLAGS) $(ZLIB_SRCDIR)/zutil.c 	


#Lha sources
crcio.o: $(LHA_SRCDIR)/crcio.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/crcio.c   

dhuf.o: $(LHA_SRCDIR)/dhuf.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/dhuf.c   

extract.o: $(LHA_SRCDIR)/extract.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/extract.c   

header.o: $(LHA_SRCDIR)/header.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/header.c   

huf.o: $(LHA_SRCDIR)/huf.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/huf.c   

larc.o: $(LHA_SRCDIR)/larc.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/larc.c   

lharc.o: $(LHA_SRCDIR)/lharc.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/lharc.c   

lhext.o: $(LHA_SRCDIR)/lhext.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/lhext.c   

maketbl.o: $(LHA_SRCDIR)/maketbl.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/maketbl.c   

shuf.o: $(LHA_SRCDIR)/shuf.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/shuf.c   

slide.o: $(LHA_SRCDIR)/slide.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/slide.c   
		
util.o: $(LHA_SRCDIR)/util.c $(LHA_HEADERS)
	$(CC) $(CCFLAGS) $(LHA_SRCDIR)/util.c 	



targetd64: $(OBJS)
	$(CXX) $(LDFLAGS) -o targetd64 $(OBJS)


always:

distribution: targetd64 always 
	sed -e "/^#ifdef LINUX/,/^#endif/ d" -e "/#ifdef/ d" -e "/#endif/ d" \
	$(DISTDIR)/Targetd64Doc.txt >$(DISTDIR)/MANUAL.WIN32
	sed -e "s/.$$//" \
	-e "/^#ifdef WIN32/,/^#endif/ d" -e "/#ifdef/ d" -e "/#endif/ d" \
	$(DISTDIR)/Targetd64Doc.txt >$(DISTDIR)/MANUAL
	cd $(TSTDIR); \
	sed "s/$$/`echo -n -e "\r"`/" README >README.WIN32; \
	tar cfz td64test.tgz *.OK README* *bytes *bytes[1-9] \
	    [1-4][^0-9]* *.p00 *.d00 \
	    *.s00 *.u00 *.lnx *.d64 *.x64 *.t64 *.zip *.gz *.lha \
	    *.Z *.tar test.sh test.bat
	mv $(TSTDIR)/td64test.tgz $(DISTDIR)/td64test_$(VERSION).tgz
	cp targetd64 $(DISTDIR)
	sed "s/$$/`echo -n -e "\r"`/" $(DISTDIR)/README >$(DISTDIR)/README.WIN32; \
	strip $(DISTDIR)/targetd64
	cd $(DISTDIR) && tar cvfz targetd64_bin_linux_i386_$(VERSION).tgz targetd64 \
	README MANUAL COPYING .targetd64rc targetd64.xpm sample.lnx.gz sample.zip
	cd ../.. && tar cvfz targetd64/distribution/targetd64_src_$(VERSION).tgz \
	targetd64/README* targetd64/COPYING targetd64/TargetD64.* \
	targetd64/src targetd64/src_foreign \
	targetd64/obj_dbg/makefile* targetd64/obj_rel/makefile* \
	targetd64/obj_trc/makefile* \
	targetd64/distribution/sample.* \
	targetd64/distribution/Targetd64Doc.txt \
	targetd64/distribution/.targetd64rc \
	targetd64/distribution/MANUAL* \
	targetd64/distribution/README* \
	targetd64/distribution/*.xpm
	
	

cleanup:
	rm -f *.o targetd64
