#
# rcsid $Header: /usr/cvsroot/magic/magic/Makefile,v 1.1 2005/02/11 17:31:52 tim Exp $
#

MODULE   = magic
MAGICDIR = ..
SRCS     = magicTop.c

include ${MAGICDIR}/defs.mak

EXTRA_LIBS = ${MAGICDIR}/cmwind/libcmwind.o ${MAGICDIR}/commands/libcommands.o \
	    ${MAGICDIR}/database/libdatabase.o ${MAGICDIR}/dbwind/libdbwind.o \
	    ${MAGICDIR}/drc/libdrc.o ${MAGICDIR}/debug/libdebug.o \
	    ${MAGICDIR}/extract/libextract.o ${MAGICDIR}/graphics/libgraphics.o \
	    ${MAGICDIR}/select/libselect.o ${MAGICDIR}/textio/libtextio.o \
	    ${MAGICDIR}/tiles/libtiles.o ${MAGICDIR}/windows/libwindows.o \
	    ${MAGICDIR}/wiring/libwiring.o ${MAGICDIR}/resis/libresis.o \
	    ${MAGICDIR}/sim/libsim.o ${MAGICDIR}/netmenu/libnetmenu.o \
	    ${MAGICDIR}/plow/libplow.o ${MAGICDIR}/utils/libutils.o \
	    ${MAIN_EXTRA_LIBS}

BITMAPS = up.xbm down.xbm left.xbm right.xbm zoom.xbm
DEST_XBM = $(BITMAPS:%=${TCLDIR}/bitmaps/%)

DFLAGS += -DMAGIC_VERSION="\"`${SCRIPTS}/version`\"" \
	-DMAGIC_REVISION="\"`${SCRIPTS}/revision`\"" \
	-DMAGIC_DATE="\"`date`\""
LIBS   += ${GR_LIBS} ${READLINE_LIBS} -lm ${LD_EXTRA_LIBS} \
		${OA_LIBS} ${TOP_EXTRA_LIBS}
CLEANS += tclmagic${SHDLIB_EXT} libtclmagic${SHDLIB_EXT}.a proto.magic

main: magic proto.magic

tcl-main: tclmagic${SHDLIB_EXT} proto.magic

tclmagic${SHDLIB_EXT}: ${EXTRA_LIBS}
	@echo --- making magic Tcl library \(tclmagic${SHDLIB_EXT}\)
	${RM} tclmagic${SHDLIB_EXT}
	${CC} ${CFLAGS} ${CPPFLAGS} -o $@ ${LDDL_FLAGS} ${LD_RUN_PATH} \
		${EXTRA_LIBS} -lc ${LIBS}

proto.magic: proto.magic.m4
	sed -e /CAD_DIR/s%CAD_DIR%${CADDIR}%g proto.magic.m4 | \
		${M4} ${GR_DFLAGS} ${DFLAGS} > proto.magic

install: ${BINDIR}/${MODULE}${EXEEXT} ${SYSDIR}/.magic ${SYSDIR}/magicps.pro

install-tcl: ${TCLDIR}/tclmagic${SHDLIB_EXT} ${SYSDIR}/.magic ${SYSDIR}/magicps.pro ${DEST_XBM}

${TCLDIR}/tclmagic${SHDLIB_EXT}: tclmagic${SHDLIB_EXT}
	${RM} ${TCLDIR}/tclmagic${SHDLIB_EXT}
	${CP} tclmagic${SHDLIB_EXT} ${TCLDIR}/tclmagic${SHDLIB_EXT}

${TCLDIR}/bitmaps/%: bitmaps/%
	${RM} ${TCLDIR}/bitmaps/$*
	${CP} bitmaps/$* ${TCLDIR}/bitmaps/$*

${SYSDIR}/.magic: proto.magic
	${RM} ${SYSDIR}/.magic
	${CP} proto.magic ${SYSDIR}/.magic

${SYSDIR}/magicps.pro: magicps.pro
	${RM} ${SYSDIR}/magicps.pro
	${CP} magicps.pro ${SYSDIR}/magicps.pro

include ${MAGICDIR}/rules.mak
