PROGNAME_PPC = dnetc_ppc
PROGNAME_68K = dnetc_68k

DEBUG    = 
OPTIMIZE = optimize optsched
CFLAGS   = unsignedchars nostkchk strmerge parms=reg define=LESS_GETENV define=_CPU_32BIT_ define=BIT_32 define=KWAN define=MEGGS includedir=netinclude: includedir=platforms/ includedir=common/ utillib nover NOLINK
DISASM   =
LFLAGS   = #farcode fardata

DEBUG_PPC    = $(DEBUG) #DEBUG=S
OPTIMIZE_PPC = $(OPTIMIZE)
CFLAGS_PPC   = $(DEBUG_PPC) $(OPTIMIZE_PPC) $(CFLAGS) define=PIPELINE_COUNT=1 HUNKOBJ
DISASM_PPC   = $(DISASM)
LFLAGS_PPC   = $(LFLAGS)

DEBUG_68K    = $(DEBUG) #DEBUG=S
OPTIMIZE_68K = $(OPTIMIZE)
CFLAGS_68K   = $(DEBUG_68K) $(OPTIMIZE_68K) $(CFLAGS) define=PIPELINE_COUNT=2 CPU=68040 DATA=FAR CODE=FAR
DISASM_68K   = $(DISASM)
LFLAGS_68K   = $(LFLAGS)

AMIGA_OBJS_PPC =\
platforms/amiga/_tzset.o_ppc\
platforms/amiga/amiga_version.o_ppc\

COMMON_OBJS_PPC =\
common/selftest.o_ppc\
common/cmdline.o_ppc\
common/cliident.o_ppc\
common/clirate.o_ppc\
common/clisrate.o_ppc\
common/clitime.o_ppc\
common/clicdata.o_ppc\
common/client.o_ppc\
common/autobuff.o_ppc\
common/iniread.o_ppc\
common/network.o_ppc\
common/netinit.o_ppc\
common/buffbase.o_ppc\
common/mail.o_ppc\
common/convdes.o_ppc\
common/cpucheck.o_ppc\
common/pathwork.o_ppc\
common/disphelp.o_ppc\
common/logstuff.o_ppc\
common/triggers.o_ppc\
common/selcore.o_ppc\
common/guistuff.o_ppc\
common/clirun.o_ppc\
common/pollsys.o_ppc\
common/probman.o_ppc\
common/probfill.o_ppc\
common/bench.o_ppc\
common/console.o_ppc\
common/modereq.o_ppc\
common/setprio.o_ppc\
common/confrwv.o_ppc\
common/confopt.o_ppc\
common/confmenu.o_ppc

RC5_OBJS_PPC	=\
common/problem.o_ppc\
rc5/crunch_allitnil_552.ppc.o_ppc\
rc5/crunch_lintilla_296.ppc.o_ppc

DES_OBJS_PPC	=\
des/des-slice-meggs.o_ppc\
des/deseval-meggs3.o_ppc

#des/deseval.o_ppc\
#des/des-slice.o_ppc\
#des/sboxes-kwan4.o_ppc

OGR_OBJS_PPC	=\
ogr/choosedat.o_ppc\
ogr/crc32.o_ppc\
ogr/ogr.o_ppc

CSC_OBJS_PPC	=\
csc/convcsc.o_ppc\
csc/csc-common.o_ppc\
csc/csc-1k.o_ppc\
csc/csc-1k-i.o_ppc\
csc/csc-6b.o_ppc\
csc/csc-6b-i.o_ppc

EXTRA_OBJS_68K	=\
platforms/amiga/sleep.o_ppc\
platforms/amiga/usleep.o_ppc

AMIGA_OBJS_68K =\
platforms/amiga/_tzset.o_68k\
platforms/amiga/globals.o_68k\
platforms/amiga/amiga_version.o_68k\

