Index: /trunk/magic/Makefile.in
===================================================================
--- /trunk/magic/Makefile.in	(revision 24665)
+++ /trunk/magic/Makefile.in	(revision 24665)
@@ -0,0 +1,24 @@
+
+default: all
+
+all: magic
+
+install: all
+	# cp -f bin/* @BINDIR@/
+	# cp -f man/man1/* @MANDIR@/man1/
+
+clean:
+	echo "dummy clean"
+
+update:
+	# get the source code (replace this with SVN interactions)
+	tar xvzf @MAGICDIR@/magic.tgz
+	tar xvzf @MAGICDIR@/ssa-core-cpp.tgz
+	cp Makefile.magic magic/Makefile.magic
+
+ssa-core-cpp:
+	cd ssa-core-cpp && ./configure
+	cd ssa-core-cpp && make
+
+magic:
+	cd magic && make -f Makefile.magic
Index: /trunk/magic/Makefile.magic
===================================================================
--- /trunk/magic/Makefile.magic	(revision 24665)
+++ /trunk/magic/Makefile.magic	(revision 24665)
@@ -0,0 +1,38 @@
+TARGETS =  DetectStreaks
+
+CXX = c++
+CXXFLAGS = -W -Wall -O3 -DNDEBUG
+# CXXFLAGS = -W -Wall -g
+
+SSA_SRC_DIR = ../ssa-core-cpp/src
+INCLUDEDIRS = -I. -I$(SSA_SRC_DIR)
+OTHER_SRCS = $(SSA_SRC_DIR)/math/Constants.cpp
+
+# CFITSIO_DIR = ../cfitsio
+CFITSIO_DIR = $(PSCONFDIR)/$(PSCONFIG)
+
+CFITSIO_INC =  -I$(CFITSIO_DIR)
+CFITSIO_LIB = -L$(CFITSIO_DIR) -lcfitsio
+
+all : $(TARGETS)
+
+RemoveStreaks : $(OTHER_SRCS)
+
+DetectStats : $(OTHER_SRCS)
+
+% :: %.cpp
+	$(CXX) $(CXXFLAGS) $(INCLUDEDIRS) $(CFITSIO_INC) $< $(OTHER_SRCS) $(CFITSIO_LIB) -o $@
+
+.PHONY : clean
+
+.SILENT : clean
+
+clean :
+	   - rm $(TARGETS)
+
+DESTDIR=$(PSCONFDIR)/$(PSCONFIG)
+
+install:        $(TARGETS)
+	cp DetectStreaks $(DESTDIR)/bin
+	chmod 755  $(DESTDIR)/bin/DetectStreaks
+
Index: /trunk/magic/autogen.sh
===================================================================
--- /trunk/magic/autogen.sh	(revision 24665)
+++ /trunk/magic/autogen.sh	(revision 24665)
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+for arg in $*; do
+    case $arg in
+        --no-configure)
+	    exit 0
+            ;;
+        *)
+            ;;
+    esac
+done
+
+./configure.tcsh $*
Index: /trunk/magic/configure
===================================================================
--- /trunk/magic/configure	(revision 24665)
+++ /trunk/magic/configure	(revision 24665)
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# strip out CC, CFLAGS, CPPFLAGS, LDFLAGS and set env vars
+while ( test $# -gt 0 ); do
+
+  skip=0
+
+  # strip out CC, set as env variable
+  echo $1 | grep "^CC=" > /dev/null
+  if ( test $? -eq 0 ) ; then
+    val=`echo $1 | sed "s|^CC=||"`
+    export CC=$val
+    skip=1
+  fi
+  # strip out CFLAGS, set as env variable
+  echo $1 | grep "^CFLAGS=" > /dev/null
+  if ( test $? -eq 0 ) ; then
+    val=`echo $1 | sed "s|^CFLAGS=||"`
+    export CFLAGS=$val
+    skip=1
+  fi
+  # strip out CPPFLAGS, set as env variable
+  echo $1 | grep "^CPPFLAGS=" > /dev/null
+  if ( test $? -eq 0 ) ; then
+    val=`echo $1 | sed "s|^CPPFLAGS=||"`
+    export CPPFLAGS=$val
+    skip=1
+  fi
+  # strip out LDFLAGS, set as env variable
+  echo $1 | grep "^LDFLAGS=" > /dev/null
+  if ( test $? -eq 0 ) ; then
+    val=`echo $1 | sed "s|^LDFLAGS=||"`
+    export LDFLAGS=$val
+    skip=1
+  fi
+  if ( test $skip -eq 0 ) ; then
+    args="$args $1"
+  fi
+  shift
+done
+
+./configure.tcsh $args
Index: /trunk/magic/configure.tcsh
===================================================================
--- /trunk/magic/configure.tcsh	(revision 24665)
+++ /trunk/magic/configure.tcsh	(revision 24665)
@@ -0,0 +1,179 @@
+#!/bin/csh -f
+
+# this is a very low-tech version of configure, not built by autoconf.
+# we check for the following libraries:
+
+# we need to be able to list the required libraries for a given distribution
+
+# evaluate command-line options
+set prefix  = ""
+set bindir  = ""
+set libdir  = ""
+set incdir  = ""
+set mandir  = ""
+set datadir  = ""
+set sysconfdir  = ""
+set exec_prefix = ""
+set defines = ""
+set profile = 0
+
+set root    = ""
+set args    = ""
+
+while ("$1" != "") 
+ switch ("$1")
+  # switch options passed by build systems which we ignore
+  case --enable-maintainer-mode
+  case --no-create
+  case --no-recursion
+  case --enable-optimize
+  case --disable-shared
+  case --enable-shared
+  case --disable-static
+  case --enable-static
+  case --enable-profile
+  case --pedantic
+   shift
+   breaksw;
+  # key/value options passed by build systems which we ignore
+  case --sbindir*
+  case --libexecdir*
+  case --sharedstatedir*
+  case --localstatedir*
+  case --oldincludedir*
+  case --infodir*
+  case --exec-prefix*
+  case --libdir*
+  case --includedir*
+  case --sysconfdir*
+  case --datadir*
+   # we need to strip the --opt word and --opt=word versions
+   set word = `echo $1 | tr = ' '`
+   if ($#word == 1) then
+     if ($#argv > 1) then
+      shift
+     endif
+   endif
+   breaksw;
+  case --prefix*
+   if ("$1" == "--prefix") then
+     shift
+     set prefix = $1
+   else
+     set prefix = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --bindir*
+   if ("$1" == "--bindir") then
+     shift
+     set bindir = $1
+   else
+     set bindir = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --mandir*
+   if ("$1" == "--mandir") then
+     shift
+     set mandir = $1
+   else
+     set mandir = `echo $1 | tr = ' ' | awk '{print $2}'`
+   endif
+   breaksw;
+  case --help:
+   goto usage
+  case -*: 
+   echo ""
+   echo "Unknown option: $1"
+   goto usage
+  default:
+   set args=($args $1);
+   breaksw;
+ endsw
+ shift
+end
+if ($#args != 1) goto usage
+
+# gpc build ignores CC, CFLAGS, CPPFLAGS, LDFLAGS
+
+# set up the basic directory names:
+set root = `pwd`
+if ($prefix == "") set prefix = $root
+
+echo 
+echo "install destinations:"
+echo "ROOT: $root"
+echo "PREFIX: $prefix"
+echo 
+
+# the config.tools fixconf operations below interpolate values in Makefile
+if (-e Makefile) mv Makefile Makefile.bak
+cp -f Makefile.in Makefile
+
+# BINDIR holds the output binary files
+if ("$bindir" == "") then
+  set subdir = bin
+  set bindir = $prefix/$subdir
+endif
+set bindir = `./config.tools fixpath $bindir`
+./config.tools fixconf @BINDIR@ $bindir
+echo BINDIR $bindir
+
+# MANDIR (DESTMAN) holds the output man pages
+if ("$mandir" == "") then
+  set mandir = $prefix/man
+endif
+set mandir = `./config.tools fixpath $mandir`
+./config.tools fixconf @MANDIR@ $mandir
+echo DESTMAN $mandir
+
+echo ""
+echo "include $bindir in your path"
+
+exit 0
+
+usage:
+cat <<EOF
+USAGE: configure [OPTION]
+
+echo remaining args: $args
+
+set the installation directory root with --prefix
+if you define the environment variable ARCH, you can set --vararch
+ 
+Configuration:
+  -h, --help              display this help and exit
+  --enable-optimize       enable compiler optimization (-O2)
+  --enable-memcheck       enable ohana memory tests
+  --pedantic              include -Wall -Werror on compilation
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+  --vararch               install with ARCH suffixes for variable architectures
+
+Fine tuning of the installation directories:
+  --bindir=DIR           user executables [PREFIX/bin/$ARCH] 
+  --libdir=DIR           object code libraries [PREFIX/lib/$ARCH]
+  --includedir=DIR       C header files [PREFIX/include]
+  --mandir=DIR           man documentation [PREFIX/man]
+  --datadir=DIR          read-only architecture-independent data [PREFIX/share]
+  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]
+
+Makefile flags:
+  CC=options
+  CFLAGS=options
+  CPPFLAGS=options
+  LDFLAGS=options
+
+The following options are silently ignored for compatibility:
+  --enable-maintainer-mode
+  --no-create
+  --no-recursion
+  --sbindir
+  --libexecdir
+  --sharedstatedir
+  --localstatedir
+  --oldincludedir
+  --infodir
+
+EOF
+ exit 2;
