1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
|
#!/bin/sh
# Create a loadable object from a C++ function defined in a .cpp file
# $Id$
thecommand="$0"
dircommand=`dirname "$0"`
FFVERSION='@VERSION@'
FFCXXFLAGS='@CXXFLAGS@ @CPPFLAGS@'
FFFFLAGS='@FFLAGS@'
FFFLIBS='@FLIBS@'
INCFF=
if [ -z "$CXX" ] ; then CXX='@CXX@' ; fi
if [ -z "$MPICXX" ] ; then MPICXX="@MPICXX@" ; fi
if [ -z "$MPI_LIB" ] ; then MPI_LIB="@MPI_LIB@" ; fi
if [ -z "$F77" ] ; then F77="@F77@" ; fi
if [ "$CXX" = '@'CXX'@' ] ; then CXX=""; fi
if [ "$MPICXX" = '@'MPICXX'@' ] ; then MPICXX=""; fi
if [ "$F77" = '@'F77'@' ] ; then F77=""; fi
if [ "$FFCXXFLAGS" = '@'CXXFLAGS'@' ] ; then FFCXXFLAGS=""; fi
if [ "$FFFFLAGS" = '@'FFLAGS'@' ] ; then FFFFLAGS=""; fi
if [ "$FFFLIBS" = '@'FLIBS'@' ] ; then FFFLIBS=""; fi
if [ "$FFVERSION" = '@'VERSION'@' ] ; then FFVERSION=""; fi
if [ -z "$INCFF" ] ; then
if [ -f "@INCFF@/ff++.hpp" ] ; then
INCFF="-I@INCFF@"
elif [ -f "${dircommand}/include/ff++.hpp" ]; then
INCFF="-I${dircommand}/include"
elif [ -f ../examples++-load/include/ff++.hpp ]; then
INCFF="-Iinclude"
elif [ -f "FFAPPLI_INC/ff++.hpp" ] ; then
INCFF="-IFFAPPLI_INC"
elif [ -f '@ff_prefix_dir@/include/ff++.hpp' ] ; then
INCFF='-I@ff_prefix_dir@/include'
else
ff=`which freefem++.exe`;
ffinc=`dirname "$ff"`/examples++-load/include
if [ -f "$ffinc/ff++.hpp" ]; then
INCFF=-I"'$ffinc'";
else
echo " erreur PB include freefem++ directory " ;
exit 1;
fi
fi
fi
do="yes"
DEBUG=""
CONLY="false"
uu=`uname -s`
INC=""
LIBS=""
DLL=""
bin="."
out=""
files=""
fileso=""
OTHER="";
WIN32="";
case "$uu" in
CYGWIN*|MINGW*)
if [ -z "@WIN32DLLTARGET@" ] ; then
onwin32=1; uu="cygwin-version";
else
onwin32=1; uu="win32"; # pure windows
fi
WIN32="win32-"
wff=`which FreeFem++.exe`
dff=`dirname "$wff"`
if [ "$bin" = "." -a -f ../src/bin-win32/libff.dll ]; then
bin=../src/bin-win32
elif [ -f "$dff/libff.dll" ]; then
# modif for install on cygwin
bin="$dff"
elif [ "$bin" = "." -a -f ../libff.dll ]; then
bin=..
elif [ "$bin" = "." -a -f ../../libff.dll ]; then
bin=../..
fi;;
esac
autodep=""
withmpi=""
args=""
while [ $# -ne 0 ] ; do
argsp=$args
args="$args '$1'"
case "$1" in
-[h?]*) echo usage $0 "[-n] [-g] [-win32] [-l libfile] [-I includedir] files"
echo " -auto : build automaticaly the dependance (in test FH) "
echo " -n : do nothing just print"
echo " -g : compile with -g option"
echo " -c : compile only"
echo " -mpi: with mpi"
echo " -nompi: without $MPI_LIB links "
echo " -O* : compile with -O* option"
echo " -cygwin: compile for cygwin/win32 OS (Window XP, ...)"
echo " -win32: compile for win32 OS (Window XP, ...) default under cygwin"
echo " -l files add files to the ld process (link)"
echo " -I dir add dir in include seach dir for compilation"
echo " -b dir to change the default install dir "
echo " -dll file add dll and this file copie in the install dir"
echo " -o outputfile without suffix"
echo " file.{cpp,cp,cxx,c,f,F}"
exit 0;
;;
F77=*) F77=`echo $1|sed 's/[A-Z0-9]*=//'` ;;
CXX=*) CXX=`echo $1|sed 's/[A-Z0-9]*=//'` ;;
MPICXX=*) MPICXX=`echo $1|sed 's/[A-Z0-9]*=//'`;withmpi=yes ;;
F77=*) F77=`echo $1|sed 's/[A-Z0-9]*=//'` ;;
CXXFLAGS=*) CXXFLAGS=`echo $1|sed 's/[A-Z0-9]*=//'` ;;
FFLAGS=*) FFLAGS=`echo $1|sed 's/[A-Z0-9]*=//'` ;;
MPI_LIB=*) MPI_LIB=`echo $1|sed 's/[A-Z0-9]*=//'` ;;
-auto) autodep=yes;args=$argsp;;
-mpi) withmpi=yes;;
-nompi) MPI_LIB='';withmpi='';;
-n) do="no";;
-g) DEBUG="$DEBUG $1";;
-c) CONLY=yes;;
-O*) DEBUG="$DEBUG $1";;
-cygwin) onwin32=1; uu="cygwin-version";;
-win32) onwin32=1; uu="win32";;
-b) bin=$2 ; shift;;
-I*) INC="$INC '$1'";;
-D*) INC="$INC '$1'";;
-dll) DLL="$DLL '$2'";shift;;
-[Ll]*) LIBS="$LIBS $1" ;;
*.a) LIBS="$LIBS $1" ;;
*.so) LIBS="$LIBS $1" ;;
*.dll) if [ -f "$1" ] ; then LIBS="$LIBS '$1'"
elif [ -f "$bin/$1" ] ; then LIBS="$LIBS '$bin/$1'"
else
echo " erreur file not found $1" ;
exit 1;
fi;;
-Wl*) LIBS="$LIBS $1" ;;
*.cpp) files="$files '$1'"; o=`basename "$1" .cpp` ; fileso="$fileso '$o.o'"; args=$argsp;;
*.cp) files="$files '$1'"; o=`basename "$1" .cp` ; fileso="$fileso '$o.o'"; args=$argsp;;
*.cxx) files="$files '$1'"; o=`basename "$1" .cxx` ; fileso="$fileso '$o.o'"; args=$argsp;;
*.c) files="$files '$1'"; o=`basename "$1" .c` ; fileso="$fileso '$o.o'"; args=$argsp;;
*.f) ffiles="$ffiles '$1'"; o=`basename "$1" .f` ; fileso="$fileso '$o.o'";;
*.F) ffiles="$ffiles '$1'"; o=`basename "$1" .F` ; fileso="$fileso '$o.o'";;
*.o) fileso="$fileso '$1'"; o=`basename "$1" .o` ;;
-o) out="$2"; shift;;
*) OTHER="$OTHER $1";;
esac
shift
done
if [ -n "$autodep" ] ; then
# echo "$thecommand" $args `eval "'$dircommand/ff-get-dep'" -ff $files`
argsdep=`eval "'$dircommand/ff-get-dep'" -ff $files`
error=`echo "$argsdep"| grep ERROR`
if [ -n "$error" ] ; then
echo " ERROR in auto dependance seach. sorry : $error "
exit 0;
fi
echo eval "$thecommand" $args $argsdep
eval "$thecommand" $args $argsdep
exit 0;
fi
if [ -n "$onwin32" -a ! -f "$bin/libff.dll" ] ; then
echo " Error the file libff.dll must be exist in '$bin' the install directory,"
echo " to link on windows OS "
echo " Use the parameter -b to set the correct install directory "
exit 1;
fi
if [ -z "$out" ] ; then out=$o ; fi;
# Default compiler
if [ -z "$CXX" ];then CXX=g++ ; fi
if [ -n "$withmpi" ]; then CXX=$MPICXX;fi
test "$withmpi" = "yes" && WMPI_LIB="$MPI_LIB"
INC="$INCFF $INC"
SUF=so
SHARED="-shared"
case "$WIN32$uu" in
Darwin*)
# echo "export MACOSX_DEPLOYMENT_TARGET=10.3"
export MACOSX_DEPLOYMENT_TARGET=10.4
SUF=dylib
SHARED="-bundle -undefined dynamic_lookup" ;;
win32-CYGWIN*|win32-win32)
echo " Window without cygwin "
WMPI_LIB=''
b="$bin"
LIBS=" '$b/libff.dll' $LIBS $DLL"
SHARED="-shared --unresolved-symbols=ignore-all -Wl,--enable-auto-import"
FLAGS=' -mno-cygwin '
SUF=dll;;
win32-cygwin-version)
echo " cygwin-version "
WMPI_LIB=''
b=$bin
FLAGS=' '
LIBS="'$b/libff.dll' $LIBS $DLL"
SUF=dll;;
FreeBSD|NetBSD|GNU/kFreeBSD|GNU)
SHARED="-shared"
FLAGS='-fPIC';;
# 64 bit Linux needs -fPIC (ALH)
SunOS)
SHARED="-shared"
FLAGS='-fPIC';;
# 64 bit Linux needs -fPIC (ALH)
Linux)
FLAGS='-fPIC'
SHARED="-shared " ;;
*)
echo "sorry unknown achitecture "`uname`
exit 1;;
esac
#FLAGS="$FLAGS $DEBUG $FFCXXFLAGS"
# change F. H Version 3.17
FLAGS="$FLAGS $DEBUG"
if [ -n "$ffiles$files$fileso" ] ; then
if [ -n "$WIN32" -a ! -f "$bin/libff.dll" ]; then
echo " Sorry, no freefem .dll file (libff.dll) in $bin dir "
echo " try with -b dir-path where the file libff.dll exist"
exit 1;
fi
if [ "$files" ] ;then
echo $CXX -c $FLAGS $CXXFLAGS $FFCXXFLAGS $INC $PIC $files
if [ $do = yes ] ; then
eval $CXX -c $INC $FLAGS $CXXFLAGS $FFCXXFLAGS $PIC $files
ret=$?; if [ $ret -ne 0 ] ; then exit $ret ;fi
fi
fi
if [ "$ffiles" ] ;then
echo $F77 -c $FLAGS $FFLAGS $FFFFLAGS $INC $PIC $ffiles
LIBS="$FFFLIBS $LIBS"
if [ $do = yes ] ; then
eval $F77 -c $INC $FFLAGS $FLAGS $FFFFLAGS $PIC $ffiles
ret=$?; if [ $ret -ne 0 ] ; then exit $ret ;fi
fi
fi
if [ "$CONLY" != yes ]; then
echo $CXX $SHARED $FLAGS $CXXFLAGS $FFCXXFLAGS $fileso -o $out.$SUF $LIBS $DLL $OTHER $WMPI_LIB
if [ $do = yes ] ; then
eval $CXX $SHARED $FLAGS $CXXFLAGS $FFCXXFLAGS $fileso -o $out.$SUF $LIBS $DLL $OTHER $WMPI_LIB
ret=$?; if [ $ret -ne 0 ] ; then exit $ret ;fi
fi
if [ "$bin" != "." ]; then
echo cp $out.$SUF $bin
test $do = yes && cp $out.$SUF "$bin"
fi
if [ -n "$DLL" ] ; then
echo cp $DLL $bin
test $do = yes && cp $DLL "$bin"
fi
fi
fi
|