# POW makefile.in
# $Id: Makefile.in,v 1.53 2007/09/07 19:53:31 irby Exp $
#
#----------------------------------------------------------------------------
# Definitions:
#----------------------------------------------------------------------------
LIBRARY		= pow

CFILES		= PowCanvCurve.c PowColormap.c PowCommands.c \
		  PowCreateCurve.c PowCreateData.c PowCreateGraph.c \
		  PowCreateImage.c PowCreateVector.c \
		  PowEventHandlers.c PowGrid.c PowInit.c PowUtils.c PowWCS.c \
		  Visu_Init.c Visu_colors.c Visu_generic.c Visu_lut.c \
		  Visu_shared_colors.c Visu_tkImgPict.c

HEADERS		= pow.h tkpict.h

SCRIPTS		= POWplot

TCLFILES	= Notifications.tcl POWplot.tcl PowCmdsClass.tcl Region.tcl \
		  RegionList.tcl Shape.tcl html_library.tcl notebook.tcl \
		  pow.tcl powEdit.tcl powImgProbe.tcl powMovie.tcl \
		  powProfile.tcl powRgn.tcl powRuler.tcl powScript.tcl \
		  powXRange.tcl visu_widgets.tcl

EXTRAS		= tclIndex mhh7.gif stretcharrow.xbm \
		  About.html Blinking.html Color.html Contours.html \
		  DefaultOptions.html Edit.html EditGraphs.html \
		  EditObjects.html File.html Labels.html Moving_Graphs.html \
		  Options.html Overview.html PrintControl.html POWAPI.html \
		  Probe.html Profile.html ROI.html Regions.html Ruler.html \
		  Scripting.html Tools.html XRange.html

OBJECTS         = ${CFILES:.c=.o} ${WCSLIB_DIR}/*.o
SHARED_OBJ      = ${OBJECTS}

STATIC_LIB	= lib${LIBRARY}.a
SHARED_LIB	= lib${LIBRARY}${SHLIB_SUFFIX}

IFLAGS		= -I${CFITSIO_DIR} -I${WCSLIB_DIR} \
		  -I${TCL_INC_PATH} -I${TK_INC_PATH} ${XINC}

#----------------------------------------------------------------------------
# Configurable macros:
#----------------------------------------------------------------------------
INSTALLDIR	= @prefix@
CC		= @CC@
RANLIB		= @RANLIB@
CFLAGS		= @CFLAGS@
#CFLAGS		= -g -DTCL_MEM_DEBUG
DEFS		= @DEFS@ -DVISU_LIBRARY=\"${INSTALLDIR}/lib/pow\" 
C_LIB_OPTION	= @C_LIB_OPTION@
SHLIB_SUFFIX	= @SHLIB_SUFFIX@
SHLIB_LD	= @SHLIB_LD@
LD_FLAGS	= @LD_FLAGS@

TCL_INC_PATH	= @TCL_INC_PATH@
TCL_LIB_PATH	= @TCL_PATH@
TCL_LIB		= @TCL_LIB@
TK_INC_PATH	= @TK_INC_PATH@
TK_LIB_PATH	= @TK_PATH@
TK_LIB		= @TK_LIB@
XINC		= @XINCLUDES@
XLIBS		= @XLIBS@
CFITSIO_DIR	= @CFITSIODIR@
WCSLIB_DIR	= @WCSLIB_DIR@
SHLIB_LD_LIBS	= @LIBS@ @SHLIB_LD_LIBS@ -L${TCL_LIB_PATH} -l${TCL_LIB} -L${TK_LIB_PATH} -l${TK_LIB} ${XLIBS}

#----------------------------------------------------------------------------
# Targets:
#----------------------------------------------------------------------------
all: ${C_LIB_OPTION}

${STATIC_LIB}: static

${SHARED_LIB}: shared

static: ${OBJECTS}
	rm -f ${STATIC_LIB}
	ar cr ${STATIC_LIB} ${OBJECTS}
	${RANLIB} ${STATIC_LIB}

shared: ${SHARED_OBJ}
	${SHLIB_LD} ${LD_FLAGS} ${SHARED_OBJ} ${SHLIB_LD_LIBS} -o ${SHARED_LIB}

install:
	@if [ ! -d ${INSTALLDIR}/lib/pow ]; then \
		echo "mkdir ${INSTALLDIR}/lib/pow"; \
		mkdir ${INSTALLDIR}/lib/pow; \
	fi
	@if [ "x${C_LIB_OPTION}" = xstatic ]; then \
		echo "cp ${STATIC_LIB} ${INSTALLDIR}/lib/"; \
		cp ${STATIC_LIB} ${INSTALLDIR}/lib/; \
	else \
		echo "cp ${SHARED_LIB} ${INSTALLDIR}/lib/"; \
		cp ${SHARED_LIB} ${INSTALLDIR}/lib/; \
	fi
	@for file in ${SCRIPTS}; do \
		echo "cp $$file ${INSTALLDIR}/bin/"; \
		cp $$file ${INSTALLDIR}/bin/; \
	done
	@for file in ${HEADERS}; do \
		echo "cp $$file ${INSTALLDIR}/include/"; \
		cp $$file ${INSTALLDIR}/include/; \
	done
	@for file in ${TCLFILES} ${EXTRAS}; do \
		echo "cp $$file ${INSTALLDIR}/lib/pow/"; \
		cp $$file ${INSTALLDIR}/lib/pow/; \
	done

clean:
	-rm -rf *.o *~ ${STATIC_LIB} ${SHARED_LIB} so_locations

distclean: clean
	-rm -f config.cache config.status config.log Makefile

#----------------------------------------------------------------------------
# Make target which outputs the list of the .o contained in the POW lib
# usefull to build a single big shared library containing Tcl/Tk and other
# extensions.  used for the Tcl Plugin. 
#----------------------------------------------------------------------------
tags:	${CFILES} ${TCLFILES}
	etags ${CFILES}
	mv TAGS CTAGS
	tcltags ${TCLFILES}
	cat CTAGS >> TAGS
	rm CTAGS

powLibObjs:
	@echo ${OBJECTS} orbit.o 

# This target actually builds the objects needed for the lib in the above case
objs: ${OFILES} orbit.o 


.c.o:
	${CC} -c ${CFLAGS} ${DEFS} ${IFLAGS} $<
