# This is a ztom's Makefile, mainly for SHARP X680x0.
# If you want to compile in other enviroments,
# please modify 'Makefile' and 'config.h.'
#
#SET MARIKO=A,GCC_OPTION=EFGLOPTW,HAS=-l,SILK=-t -l -x


#OS			= X68000				# for SHARP X680x0 series with gcc
#OS			= TOWNS					# for FUJITSU FM-TOWNS series with High-C */
#OS			= LSIC86				# for MS-DOS LSI-C */
OS			= BCB					# for Windows95/NT(x86) with Borland C++ Builder */
#OS			= Linux_i386
#OS			= Solaris_UltraSPARC
#OS			= FreeBSD
#OS			= SunOS41x_SPARC
# If you choose UNIXY-OS, please check "config.h" too.
# (You have to select whether the libc supports "memmove" or not.)


RM			= del			# for MS-DOS,Human68k,...
#RM			= rm			# for unix

#CC			= gcc			# for Human68k, PC-UNIX & so on...
#CC			= lcc			# for LSI-C
CC			= bcc32			# for Borland C++ Builder

#CFLAGS		= -c -O
CFLAGS		= -c -O -A -d		# for C++ Builder
#OPTION		= -fforce-mem -finline-functions	# for GCC
#LIBS		= -ldos			# check off this remark if you use DOS-lib.(X680x0 only)
INCDIR		= -I.
#MACRO		= -DXCLIB		# use XC library(X680x0 only)
#MACRO		= -DENGLISH		# change messages into English. default is in Japanese.

#OEXT		= .o			# for Human68k,unix,...
OEXT		= .obj			# for MS-DOS
#EEXT		= .x			# for Human68k
EEXT		= .exe			# for MS-DOS
#EEXT		=				# for unix
TARGET		= ztom$(EEXT)

OBJS   = z$(OEXT) makeMThd$(OEXT) makeMTr0$(OEXT) makeMTrk$(OEXT) VarLen$(OEXT) Putcode$(OEXT) zmscinit$(OEXT) options$(OEXT)
OBJS2  = keyonoff$(OEXT) instload$(OEXT) Panpot$(OEXT) bend$(OEXT) tempo$(OEXT) etc$(OEXT) bulkdump$(OEXT) sync$(OEXT) 68lib$(OEXT) readfile$(OEXT) debugcmd$(OEXT)

$(TARGET) : $(OBJS) $(OBJS2)
#	$(CC) -o $@ $(OBJS) $(OBJS2) $(LIBS)
	$(CC) -e$@ $(OBJS) $(OBJS2) $(LIBS)		# for C++ Builder
.c$(OEXT) :
	$(CC) $(CFLAGS) $(OPTION) $(INCDIR) -D$(OS) $(MACRO) $<




z$(OEXT)        : z.c config.h MThdINFO.h makeMThd.h makeMTr0.h makeMTrk.h options.h instload.h etc.h sync.h tempo.h debugcmd.h
makeMThd$(OEXT) : config.h makeMThd.c etc.h
makeMTr0$(OEXT) : config.h makeMTr0.c MThdINFO.h VarLen.h zmscinit.h bulkdump.h tempo.h
makeMTrk$(OEXT) : config.h makeMTrk.c MThdINFO.h VarLen.h Putcode.h zmscinit.h keyonoff.h Panpot.h bend.h structs.h etc.h tempo.h
Putcode$(OEXT)  : config.h Putcode.c VarLen.h
Panpot$(OEXT)   : config.h Panpot.c Putcode.h
zmscinit$(OEXT) : config.h zmscinit.c Putcode.h
options$(OEXT)  : config.h options.c MThdINFO.h 68lib.h etc.h structs.h tempo.h
instload$(OEXT) : config.h instload.c MThdINFO.h etc.h
keyonoff$(OEXT) : config.h keyonoff.c Putcode.h VarLen.h structs.h bend.h
bend$(OEXT)     : config.h bend.c Putcode.h VarLen.h
tempo$(OEXT)    : config.h tempo.c VarLen.h
bulkdump$(OEXT) : config.h bulkdump.c VarLen.h etc.h
sync$(OEXT)     : config.h sync.c structs.h etc.h VarLen.h etc.h
VarLen$(OEXT)   : config.h VarLen.c
etc$(OEXT)      : config.h etc.c
structs.h       : config.h
68lib$(OEXT)    : config.h 68lib.c
68lib.h         : config.h
readfile$(OEXT) : config.h readfile.c etc.h MThdINFO.h
debugcmd$(OEXT) : config.h debugcmd.c structs.h etc.h VarLen.h


all:	$(TARGET)

clean:
	$(RM) *$(OEXT)
	$(RM) $(TARGET)
	$(RM) *.bak
#	$(RM) *~

cleanbak:
	$(RM) *.bak
#	$(RM) *~

depend:
	$(CC) -MM $(INCDIR) $(SRCS)



# for yyagi's convenience
archive:	# for yyagi's convenience
		# for DOS only! (as -z1 switch is not supported in UNIX lha)
#	lha a -z1 srcs.lzh source.txt *.c *.h makefile
#	lha a ztom.lzh ztom.txt ztomhis.txt seigen.txt ztomman.txt ztom.x ztom.exe srcs.lzh
		# if you use unix-LHA, you should use -g switch to extract.
		# e.g. > lha -xg srcs.lzh
	zip -0 srcs.zip source.txt *.c *.h makefile
	zip -9 ztom.zip ZtoM.txt ZtoMhis.txt seigen.txt ztomman.txt ztom.x ztom.exe srcs.zip

