#!/bin/csh -f
# rcsid="$Id: config,v 1.24 2006/02/08 03:48:24 fang Exp $"

set VERSION="7.1"

echo ""
echo "              Welcome to Magic's configuration program."
echo "                    This is Version $VERSION."
echo ""

set SCRIPTS=scripts

# default options (may be overridden in file "default.conf")
set windefault="1"
set osdefault="1"
set machdefault="1"
set calmadefault="yes"
set cifdefault="yes"
set plotdefault="yes"
set filelockdefault="no"
set readlinedefault="yes"
set threadeddefault="yes"
set nonmanhdefault="yes"
set routedefault="yes"
set scmdefault="yes"
set simdefault="yes"
set newdotdefault="yes"

set nonomatch
if ( $status == 0 ) then
   set CADDEFAULT=~cad
else
   set CADDEFAULT=/usr/local
endif
unset nonomatch

if ( -f default.conf ) then
    source default.conf
endif

if( $?CAD_HOME ) then
  set CADDIR=$CAD_HOME
  cat - << CAT_EOF
You have \$CAD_HOME set to "$CAD_HOME".
CAT_EOF
else
  echo "You do not have CAD_HOME set. Set it now or press return to it to the default."
  echo -n "Enter a value of CAD_HOME [${CADDEFAULT}]: "

  set cad_home=($<)
  if( $cad_home != "" ) then
    set CADDIR=$cad_home
  else
    set CADDIR=${CADDEFAULT}
  endif
  echo "CAD_HOME set to $CADDIR"
endif

cat - << CAT_EOF

The \$CAD_HOME value will be reflected in the \$CADDIR varible in the 
defs.mak files. It is only needed for installation so you can change
it by modifying the defs.mak after building.

You can create other custom configurations yourself.  Read the
maintainer's manuals for details.  In particular, you can have more than
one graphics driver installed.
 
We haven't been able to test all of these configurations.  If 
you develop modifications to Magic or to this configuration program,
please let us (magic-hackers@csl.cornell.edu) know.
-------------------------------------------------------------------------------
Magic works with the following window configurations.  X11 is preferred.
	1) X11
	2) OpenGL
	3) SunView
	4) OS/2 Warp
	5) X10
	6) AED graphics terminal

CAT_EOF

set cflags=
set cppflags='-I. -I${MAGICDIR}'
set dflags=
set oflags=

set rl_defs=
set rl_libs=

set gr_cflags=
set gr_dflags=
set gr_libs=
set gr_srcs=
set gr_hsrcs=
set gr_hprog=

echo -n "Please select one or more of the above configurations by number [$windefault]:  "

set windows=($<)
if ("$windows" == "") then
   set windows="$windefault"
else
   set windefault="$windows"
endif

