#
# 
#	Copyright (C) 2003 Hirohisa MORI joshua@nichibun.ac.jp
# 
#	This program is free software; you can redistribute it and/or
#	modify it under the terms of the GLOBALBASE General Public 
#	License as published by http://www.globalbase.org/
# 
#	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.
#
#	Usage::
#
#	mmake MACHINE=linux.redhat	for linux.redhat
#	mmake MACHINE=linux.debian	for linux.debian
#	mmake MACHINE=MacOSX		for MacOSX
#	mmake MACHINE=FreeBSD		for FreeBSD
#
#	default machine is solaris
#

@(eq,${UNAME},SunOS)	set MACHINE	solaris
@(eq,${UNAME},Darwin)	set MACHINE MacOSX
@(ndef,MACHINE)			set MACHINE	solaris

@ set CC	gcc
@ set YY	yacc
@ set PC	p2c
@ set DEP	mdep
@ set CFLAGS	"-g -c -Wreturn-type -D_POSIX_C_SOURCE=199506L -D__EXTENSIONS__ -DMETH_TC -D_REENTRANT"
@ set INCLUDES	"-I${src_dir} -I../../src/h -I../../src/arch/unix/h -I../../src/arch/unix/machine/${MACHINE}"
@ 				set LFLAGS	"-D_POSIX_C_SOURCE=199506L"
@				set M_LIB	"-lm "
@				set Z_LIB	"-lz "
@				set T_LIB	"-lposix4 -lpthread "
@				set N_LIB	"-lsocket -lnsl ${T_LIB}"
@				set W_LIB	"-lX11 ${N_LIB}"



#
#	linux.redhat option
#

@(eq,${MACHINE},linux.redhat)	set T_LIB	"-lpthread "
@(eq,${MACHINE},linux.redhat)	set N_LIB	"-lnsl ${T_LIB} "
@(eq,${MACHINE},linux.redhat)	set W_LIB "-L/usr/X11R6/lib -lX11 ${N_LIB} "

#
#	FreeBSD option
#

@(eq,${MACHINE},FreeBSD)	set INCLUDES	"-I${src_dir} -I../../src/h -I../../src/arch/unix/h -I../../src/arch/unix/machine/${MACHINE} -I/usr/X11R6/include"
@(eq,${MACHINE},FreeBSD)	set CFLAGS	"-g -c -pthread -Wreturn-type -D_POSIX_C_SOURCE=199506L -D__EXTENSIONS__ -DMETH_TC -D_REENTRANT -D_THREAD_SAFE"
@(eq,${MACHINE},FreeBSD)	set T_LIB	"-pthread "
@(eq,${MACHINE},FreeBSD)	set N_LIB	"${T_LIB} "
@(eq,${MACHINE},FreeBSD)	set W_LIB "-L/usr/X11R6/lib -lX11 ${N_LIB} "

#
#	MacOS X option
#

@(eq,${MACHINE},MacOSX)			set INCLUDES	"-I${src_dir} -I../../src/h -I../../src/arch/unix/h -I../../src/arch/unix/machine/${MACHINE} -I/usr/X11R6/include"
@(eq,${MACHINE},MacOSX)			set T_LIB	"-lpthread "
@(eq,${MACHINE},MacOSX)			set N_LIB	"${T_LIB} "
@(eq,${MACHINE},MacOSX)			set W_LIB "-L/usr/X11R6/lib -lX11 ${N_LIB} "




@ set YFLAGS	-d

@ source	../../src
@ work		${MACHINE}/work

@ keep		CVS d

@ insert	arch/unix/std
@ insert	arch/unix/viewlib
@ insert	arch/unix/main
@ insert	arch/unix/machine/${MACHINE}
@ insert	arch/unix/gbfloader

@ insert	main

@ insert	r64
@ insert	utils

@ insert	ppm2r64
@ insert	ppm
@ insert	gbclient
@ insert	endian
@ insert	xl
@ insert	r64status

@ insert	longchar

@ insert	stream
@ insert	memory_debug

@ insert	gbs
@ insert	pdb/fa
@ insert	pdb/status
@ insert	pdb/svg2pp
@ insert	pdb/nig2svg
@ insert	pdb/netmapper
@ insert	pdb/favt
@ insert	pdb/makekyotodb
@ insert	pdb/associate
@ insert	pdb/kiban2svg

@ insert	gbjmp
@ insert	image
@ insert	version

@ tree

@ make sufix .c from sufix - .y
	${YY} ${YFLAGS} ${from}
 	cp y.tab.c ${to}.c
 	rm y.tab.c


@ make sufix .o from sufix - .c
	${DEP} ${INCLUDES} -i${from} -o${to}.c.ap
	${CC} ${CFLAGS} ${INCLUDES} -o ${to}.o ${from}

@ make sufix .o from sufix - .t
	${PC} ${from} ${to}.c
	${DEP} ${INCLUDES} -i${from} -o${to}.c.ap
	${CC} ${CFLAGS} ${INCLUDES} -o ${to}.o ${to}.c


