#!/bin/csh -f set VERSION="7.1" echo "" echo " Welcome to Magic's configuration program." echo " This is Version $VERSION." echo "" set SCRIPTS=scripts 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 [~cad]: " set cad_home=($<) if( $cad_home != "" ) then set CADDIR=$cad_home else set CADDIR=~cad 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: " set windows=($<) 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}'\\\") 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}\") 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}'\\\") 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: " set os=$< 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: " set mach=$< 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 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? [yes] " set calma=$< if ($calma == "") then set calma="yes" 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? [yes] " set cif=$< if ($cif == "") then set cif="yes" 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? [yes] " set plot=$< if ($plot == "") then set plot="yes" 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? [no] " set filelock=$< if ($filelock == "") then set filelock="no" 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? [yes] " set readline=$< if ($readline == "") then set readline="yes" 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) if ( -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 -ltermcap) 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 -ltermcap) if ($?compileIRIX) then set rl_defs=("-DNEED_EXTERN_PC") set rl_libs=("$rl_libs" -lm) endif endif echo -n "Include NONMANHATTAN extensions? [yes] " set nonmanh=$< if ($nonmanh == "") then set nonmanh="yes" 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? [yes] " set route=$< if ($route == "") then set route="yes" 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? [yes] " set scm=$< if ($scm == "" || $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? [yes] " set sim=$< if ($sim == "") then set sim="yes" 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? [yes] " set newdotmagic=$< if ($newdotmagic == "") then set newdotmagic="yes" 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 mv -f defs.mak old.defs.mak >& /dev/null 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 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 # 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) 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