foreach i ($windows)
switch ($i)
case "1":
    echo "X11 selected"
    echo "Make sure your default link and include path contains the X11"
    echo "libraries and header files. Otherwise edit LDFLAGS in defs.mak"
    echo "to include them." 
    set usingX11
    set gr_dflags=($gr_dflags -DX11 -DXLIB -DX11HELP_PROG=\\\"'${X11HELP_PROG}$(PROGRAM_SUFFIX)'\\\")
    set gr_libs=("$gr_libs" -lX11)
    set gr_srcs=("$gr_srcs" '${X11_SRCS}')
    set gr_hsrcs=("$gr_hsrcs" '${X11HELPER_SRCS}')
    set gr_hprog=("$gr_hprog" '${X11HELP_PROG}')
    breaksw
case "2":
    echo "OpenGL selected"
    set usingOGL
    set gr_dflags=("$gr_dflags" -DOGL)
    set gr_libs=("$gr_libs" -lGLU -lGL -lXi -lXmu -lXext)
    set gr_srcs=("$gr_srcs" '${OGL_SRCS}')
    if (!($?usingX11)) then
	set usingX11
	set gr_libs=("$gr_libs" -lX11)
	set gr_dflags=("$gr_dflags" -DXLIB -DX11HELP_PROG=\"${X11HELP_PROG}$(PROGRAM_SUFFIX)\")
	set gr_hsrcs=("$gr_hsrcs" '${X11HELPER_SRCS}')
	set gr_hprog=("$gr_hprog" '${X11HELP_PROG}')
    endif
    breaksw
case "3":
    echo "SunView selected"
    set gr_dflags=("$gr_dflags" -DSUNVIEW)
    set gr_libs=("$gr_libs" -lsuntool -lsunwindow -lpixrect)
    set gr_srcs=("$gr_srcs" '${SUN_SRCS}')
    set gr_hsrcs=("$gr_hsrcs" '${SUNHELPER_SRCS}')
    set gr_hprog=("$gr_hprog" '${SUNHELP_PROG}')
    breaksw
case "4":
    echo "OS/2 Warp (X11-based) selected"
    echo "Make sure your default link and include path contains the X11"
    echo "libraries and header files. Otherwise edit LDFLAGS in defs.mak"
    echo "to include them." 
    set usingX11
    set gr_dflags=($gr_dflags -DX11 -DXLIB -DX11HELP_PROG=\\\"'${X11HELP_PROG}$(PROGRAM_SUFFIX)'\\\")
    set gr_libs=("$gr_libs" -lX11)
    set gr_srcs=("$gr_srcs" '${OS2_SRCS}')
    set gr_hsrcs=("$gr_hsrcs" '${X11HELPER_SRCS}')
    set gr_hprog=("$gr_hprog" '${X11HELP_PROG}')
    breaksw
case "5":
    echo "X10 selected"
    echo "Make sure your default link and include path contains the X10"
    echo "libraries and header files. Otherwise edit LDFLAGS in defs.mak"
    echo "to include them." 
    set gr_dflags=("$gr_dflags" -DX10)
    set gr_libs=("$gr_libs" -lX10)
    set gr_srcs=("$gr_srcs" '${X10_SRCS}')
    set gr_hsrcs=("$gr_hsrcs" '${X10HELPER_SRCS}')
    set gr_hprog=("$gr_hprog" '${X10HELP_PROG}')
    breaksw
case "6":
    echo "AED terminal selected"
    set gr_srcs=("$gr_srcs" '${AED_SRCS}')
    breaksw
default:
    echo "Unrecognized selection:  $i"
    echo "Exiting."
    exit 1
    breaksw
endsw
end

cat - << CAT_EOF

-------------------------------------------------------------------------------
The following operating systems are known:

	 1) Linux
	 2) NetBSD 1.x 
	 3) FreeBSD 2.x 
	 4) OSF/1 on a 64 bit machine (Digital Alpha AXP)
	 5) Solaris 2.x (aka SunOS 5.x)
	 6) SunOS 4.x 
	 7) SGI IRIX
	 8) OS/2 Warp
	 9) BSD Unix systems (Ultrix, pre-4.0 SunOS, RISCos4.0, etc..)
 	10) SYSV Unix systems (A/UX, HPUX)
	11) Cygwin (UNIX for MS Windows)
CAT_EOF

echo -n "Please select one of the above operating systems by number [$osdefault]:  "

set os=$<
if ($os == "") then
   set os=$osdefault
else
   set osdefault=$os
endif

set cpp = "/lib/cpp -P"
set cc=gcc
set depend_flag=-MM
set ranlib=ranlib
echo ""

switch ($os)
case "1":
    echo "Linux selected"
    set cpp = "/lib/cpp -P -traditional"
    set dflags=("$dflags" -Dlinux -DSYSV -DF_OK=0 -DW_OK=2)
    set dflags=("$dflags" -D__NO_STRING_INLINES -DISC)
    set oflags=("-O6 -fomit-frame-pointer")
    if ($?usingOGL) then
	set gr_libs=("$gr_libs" -lstdc++)
    endif
    if ($?usingX11) then
	set gr_cflags=("$gr_cflags" -I/usr/X11R6/include)
	set gr_libs=("$gr_libs" -L/usr/X11R6/lib/)
    endif
    if ( -f /usr/lib/libbsd-compat.a ) then
       set gr_libs=("$gr_libs" -lbsd-compat)
    else if ( -f /usr/lib/libbsd.a ) then
       set gr_libs=("$gr_libs" -lbsd)
    endif
    breaksw