@ make file ${MACHINE}/bin/cosmos from sufix ${MACHINE}/work/gbs/lib/lump .o sufix ${MACHINE}/work/gbs/lib/resource .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/gbclient .o sufix ${MACHINE}/work/r64 .o sufix ${MACHINE}/work/arch/unix/viewlib .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/gbs/lib/maputils .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/http .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/longchar/wct .o sufix ${MACHINE}/work/longchar/window .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/gbs/lib/trailer .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/gbs/lib/version .o sufix ${MACHINE}/work/image .o sufix ${MACHINE}/work/arch/unix/main/window .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o sufix ${MACHINE}/work/gbs/lib/view .o sufix ${MACHINE}/work/gbs/lib/viewutils .o

	${CC} -o ${to}  ${LFLAGS} ${from} ${Z_LIB} ${M_LIB} ${W_LIB}
	cp -r ../../peripheral ${MACHINE}


# stop

@ make file ${MACHINE}/bin/xlsv from sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/xl/server_function .o sufix ${MACHINE}/work/xl/server .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/arch/unix/main/stab .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB} ${N_LIB}

# stop


@ make file ${MACHINE}/bin/kiban2svg from sufix ${MACHINE}/work/pdb/kiban2svg .o

	${CC} -o ${to}  ${LFLAGS} ${from} ${M_LIB}


@ make file ${MACHINE}/bin/gbjmp.cgi from sufix ${MACHINE}/work/gbjmp .o

	${CC} -o ${to} ${LFLAGS} ${from}

# make file ${MACHINE}/bin/lcconv from sufix ${MACHINE}/work/longchar/lcconv .o file ${MACHINE}/work/longchar/std code_table.o file ${MACHINE}/work/longchar/std get_mask.o sufix ${MACHINE}/work/arch/unix/std/panic .o

	${CC} -o ${to} ${LFLAGS} ${from}

# stop


@ make file ${MACHINE}/bin/gbmp from sufix ${MACHINE}/work/gbs/lib/lump .o sufix ${MACHINE}/work/gbs/mp .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/gbs/lib/mp .o sufix ${MACHINE}/work/xl/server_function .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/gbs/lib/version .o sufix ${MACHINE}/work/arch/unix/main/stab .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB} ${N_LIB}

# stop


@ make file ${MACHINE}/bin/gbstd from sufix ${MACHINE}/work/gbs/std .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/gbs/lib/mp .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/gbs/lib/version .o sufix ${MACHINE}/work/arch/unix/main/cmdline .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o sufix ${MACHINE}/work/gbs/lib/resource .o sufix ${MACHINE}/work/gbs/lib/maputils .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB} ${N_LIB}


# stop

@ make file ${MACHINE}/bin/gbview from sufix ${MACHINE}/work/gbs/lib/lump .o sufix ${MACHINE}/work/gbs/lib/resource .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/gbs/view .o sufix ${MACHINE}/work/r64 .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/gbs/lib/maputils .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/http .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/longchar/window .o sufix ${MACHINE}/work/longchar/wct .o sufix ${MACHINE}/work/longchar/gbf .o sufix ${MACHINE}/work/longchar/gbfglue .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/gbs/lib/trailer .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/gbs/lib/version .o sufix ${MACHINE}/work/image .o sufix ${MACHINE}/work/arch/unix/main/window .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o sufix ${MACHINE}/work/gbs/lib/view .o sufix ${MACHINE}/work/gbs/lib/viewutils .o

	${CC} -o ${to}  ${LFLAGS} ${from} ${Z_LIB} ${M_LIB} ${W_LIB}

# stop


@ make file ${MACHINE}/bin/gbfloader from sufix ${MACHINE}/work/arch/unix/gbfloader .o sufix ${MACHINE}/work/longchar/gbf .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/longchar/wct .o sufix ${MACHINE}/work/longchar/window .o sufix ${MACHINE}/work/arch/unix/viewlib .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/version .o

	${CC} -o ${to}  ${LFLAGS} ${from} ${W_LIB}

# stop


@ make file ${MACHINE}/bin/gbpmd from sufix ${MACHINE}/work/gbs/lib/pfc .o sufix ${MACHINE}/work/gbs/lib/pmd .o sufix ${MACHINE}/work/gbs/lib/lump .o sufix ${MACHINE}/work/gbs/lib/resource .o sufix ${MACHINE}/work/gbs/pmd .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/gbs/lib/maputils .o sufix ${MACHINE}/work/pdb/favt .o sufix ${MACHINE}/work/pdb/fa .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/gbs/lib/version .o sufix ${MACHINE}/work/arch/unix/main/cmdline .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to}  ${LFLAGS} ${from} ${M_LIB} ${N_LIB}

# stop