COMMON_OBJS_68K =\
common/cliident.o_68k\
common/clirate.o_68k\
common/clisrate.o_68k\
common/clitime.o_68k\
common/clicdata.o_68k\
common/client.o_68k\
common/autobuff.o_68k\
common/iniread.o_68k\
common/network.o_68k\
common/netinit.o_68k\
common/buffbase.o_68k\
common/mail.o_68k\
common/convdes.o_68k\
common/cpucheck.o_68k\
common/pathwork.o_68k\
common/disphelp.o_68k\
common/selftest.o_68k\
common/cmdline.o_68k\
common/logstuff.o_68k\
common/triggers.o_68k\
common/selcore.o_68k\
common/guistuff.o_68k\
common/clirun.o_68k\
common/pollsys.o_68k\
common/probman.o_68k\
common/probfill.o_68k\
common/bench.o_68k\
common/console.o_68k\
common/modereq.o_68k\
common/setprio.o_68k\
common/confrwv.o_68k\
common/confopt.o_68k\
common/confmenu.o_68k

RC5_OBJS_68K	=\
common/problem.o_68k\
rc5/rc5-040_060-jg.o_68k\
rc5/rc5-000_030-jg.o_68k

DES_OBJS_68K	=\
des/des-slice-meggs.o_68k\
des/deseval-meggs3.o_68k

EXTRA_OBJS_68K	=\
platforms/amiga/sleep.o_68k\
platforms/amiga/usleep.o_68k

LIBSTART     = lib:c.o
LIBSTART_PPC = $(LIBSTART)
OBJS_PPC     = $(RC5_OBJS_PPC) $(DES_OBJS_PPC) $(OGR_OBJS_PPC) $(CSC_OBJS_PPC) $(EXTRA_OBJS_PPC) $(AMIGA_OBJS_PPC) $(COMMON_OBJS_PPC)
LIBS_PPC     = LIB:sccxxppc.lib LIB:scppc.lib #LIB:end.o

LIBSTART_68K = $(LIBSTART)
OBJS_68K     = $(COMMON_OBJS_68K) $(RC5_OBJS_68K) $(DES_OBJS_68K) $(AMIGA_OBJS_68K)# $(EXTRA_OBJS_68K)
LIBS_68K     = LIB:scm.lib LIB:sc.lib LIB:amiga.lib LIB:debug.lib

.s.o_ppc:
	ppc-amigaos-gas -m604 $< -o $@
	elf2am -o $@

.cpp.o_ppc:
	scppc RESETOPTS $(CFLAGS_PPC) $(DISASM) $< OBJNAME $@
	@rename $*.o $@ QUIET

.c.o_ppc:
	scppc RESETOPTS $(CFLAGS_PPC) $(DISASM) $< OBJNAME $@

.s.o_68k:
	asm -m2 -o$@ $<

.cpp.o_68k:
	sc RESETOPTS $(CFLAGS_68K) $(DISASM) $<
#	@delete $@ QUIET FORCE
	@rename $*.o $@ QUIET

.c.o_68k:
	sc RESETOPTS $(CFLAGS_68K) $(DISASM) $< OBJNAME $@

all: $(PROGNAME_PPC) $(PROGNAME_68K)
ppc: $(PROGNAME_PPC)
68k: $(PROGNAME_68K)

$(PROGNAME_PPC): $(OBJS_PPC)
#	ppc-amigaos-ld -r -o $(PROGNAME_PPC) $(LIBSTART_PPC) $(FINAL_OBJS_PPC) $(LIBS_PPC)
	SLINKPPC noicons with << 
PPC FROM $(LIBSTART_PPC) $(OBJS_PPC) TO $(PROGNAME_PPC) LIB $(LIBS_PPC) $(LFLAGS_PPC)
<

$(PROGNAME_68K): $(OBJS_68K)
	slink noicons with lib:utillib.with <with < (dnetc.lnk)
FROM $(LIBSTART_68K) $(OBJS_68K) TO $(PROGNAME_68K) LIB $(LIBS_68K) $(LFLAGS_68K)
<


#
# PPC Dependencies
#	
 
common_objs.o_ppc	:	$(COMMON_OBJS_PPC)
	ppc-amigaos-ld -r -o common_objs.o_ppc $(COMMON_OBJS_PPC)

core_objs.o_ppc	:	$(RC5_OBJS_PPC) $(DES_OBJS_PPC) $(OGR_OBJS_PPC) $(CSC_OBJS_PPC) 
	ppc-amigaos-ld -r -o core_objs.o_ppc $(RC5_OBJS_PPC) $(DES_OBJS_PPC) $(OGR_OBJS_PPC) $(CSC_OBJS_PPC) 