case "2":
    echo "NetBSD 1.x selected"
    set cpp = "/usr/libexec/cpp -P -traditional"
    if ($?usingX11) then
	echo "NOTE:  Since you are running NetBSD using X11, we're assuming"
	echo "       that you want to get the X11 library from either the normal"
 	echo "       library area or from the directory /usr/X11R6/lib.  If this"
 	echo "       is not correct, edit the defs.mak file by hand after this"
	echo "       script completes."
    set gr_cflags=("$gr_cflags" -I/usr/X11R6/include)
 	set gr_libs=(-L/usr/X11R6/lib "$gr_libs")
    endif
    breaksw
case "3":
    echo "FreeBSD 2.x selected"
    set cpp = "/usr/libexec/cpp -P -traditional"
    if ($?usingX11) then
	echo "NOTE:  Since you are running FreeBSD using X11, we're assuming"
	echo "       that you want to get the X11 library from either the normal"
 	echo "       library area or from the directory /usr/X11R6/lib.  If this"
 	echo "       is not correct, edit the defs.make file by hand after this"
	echo "       script completes."
	set gr_cflags=("$gr_cflags" -I/usr/X11R6/include)
 	set gr_libs=(-L/usr/X11R6/lib "$gr_libs")
    endif
    breaksw
case "4":
    echo "64 bit OSF/1 selected (Alpha AXP)"
    set dflags=("$dflags" -DALPHA -DUSE_IO_PROBE)
    breaksw
case "5":
    echo "Solaris 2.x selected"
    set cpp = "/usr/ccs/lib/cpp -P"
    set cc=cc
    set depend_flag=-xM1
    if ($?OPENWINHOME) then
       set OPENHOME=${OPENWINHOME}
    else
       set OPENHOME=""
    endif
    if ($?usingX11) then
       echo "NOTE:  Since you are on a Sun using X11, we're assuming that"
       echo "       you want to get the X11 libraries and header files from"
       echo "       either the normal library and header file area or from"
       echo "       the directories ${OPENHOME}/lib and ${OPENHOME}/include."
       echo "       If this is not correct, edit the defs.mak file by"
       echo "       hand after this script completes, or re-run this script with"
       echo "       the environment variable OPENWINHOME set properly."
       set gr_cflags=("$gr_cflags" "-I${OPENHOME}/include")
       set gr_libs=("-R${OPENHOME}/lib" "-L${OPENHOME}/lib" "$gr_libs")
    endif
    set dflags=("$dflags" -DSYSV)
    set oflags=(-fast)
    set ranlib=/bin/true
    breaksw
case "6":
    echo "Sun OS 4.0 and later (pre-Solaris) selected"
    echo "NOTE:  You might have to load the libraries libsuntool.a,"
    echo "       libsunwindow.a, and libpixrect.a from CD if your software"
    echo "       was pre-loaded at the factory."
    if ($?OPENWINHOME) then
	set OPENHOME=${OPENWINHOME}
    else
	set OPENHOME=""
    endif
    if ($?usingX11) then
	echo "NOTE:  Since you are on a Sun using X11, we're assuming that"
	echo "       you want to get the X11 library from either the normal"
	echo "       library area or from the directory ${OPENHOME}/lib.  If"
	echo "       this is not correct, edit the defs.mak file by hand"
	echo "       after this script completes, or re-run this script with"
	echo "       the environment variable OPENWINHOME set properly."
	set gr_cflags=("-I${OPENHOME}/include")
	set gr_libs=("-L${OPENHOME}/lib" "$gr_libs")
    endif
    set cflags=("$cflags" -Bstatic)
    breaksw
