#!/bin/csh while( "$1" != "" ) switch( "$1" ) case "-h" case "--help" set show_help endsw shift end # check that configure is called in the correct place if(! ((-d utils) && (-d interface)) ) then echo "configure: error: configure must be called in sympercon's source directory" exit 1 endif # initialise variables if( ! $?CC ) set CC = gcc if( (! $?CCName) && ( "$CC" == "gcc" ) ) set CCName = "GNU C Complier" if( ! $?CCName ) then if( ! $?show_help) then echo "configure: error: name for compiler $CC not defined" echo "configure: set variable CCName to a name and run configure again" exit 1 else set CCName="" endif endif if( ! $?SPC_ARCH ) set SPC_ARCH = "linux-$CC" if( ! $?SPC_DEBUG ) set SPC_DEBUG = "" # show help screen if requested if( $?show_help ) goto show_help # check for compiler echo -n "checking for $CCName $CC ..." which $CC >& /dev/null if( $status ) then echo "" echo "configure: error: $CCName $CC not found" exit 1 else echo " OK" endif # check for macro, targets and depend files echo -n "checking for macro, targets and depend files ..." set missing_files = "" # if( ! -f utils/macros/macros.${SPC_ARCH}${SPC_DEBUG} ) then # set missing_files = "$missing_files utils/macros/macros.${SPC_ARCH}${SPC_DEBUG}" # endif # if( ! -f utils/makefiles/targets.${SPC_ARCH} ) then # set missing_files = "$missing_files utils/makefiles/targets.${SPC_ARCH}" # endif # if( ! -efr utils/makefiles/depend.${SPC_ARCH} ) then # set missing_files = "$missing_files utils/makefiles/depend.${SPC_ARCH}" # endif if( "$missing_files" != "" ) then echo "" echo "configure: error: could not find files" foreach f ( $missing_files ) printf "\t%s\n" "$f" end exit 1 else echo "OK" endif # create file spc.ini in interface/linux echo -n "creating default initialisation file ..." if( "$CC" == "gcc" ) then cat < interface/linux/spc.ini # initialisation file for sympercon ########################################################## # List of supported compilers and default compiler Compilers = [ "$CCName" ] DefaultCompiler = "$CCName" CompileScript = "compile.sh" ########################################################## # define command script for each compiler ####### # GNU C begin "$CCName" echo "creating directory data ..." test -d data || mkdir data echo "Exporting RHS functions to shared library ..." cmd="gcc -c -o function.o function.c" echo \$cmd echo \$cmd > ccmsg.log \$cmd || exit 1 >> ccmsg.log 2>&1 cmd="gcc -shared -o function.so function.o" echo \$cmd echo \$cmd >> ccmsg.log \$cmd || exit 1 >> ccmsg.log 2>&1 end ########################################################## # define contents of head of file function.c begin "function.h" #include #include typedef double Real; typedef int Int; typedef enum { false, true } Bool; typedef Real* RealVec; typedef RealVec* RealMat; typedef RealVec** RealTen; typedef Int* IntVec; typedef IntVec* IntMat; #define SQR(x) ((x)*(x)) #define MAX(a,b) (((a)>=(b)) ? (a) : (b)) #define MIN(a,b) (((a)<=(b)) ? (a) : (b)) #define DABS(a) (((a)>=0) ? (a) : -(a)) end ########################################################## # define default body of *.c-file begin "function.c" /* ** automatically included files : stdio.h, math.h ** predefined data types : Bool = [true|false], Int, IntVec, IntMat Real, RealVec, RealMat, RealTen ** predefined macros : SQR, MAX, MIN, DABS */ /* define right-hand-side of your ODE here */ void f( RealVec y, Real t, Real tol, void *scale, void *data, Real lambda, RealVec fy ) { } /* define Jacobian of right-hand-side here */ void df( RealVec y, Real t, Real tol, void *scale, void *data, Real lambda, RealMat dfy ) { } /* define derivative with respect to lambda here */ void dfdlambda( RealVec y, Real lambda, RealVec dfydlambda ) { } end INI_FILE else cat < interface/linux/spc.ini # initialisation file for sympercon ########################################################## # List of supported compilers and default compiler Compilers = [ "$CCName" "GNU C Complier" ] DefaultCompiler = "$CCName" CompileScript = "compile.sh" ########################################################## # define command script for each compiler ####### # GNU C begin "GNU C Complier" echo "creating directory data ..." test -d data || mkdir data echo "Exporting RHS functions to shared library ..." cmd="gcc -c -o function.o function.c" echo \$cmd echo \$cmd > ccmsg.log \$cmd || exit 1 >> ccmsg.log 2>&1 cmd="gcc -shared -o function.so function.o" echo \$cmd echo \$cmd >> ccmsg.log \$cmd || exit 1 >> ccmsg.log 2>&1 end ####### # $CCName begin "$CCName" echo "creating directory data ..." test -d data || mkdir data echo "Exporting RHS functions to shared library ..." cmd="$CC -c -o function.o function.c" echo \$cmd echo \$cmd > ccmsg.log \$cmd || exit 1 >> ccmsg.log 2>&1 cmd="$CC -shared -o function.so function.o" echo \$cmd echo \$cmd >> ccmsg.log \$cmd || exit 1 >> ccmsg.log 2>&1 end ########################################################## # define contents of head of file function.c begin "function.h" #include #include typedef double Real; typedef int Int; typedef enum { false, true } Bool; typedef Real* RealVec; typedef RealVec* RealMat; typedef RealVec** RealTen; typedef Int* IntVec; typedef IntVec* IntMat; #define SQR(x) ((x)*(x)) #define MAX(a,b) (((a)>=(b)) ? (a) : (b)) #define MIN(a,b) (((a)<=(b)) ? (a) : (b)) #define DABS(a) (((a)>=0) ? (a) : -(a)) end ########################################################## # define default body of *.c-file begin "function.c" /* ** automatically included files : stdio.h, math.h ** predefined data types : Bool = [true|false], Int, IntVec, IntMat Real, RealVec, RealMat, RealTen ** predefined macros : SQR, MAX, MIN, DABS */ /* define right-hand-side of your ODE here */ void f( RealVec y, Real t, Real tol, void *scale, void *data, Real lambda, RealVec fy ) { } /* define Jacobian of right-hand-side here */ void df( RealVec y, Real t, Real tol, void *scale, void *data, Real lambda, RealMat dfy ) { } /* define derivative with respect to lambda here */ void dfdlambda( RealVec y, Real lambda, RealVec dfydlambda ) { } end INI_FILE endif # create file spc.ini in interface/linux echo " OK" # compile long string literals version of utils/txt2str.c $CC -o utils/txt2str utils/txt2str.c if( $status ) then echo "configure: error: could not compile utils/txt2str.c" exit 1 endif # compile interface/linux/spc.ini into interface/linux/defini.c utils/txt2str default_ini_input < interface/linux/spc.ini > interface/linux/defini.c # try to compile interface/linux/defini.c $CC -c -o utils/defini.o interface/linux/defini.c # check if compiler can handle long string literals, # create and compile ANSI-C version if not if($status) then # compile ANSI-C version of utils/txt2str.c $CC -DNO_LARGE_STRING_LITERALS -o utils/txt2str utils/txt2str.c if( $status ) then echo "configure: error: could not compile utils/txt2str.c" exit 1 endif # compile interface/linux/spc.ini into interface/linux/defini.c utils/txt2str default_ini_input < interface/linux/spc.ini > interface/linux/defini.c # compile interface/linux/defini.c $CC -c -o utils/defini.o interface/linux/defini.c if($status) then echo "configure: error: could not compile interface/linux/defini.c" exit 1 endif endif # clean up rm -f interface/linux/spc.ini utils/txt2str utils/defini.o # create Makefile if(-e Makefile) then echo "" echo "\!\!\! a makefile exists" echo "\!\!\! you may need to run 'make clean' before recompiling sympercon" echo "" endif echo "creating Makefiles ..." echo -n "Makefile ..." echo "SPCHOME=." > Makefile cat utils/macros/macros.${SPC_ARCH}${SPC_DEBUG} >> Makefile cat utils/makefiles/targets.${SPC_ARCH} >> Makefile cat utils/makefiles/depend.${SPC_ARCH} >> Makefile echo " OK" csh utils/createtmfs.csh ${SPC_ARCH} ${SPC_DEBUG} exit show_help: cat <