platforms/amiga/_tzset.o_ppc	:	platforms/amiga/_tzset.c
platforms/amiga/amiga_version.o_ppc	:	platforms/amiga/amiga_version.c common/client.h
common/confrwv.o_ppc	:	common/confrwv.cpp
common/confopt.o_ppc	:	common/confopt.cpp
common/confmenu.o_ppc	:	common/confmenu.cpp
common/selftest.o_ppc	:	common/selftest.cpp
common/cmdline.o_ppc	:	common/cmdline.cpp
common/cliident.o_ppc	:	common/cliident.cpp
common/clirate.o_ppc	:	common/clirate.cpp
common/clisrate.o_ppc	:	common/clisrate.cpp
common/clitime.o_ppc	:	common/clitime.cpp
common/clicdata.o_ppc	:	common/clicdata.cpp
common/client.o_ppc	:	common/client.cpp
common/autobuff.o_ppc	:	common/autobuff.cpp
common/iniread.o_ppc	:	common/iniread.cpp
common/network.o_ppc	:	common/network.cpp
common/netinit.o_ppc	:	common/netinit.cpp
common/buffbase.o_ppc	:	common/buffbase.cpp
common/mail.o_ppc	:	common/mail.cpp
common/convdes.o_ppc	:	common/convdes.cpp
common/cpucheck.o_ppc	:	common/cpucheck.cpp
common/disphelp.o_ppc	:	common/disphelp.cpp
common/pathwork.o_ppc	:	common/pathwork.cpp
common/problem.o_ppc	:	common/problem.cpp
common/logstuff.o_ppc	:	common/logstuff.cpp
common/triggers.o_ppc	:	common/triggers.cpp
common/selcore.o_ppc	:	common/selcore.cpp
common/guistuff.o_ppc   :       common/guistuff.cpp 
common/clirun.o_ppc     :       common/clirun.cpp
common/pollsys.o_ppc    :       common/pollsys.cpp
common/probman.o_ppc    :       common/probman.cpp
common/probfill.o_ppc   :       common/probfill.cpp
common/bench.o_ppc      :       common/bench.cpp
common/console.o_ppc    :       common/console.cpp
common/setprio.o_ppc    :       common/setprio.cpp
common/modereq.o_ppc    :       common/modereq.cpp

# RC5 Dependencies

rc5/crunch_allitnil_552.ppc.o_ppc	:	rc5/crunch_allitnil_552.ppc.s
rc5/crunch_lintilla_296.ppc.o_ppc	:	rc5/crunch_lintilla_296.ppc.s

# DES Dependencies

des/des-slice-meggs.o_ppc	:	des/des-slice-meggs.cpp
des/deseval-meggs3.o_ppc	:	des/deseval-meggs3.cpp

# OGR Dependencies

output/choosedat.o_ppc	:	ogr/choosedat.cpp 
output/ogr.o_ppc	:	ogr/ogr.cpp
output/crc32.o_ppc	:	ogr/crc32.cpp 

# CSC Dependencies

output/convcsc.o_ppc	:	csc/convcsc.cpp
output/csc-common.o_ppc	:	csc/csc-common.cpp
output/csc-1k-i.o_ppc	:	csc/csc-1k-i.cpp csc/csc-1key-bitslicer.cpp csc/csc-1key-driver.cpp
output/csc-1k.o_ppc	:	csc/csc-1k.cpp csc/csc-1key-bitslicer.cpp csc/csc-1key-driver.cpp
output/csc-6b-i.o_ppc	:	csc/csc-6b-i.cpp csc/csc-6bits-bitslicer.cpp csc/csc-6bits-driver.cpp
output/csc-6b.o_ppc	:	csc/csc-6b.cpp csc/csc-6bits-bitslicer.cpp csc/csc-6bits-driver.cpp

# EXTRA Dependencies

platforms/amiga/sleep.o_ppc	:	platforms/amiga/sleep.c
platforms/amiga/usleep.o_ppc	:	platforms/amiga/usleep.c

#
# 68k Dependencies
#	
 