@ make file ${MACHINE}/bin/xl from sufix ${MACHINE}/work/xl/sh .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/arch/unix/main/cmdline .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB} ${N_LIB}

# stop

@ make file ${MACHINE}/bin/exl from sufix ${MACHINE}/work/xl/exsh .o sufix ${MACHINE}/work/xl/ex_function .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/pdb/associate .o sufix ${MACHINE}/work/pdb/favt .o sufix ${MACHINE}/work/pdb/fa .o sufix ${MACHINE}/work/gbs/lib/maputils .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/arch/unix/main/cmdline .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB} ${N_LIB}

# stop








@ make file ${MACHINE}/bin/netmapper from sufix ${MACHINE}/work/pdb/netmapper .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/xl/ex_function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/gbs/lib/maputils .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/arch/unix/main/cmdline .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o sufix ${MACHINE}/work/pdb/associate .o sufix ${MACHINE}/work/pdb/favt .o sufix ${MACHINE}/work/pdb/fa .o sufix ${MACHINE}/work/ppm .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB} ${N_LIB}

# stop




@ make file ${MACHINE}/bin/ppm2r64 from sufix ${MACHINE}/work/r64 .o sufix ${MACHINE}/work/ppm2r64 .o sufix ${MACHINE}/work/ppm .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/arch/unix/panic .o sufix ${MACHINE}/work/image/jpeg .o sufix ${MACHINE}/work/arch/unix/std/panic .o sufix ${MACHINE}/work/memory_debug .o
	${CC} -o ${to} ${from} ${M_LIB} ${Z_LIB}

# stop





@ make file ${MACHINE}/bin/gbpdbp from sufix ${MACHINE}/work/gbs/pdbp .o sufix ${MACHINE}/work/pdb/fa .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/gbs/lib/maputils .o sufix ${MACHINE}/work/gbs/lib/trailer .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/gbs/lib/version .o sufix ${MACHINE}/work/xl/compress .o sufix ${MACHINE}/work/image/zlib .o sufix ${MACHINE}/work/arch/unix/main/cmdline .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to} ${LFLAGS} ${from} ${Z_LIB} ${M_LIB} ${N_LIB}




@ make file ${MACHINE}/bin/svg2pp from sufix ${MACHINE}/work/pdb/svg2pp .o sufix ${MACHINE}/work/pdb/fa .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/gbs/lib/maputils .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/arch/unix/main/cmdline .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB} ${N_LIB}


# stop







@ make file ${MACHINE}/bin/xllock from sufix ${MACHINE}/work/xl/lock .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/arch/unix/main/stab .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB} ${N_LIB}

# stop


@ make file ${MACHINE}/bin/r64status from sufix ${MACHINE}/work/r64 .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/r64status .o sufix ${MACHINE}/work/arch/unix/std/panic .o sufix ${MACHINE}/work/image/jpeg .o
	${CC} -o ${to} ${from} ${M_LIB}

# stop

@ make file ${MACHINE}/bin/makekyotodb from sufix ${MACHINE}/work/pdb/favt .o sufix ${MACHINE}/work/xl/ex_function .o sufix ${MACHINE}/work/pdb/associate .o sufix ${MACHINE}/work/pdb/makekyotodb .o sufix ${MACHINE}/work/pdb/fa .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/gbs/lib/maputils .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/arch/unix/main/cmdline .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB} ${N_LIB}




@ make file ${MACHINE}/bin/nig2svg from sufix ${MACHINE}/work/pdb/nig2svg .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/arch/unix/std/panic .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB}





@ make file ${MACHINE}/bin/pdbstatus from sufix ${MACHINE}/work/pdb/status .o sufix ${MACHINE}/work/pdb/fa .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/utils/avt .o sufix ${MACHINE}/work/arch/unix/panic .o sufix ${MACHINE}/work/utils/copy .o sufix ${MACHINE}/work/arch/unix/std/panic .o

	${CC} -o ${to} ${LFLAGS} ${from} ${M_LIB}


@ make file ${MACHINE}/bin/gbr64 from sufix ${MACHINE}/work/gbs/r64 .o sufix ${MACHINE}/work/longchar/std .o sufix ${MACHINE}/work/stream .o sufix ${MACHINE}/work/arch/unix/std .o sufix ${MACHINE}/work/utils .o sufix ${MACHINE}/work/xl/lib .o sufix ${MACHINE}/work/xl/function .o sufix ${MACHINE}/work/memory_debug .o sufix ${MACHINE}/work/endian .o sufix ${MACHINE}/work/r64 .o sufix ${MACHINE}/work/version .o sufix ${MACHINE}/work/gbs/lib/version .o sufix ${MACHINE}/work/image .o sufix ${MACHINE}/work/arch/unix/main/cmdline .o sufix ${MACHINE}/work/arch/unix/machine/${MACHINE} .o

	${CC} -o ${to} ${LFLAGS} ${from} ${Z_LIB} ${M_LIB} ${N_LIB}