case "7":
    echo "SGI/IRIX selected. "
    set compileIRIX
    set cc=cc
    set cpp = "/usr/lib/cpp -P"
    set dflags=("$dflags" -DSYSV -DIRIX -D_BSD_SIGNALS)
# These values do not seem to be warranted (which IRIX system needs them?)
#   set cflags=("$cflags" -cckr -n32 -woff 1174,1116,1233,1552,1009,1171,1014,1177)
#   set oflags=(-mips4 -O3 -TARG:platform=ip27 -OPT:Olimit=0:roundoff=3:div_split=ON:alias=typed)
    set cflags=("$cflags" -cckr)
    set oflags=(-mips4 -O3)
    set gr_cflags=("$gr_cflags" -I/usr/include/X11)
    set ranlib=/bin/true
    breaksw
case "8":
    echo "OS/2 Warp selected"
    set dflags=("$dflags" -DOS2)
    breaksw
case "9":
    echo 'BSD Unix selected'
    breaksw
case "10":
    echo "SYSV selected"
    set dflags=("$dflags" -DSYSV )
    set ranlib=/bin/true
    breaksw
case "11":
    echo "Cygwin selected"
    set cflags=("$cflags" -I/usr/X11R6/include)
    set gr_libs=(-L/usr/X11R6/lib $gr_libs)
    set dflags=("$dflags" -DCYGWIN -Di386 -DWIN32)
    set usingCygwin
    set cc=gcc
    set cpp = "/bin/cpp -P -traditional"
    breaksw
default:
    echo "Unrecognized selection:  $os"
    echo "Exiting."
    exit 2
    breaksw
endsw

cat - << CAT_EOF

-------------------------------------------------------------------------------
Some machines need special compile-time switches:

	1) Intel 80x86-based workstations
	2) HP 68000-based workstations
	3) HP/PA based workstation
 	4) A MIPS workstation running RISCos4.0 or greater (not DECStations)
 	5) An Apple MacII
	6) None of the above

CAT_EOF

echo -n "Please select one of the above machine types by number [$machdefault]:  "

set mach=$<
if ($mach == "") then
   set mach=$machdefault
else
   set machdefault=$mach
endif

switch ($mach)
case "1":
    echo "Intel x86 workstation selected"
    if ($?usingCygwin) then
        set cflags=("$cflags"  -mpentium)
    else
        set cflags=("$cflags"  -m486)
    endif
    breaksw
case "2":
    echo "HP 68000 workstation selected"
    set dflags=("$dflags" -Dmc68000)
    breaksw
case "3":
    echo "HP/PA workstation selected"
    breaksw
case "4":
    echo "MipsCo selected"
    set cflags=("$cflags" -systype bsd43 -O -Olimit 3000 -signed)
    breaksw
case "5":
    echo "MacII selected"
    set dflags=("$dflags" -DmacII)
    set cflags=("$cflags" -B /usr/lib/big/)
    breaksw
case "6":
    echo "Normal compilation---no additional flags."
    breaksw
default:
    echo "Unrecognized selection:  $mach"
    echo "Exiting."
    exit 2
    breaksw
endsw

cat - << CAT_EOF

-------------------------------------------------------------------------------
Sometimes is it handy to eliminate modules from Magic, to make it smaller.
The following modules are optional:
    CALMA - module to read and write GDS-II format
    CIF - module to read and write CIF
    PLOT - plotting code
    READLINE - readline support on the command line
    THREADS - support for multithreaded graphics in X11 and OpenGL
    NONMANHATTAN - support for non-manhattan geometry
    ROUTE - a whole bunch of routing tools
    SCM - a scheme command-line interpreter
    SIM - an interface to RSIM
    .magic - choice of new or old system startup (macro definition) file

You may need to update your system wide ".magic" file to eliminate use of these
modules.  (Look at "~cad/lib/magic/sys/.magic".)
CAT_EOF

echo -n "Include CALMA module? [$calmadefault]  "
set calma=$<
if ($calma == "") then 
    set calma=$calmadefault
else
    set calmadefault=$calma