platforms/amiga/_tzset.o_68k	:	platforms/amiga/_tzset.c
platforms/amiga/globals.o_68k	:	platforms/amiga/globals.c
platforms/amiga/amiga_version.o_68k	:	platforms/amiga/amiga_version.c common/client.h
common/confrwv.o_68k	:	common/confrwv.cpp
common/confopt.o_68k	:	common/confopt.cpp
common/confmenu.o_68k	:	common/confmenu.cpp
common/selftest.o_68k	:	common/selftest.cpp
common/cmdline.o_68k	:	common/cmdline.cpp
common/cliident.o_68k	:	common/cliident.cpp
common/clirate.o_68k	:	common/clirate.cpp
common/clisrate.o_68k	:	common/clisrate.cpp
common/clitime.o_68k	:	common/clitime.cpp
common/clicdata.o_68k	:	common/clicdata.cpp
common/client.o_68k	:	common/client.cpp
common/autobuff.o_68k	:	common/autobuff.cpp
common/iniread.o_68k	:	common/iniread.cpp
common/network.o_68k	:	common/network.cpp
common/netinit.o_68k	:	common/netinit.cpp
common/buffbase.o_68k	:	common/buffbase.cpp
common/mail.o_68k	:	common/mail.cpp
common/convdes.o_68k	:	common/convdes.cpp
common/cpucheck.o_68k	:	common/cpucheck.cpp
common/disphelp.o_68k	:	common/disphelp.cpp
common/pathwork.o_68k	:	common/pathwork.cpp
common/problem.o_68k	:	common/problem.cpp
common/logstuff.o_68k	:	common/logstuff.cpp
common/triggers.o_68k	:	common/triggers.cpp
common/selcore.o_68k	:	common/selcore.cpp
common/guistuff.o_68k	:	common/guistuff.cpp
common/clirun.o_68k     :       common/clirun.cpp
common/pollsys.o_68k    :       common/pollsys.cpp
common/probman.o_68k    :       common/probman.cpp
common/probfill.o_68k   :       common/probfill.cpp
common/bench.o_68k      :       common/bench.cpp
common/console.o_68k    :       common/console.cpp
common/setprio.o_68k    :       common/setprio.cpp
common/modereq.o_68k    :       common/modereq.cpp

# RC5 Dependencies

rc5/keycheck_opt.o_68k	:	rc5/keycheck_opt.s
rc5/cor_act.o_68k	:	rc5/cor_act.s
rc5/rc5-000_030-jg.o_68k	:	rc5/rc5-000_030-jg.s
rc5/rc5-040_060-jg.o_68k	:	rc5/rc5-040_060-jg.s

# DES Dependencies

des/des-slice-meggs.o_68k	:	des/des-slice-meggs.cpp
des/deseval-meggs3.o_68k	:	des/deseval-meggs3.cpp

# OGR Dependencies

output/choosedat.o_68k	:	ogr/choosedat.cpp 
output/ogr.o_68k	:	ogr/ogr.cpp
output/crc32.o_68k	:	ogr/crc32.cpp 

# CSC Dependencies

output/convcsc.o_68k	:	csc/convcsc.cpp
output/csc-common.o_68k	:	csc/csc-common.cpp
output/csc-1k-i.o_68k	:	csc/csc-1k-i.cpp csc/csc-1key-bitslicer.cpp csc/csc-1key-driver.cpp
output/csc-1k.o_68k	:	csc/csc-1k.cpp csc/csc-1key-bitslicer.cpp csc/csc-1key-driver.cpp
output/csc-6b-i.o_68k	:	csc/csc-6b-i.cpp csc/csc-6bits-bitslicer.cpp csc/csc-6bits-driver.cpp
output/csc-6b.o_68k	:	csc/csc-6b.cpp csc/csc-6bits-bitslicer.cpp csc/csc-6bits-driver.cpp

# EXTRA Dependencies

platforms/amiga/sleep.o_68k	:	platforms/amiga/sleep.c
platforms/amiga/usleep.o_68k	:	platforms/amiga/usleep.c

clean: clean_68k clean_ppc

clean_68k:
	delete common/*.o_68k rc5/*.o_68k des/*.o_68k ogr/*.o_68k csc/*.o_68k platforms/*.o_68k $(PROGNAME_68K) QUIET
clean_ppc:
	delete common/*.o_ppc rc5/*.o_ppc des/*.o_ppc ogr/*.o_ppc csc/*.o_ppc platforms/*.o_ppc $(PROGNAME_PPC) QUIET