endif
if ($calma != "no" && $calma != "n" && $calma != "yes" && $calma != "y") then
    echo Unrecognized answer:  $calma
    echo "Exiting."
    exit 5
endif
if ($calma == "n" || $calma == "no") then
    set dflags=("$dflags" -DNO_CALMA)
endif

echo -n "Include CIF module? [$cifdefault]  "
set cif=$<
if ($cif == "") then 
    set cif=$cifdefault
else
    set cifdefault=$cif
endif
if ($cif != "no" && $cif != "n" && $cif != "yes" && $cif != "y") then
    echo Unrecognized answer:  $cif
    echo "Exiting."
    exit 5
endif
if ($cif == "n" || $cif == "no") then
    set dflags=("$dflags" -DNO_CIF)
endif

echo -n "Include PLOT module? [$plotdefault]  "
set plot=$<
if ($plot == "") then 
    set plot=$plotdefault
else
    set plotdefault=$plot
endif
if ($plot != "no" && $plot != "n" && $plot != "yes" && $plot != "y") then
    echo Unrecognized answer:  $plot
    echo "Exiting."
    exit 5
endif
if ($plot == "n" || $plot == "no") then
    set dflags=("$dflags" -DNO_PLOT)
endif

echo -n "Include multiuser file-locking? [$filelockdefault] "
set filelock=$<
if ($filelock == "") then 
    set filelock=$filelockdefault
else
    set filelockdefault=$filelock
endif
if ($filelock != "no" && $filelock != "n" && $filelock != "yes" && $filelock != "y") then
    echo Unrecognized answer:  $filelock
    echo "Exiting."
    exit 5
endif
if ($filelock == "yes" || $filelock == "y") then
    set dflags=("$dflags" -DFILE_LOCKS)
endif

set modules=""
echo -n "Include READLINE module? [$readlinedefault]  "
set readline=$<
if ($readline == "") then 
    set readline=$readlinedefault
else
    set readlinedefault=$readline
endif
if ($readline != "no" && $readline != "n" && $readline != "yes" && $readline != "y") then
    echo Unrecognized answer:  $readline
    echo "Exiting."
    exit 5
endif
# check for readline on system first. . .
# readline must be version 4.0 or better (contains function rl_pre_input_hook())
#
set have_readline="no"
if ($readline == "y" || $readline == "yes") then
    set dflags=("$dflags" -DUSE_READLINE)
# some systems are now putting termcap functions in ncurses. . . check this!
    set termlib=-ltermcap
    if ( -f /usr/lib/libncurses.so || -f /usr/lib/libncurses.a ) then
	if (-f /usr/lib/libncurses.a ) then
	    if ( `nm /usr/lib/libncurses.a | grep tgetent | wc -l` > 0) then
		set termlib=-lncurses
	    endif
	else
	    if ( `nm /usr/lib/libncurses.so | grep tgetent | wc -l` > 0) then
		set termlib=-lncurses
	    endif
	endif
    else if (!( -f /usr/lib/libtermcap.so || -f /usr/lib/libtermcap.a )) then
	echo "Cannot find termcap library functions. . . compiling without readline"
	set readline="no"
    endif
    
    if ( $readline != "no" && -f /usr/lib/libreadline.so ) then
	if ( `nm /usr/lib/libreadline.so | grep pre_input | wc -l` > 0 ) then
	    set have_readline="yes"
	    set dflags=($dflags -DHAVE_READLINE)
	    set rl_libs=($rl_libs -lreadline ${termlib})
	    if ( `nm /usr/lib/libreadline.so | grep rl_filename_completion_function | wc -l` > 0) then
		set dflags=($dflags -DREADLINE_4_DOT_2_PLUS)
	    endif
	endif
    endif
    if ($?compileIRIX) then
       echo "NOTE:  Must compile with GNU make (gmake), not the IRIX make"
    endif
endif

if ($have_readline == "no" && ($readline == "y" || $readline == "yes")) then
    set modules=readline
	set cppflags=("$cppflags" '-I${MAGICDIR}/readline')
	set rl_libs=("$rl_libs" '-L${MAGICDIR}/readline/readline' -lreadline ${termlib})
    if ($?compileIRIX) then
      set rl_defs=("-DNEED_EXTERN_PC")
	  set rl_libs=("$rl_libs" -lm)
    endif
endif

if ($?usingX11) then
echo -n "Include THREADS support? [$threadeddefault]  "
set threaded=$<
if ($threaded == "") then 
    set threaded=$threadeddefault
else
    set threadeddefault=$threaded
endif
if ($threaded != "no" && $threaded != "n" && $threaded != "yes" && $threaded != "y") then
    echo Unrecognized answer:  $threaded
    echo "Exiting."
    exit 5
endif  
#
# check for pthreads on system first. . .
#
if ($threaded == "y" || $threaded == "yes") then
    if ( -f /usr/lib/libpthread.so || -f /usr/lib/libpthread.a ) then
	set gr_dflags=("$gr_dflags" -DHAVE_PTHREADS)
	set gr_libs=($gr_libs -lpthread)
	set gr_srcs=("$gr_srcs" 'grX11thread.c')
	set gr_hsrcs=
	set gr_hprog=
    endif
endif
# usingX11
endif

echo -n "Include NONMANHATTAN extensions? [$nonmanhdefault]  "
set nonmanh=$<
if ($nonmanh == "") then 
    set nonmanh=$nonmanhdefault
else
    set nonmanhdefault=$nonmanh
endif
if ($nonmanh != "no" && $nonmanh != "n" && $nonmanh != "yes" && $nonmanh != "y") then
    echo Unrecognized answer:  $route
    echo "Exiting."
    exit 5
endif
if ($nonmanh == "y" || $nonmanh == "yes") then
    set dflags=("$dflags" -DNONMANHATTAN)
endif

echo -n "Include ROUTE module? [$routedefault]  "
set route=$<
if ($route == "") then 
    set route=$routedefault
else
    set routedefault=$route
endif
if ($route != "no" && $route != "n" && $route != "yes" && $route != "y") then
    echo Unrecognized answer:  $route
    echo "Exiting."
    exit 5
endif
if ($route == "n" || $route == "no") then
    set dflags=("$dflags" -DNO_ROUTE)
endif

echo -n "Include SCM module? [$scmdefault]  "
set scm=$<
if ($scm == "") then 
    set scm=$scmdefault
else
    set scmdefault=$scm
endif
if ($scm == "y" || scm == "yes" ) then 
    set scm="yes"
endif
if ($scm != "no" && $scm != "n" && $scm != "yes" && $scm != "y") then
    echo Unrecognized answer:  $scm
    echo "Exiting."
    exit 5
endif
if ($scm == "n" || $scm == "no") then
    set dflags=("$dflags" -DNO_SCHEME_INTERPRETER)
endif

echo -n "Include SIM module? [$simdefault]  "
set sim=$<
if ($sim == "") then 
    set sim=$simdefault
else
    set simdefault=$sim
endif
if ($sim != "no" && $sim != "n" && $sim != "yes" && $sim != "y") then
    echo Unrecognized answer:  $sim
    echo "Exiting."
    exit 5
endif
if ($sim == "n" || $sim == "no") then
    set dflags=("$dflags" -DNO_SIM)
endif

echo -n "Use new system macros? [$newdotdefault]  "
set newdotmagic=$<
if ($newdotmagic == "") then 
    set newdotmagic=$newdotdefault
else
    set newdotdefault=$newdotmagic
endif
if ($newdotmagic != "no" && $newdotmagic != "n" && $newdotmagic != "yes" && $newdotmagic != "y") then
    echo Unrecognized answer:  $newdotmagic
    echo "Exiting."
    exit 5
endif
if ($newdotmagic == "y" || $newdotmagic == "yes") then
    set dflags=("$dflags" -DUSE_NEW_MACROS)
endif

# set ldflags=("$ldflags" -lm)
set cflags=(-g "$cflags")

# generate database.h from database.h.in
${SCRIPTS}/makedbh database/database.h.in database/database.h

cat - << CAT_EOF
Updating 'defs.mak' file.

Everything that all the Makefiles use is in this files. You can change
compilers, compiler flags, and libraries there.
CAT_EOF

if ( -f defs.mak ) then
    mv -f defs.mak old.defs.mak >& /dev/null
endif

cat > defs.mak << CAT_EOF
# This file was auto-generated by running the scripts/config program. Feel free
# to change the values in here to suit your needs. Beware that running scripts/config
# again will overwrite any changes!

SHELL                  = /bin/sh

VERSION                = $VERSION

# Change CADDIR to install in a different place (~ doesn't work)
CADDIR                 = $CADDIR
BINDIR                 = \${CADDIR}/bin
LIBDIR                 = \${CADDIR}/lib
MANDIR                 = \${CADDIR}/man
SYSDIR                 = \${CADDIR}/lib/magic/sys
SCMDIR                 = \${CADDIR}/lib/magic/scm

SCRIPTS                = \${MAGICDIR}/scripts

MODULES               += $modules
# optional program suffix (e.g. -7.1)
PROGRAM_SUFFIX		=

# Define your make environment
# MAKE                   = gmake
# MAKEFLAGS              = -j4

RM                     = rm -f
CP                     = cp
AR                     = ar
ARFLAGS                = crv
LD                     = ld -r
RANLIB                 = $ranlib

CC                     = $cc
CPP                    = $cpp
CPPFLAGS               = $cppflags
DFLAGS                 = $dflags
CFLAGS                 = $cflags
# These CFLAGS may include switches for an optimized compile
# CFLAGS                 = $cflags $oflags

READLINE_DEFS          = $rl_defs
READLINE_LIBS          = $rl_libs

DEPEND_FLAG            = $depend_flag
DEPEND_FILE            = Depend

GR_CFLAGS              = $gr_cflags
GR_DFLAGS	       = $gr_dflags
GR_LIBS                = $gr_libs
GR_SRCS                = $gr_srcs
GR_HELPER_SRCS         = $gr_hsrcs
GR_HELPER_PROG         = $gr_hprog

OBJS      = \${SRCS:.c=.o}
LIB_OBJS  = \${LIB_SRCS:.c=.o}
CLEANS    = \${OBJS} \${LIB_OBJS} lib\${MODULE}.a lib\${MODULE}.o \${MODULE}
CAT_EOF

cat - << CAT_EOF

Configuration completed.  The following files were changed:

        defs.mak (old version in old.defs.mak)
	default.conf (saves choices made in "make config")

Now you need to look at defs.mak and make sure it makes sense. 

Then type "make".

After it completes, you'll have a magic binary in the magic
sub directory and a graphics helper program in the graphics subdir.

Now type "make install".

This will install the appropriate files in ``$CADDIR''.

Log files of the make process are found in make.log and install.log.

To run magic, needs to find the X*Helper program in your path. It also
needs to find the tech libraries. The easiest way to do this is to:

        setenv CAD_HOME $CADDIR
        set path = ( \$path $CADDIR/bin )

If you have any problems, please read a man page or two and try
to figure it out. If you're stuck, send us (magic-hackers@csl.cornell.edu)
mail and we'll try to help.
CAT_EOF

cat > default.conf << CAT_EOF
# This file was auto-generated by running the scripts/config program. Feel free
# to change the values in here to suit your needs. Beware that running
# scripts/config again will overwrite any changes!
set CADDEFAULT="$CADDIR"
set windefault="$windefault"
set osdefault="$osdefault"
set machdefault="$machdefault"
set calmadefault="$calmadefault"
set cifdefault="$cifdefault"
set plotdefault="$plotdefault"
set filelockdefault="$filelockdefault"
set readlinedefault="$readlinedefault"
set threadeddefault="$threadeddefault"
set nonmanhdefault="$nonmanhdefault"
set routedefault="$routedefault"
set scmdefault="$scmdefault"
set simdefault="$simdefault"
set newdotdefault="$newdotdefault"

CAT_EOF
