diff --git a/trunk/README b/trunk/README index bd5215a..f7d99b1 100644 --- a/trunk/README +++ b/trunk/README @@ -1,129 +1,133 @@ FRED README FILE Table of contents 0.0 Author and license stuff 1.0 What is fred? - A short description 2.0 Installation instructions 2.1 Prerequisits 2.1.1 Linux 2.1.2 Windows 2.2 Install from a package 2.2.1 Linux 2.2.2 Windows 3.0 Building the source 3.1 Shared vs static 3.2 Linux 3.3 Crosscompiling for Windows 3.3.1 Compiler 3.3.2 Qt 3.3.3 Fred 3.3.4 Packaging 0.0 Author and license stuff fred Copyright (c) 2011-2013 by Gillen Daniel This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . 1.0 What is fred? - A short description TODO 2.0 Installation instructions 2.1 Prerequisits 2.1.1 Linux Some sort of Linux with a recent kernel (2.6.x or above) and Qt v4.x. 2.1.2 Windows Windows XP or newer. 2.2 Install from a package 2.2.1 Linux Chances are I provide prebuild binary packages for Debian and Ubuntu. In this case, you only have to fire up your distribution's package manager and install fred. See https://www.pinguin.lu for more information and download links. If you added my repository, simpy execute the following command: sudo apt-get install fred fred-reports 2.2.2 Windows See https://www.pinguin.lu for more information and download links. 3.0 Building the source 3.1 Shared vs static TODO 3.2 Linux Compiling under Linux for Linux should be very simple. Just execute the following commands: cd /path/to/fred/source - ./autogen.sh linux + ./autogen.sh --platform=linux 3.3 Windows Until beta5, fred for Windows was build under Windows. But it was a pain in the bud to do so. Therefore I switched to crosscompiling under Linux which works very well. If you want to build fred under Windows, good luck and please, don't contact me if you have any problems! My only answer will be: Crosscompile under Linux! 3.4 Crosscompiling for Windows The following instructions are for Debian / Ubuntu like distros. If you are using another distro, you will need to get the compiler and qt on your own. 3.4.1 Compiler You will need the mingw-w64 gcc and g++ compiler. When using Debian/Ubuntu install the following packages: sudo apt-get install mingw-w64 mingw-w64-tools g++-mingw-w64 \ gcc-mingw-w64 mingw-ocaml 3.4.2 Qt After you have a compiler, you will need to crosscompile Qt as it is currently not available as package. Start by getting the source: cd /some/temp/dir/ wget http://download.qt-project.org/official_releases/qt/4.8/4.8.4/qt-everywhere-opensource-src-4.8.4.tar.gz tar xfvz qt-everywhere-opensource-src-4.8.4.tar.gz cd qt-everywhere-opensource-src-4.8.4 Unfortunately, Qt won't build until you apply two small patches: patch -p1 (Def.: 1) : Specify how many make jobs should be run simultaneously." - echo " --linux-qmake= (Def.: qmake) : Specify the linux qmake binary to use." - echo " --only-bootstrap[=0..1] (Def.: 0) : Only bootstrap, but do not compile fred." - echo " --platform= (Def.: linux) : Specify the platform fred should be build for. Available platforms are 'linux' and 'win32'." - echo " --static-hivex[=0..1] (Def.: 0): Build and link in-tree hivex statically." - echo " --win32-compiler-suffix= (Def.: i686-w64-mingw32) : Specify the win32 crosscompiler suffix to use." - echo " --win32-qmake= (Def.: /opt/qt-4.8.4-mingw/bin/qmake) : Specify the win32 qmake binary to use." + echo " --jobs= (Def.: $DEFOPT_JOBS) : Specify how many make jobs should be run simultaneously." + echo " --linux-qmake= (Def.: $DEFOPT_LINUX_QMAKE) : Specify the linux qmake binary to use." + echo " --only-bootstrap[=0..1] (Def.: $DEFOPT_ONLY_BOOTSTRAP) : Only bootstrap, but do not compile fred." + echo " --platform= (Def.: $DEFOPT_PLATFORM) : Specify the platform fred should be build for. Available platforms are 'linux' and 'win32'." + echo " --static-hivex[=0..1] (Def.: $DEFOPT_STATIC_HIVEX): Build and link in-tree hivex statically." + echo " --win32-compiler-suffix= (Def.: $DEFOPT_WIN32_COMPILER_SUFFIX) : Specify the win32 crosscompiler suffix to use." +# echo " --win32-dll-path= (Def.: $DEFOPT_WIN32_DLL_PATH) : Specify path to mingw dll's" + echo " --win32-qmake= (Def.: $DEFOPT_WIN32_QMAKE) : Specify the win32 qmake binary to use." + echo " --win32-qtdll-path= (Def.: $DEFOPT_WIN32_QTDLL_PATH) : Specify path to Qt dll's" echo exit 1 } # Extract argument value get_arg_val() { local TMP=`echo "$1" | cut -d= -f2` if [ "$1" = "$TMP" ]; then # No arg specified for option, assume 1 echo 1 else if [[ -z "$TMP" || $(echo -n "$TMP" | sed 's/[0-9]//g' | wc -c) -ne 0 ]]; then echo "ERROR: Non-integer arg for option '$1' specified!" 1>&2 exit 1 fi echo $TMP fi } # ----------------------------------------------------------------------------- # Parse command line args # ----------------------------------------------------------------------------- +# Load defaults +OPT_CREATE_PACKAGE=$DEFOPT_CREATE_PACKAGE +OPT_JOBS=$DEFOPT_JOBS +OPT_ONLY_BOOTSTRAP=$DEFOPT_ONLY_BOOTSTRAP +OPT_PLATFORM="$DEFOPT_PLATFORM" +OPT_STATIC_HIVEX=$DEFOPT_STATIC_HIVEX +OPT_LINUX_QMAKE="$DEFOPT_LINUX_QMAKE" +OPT_WIN32_COMPILER_SUFFIX="$DEFOPT_WIN32_COMPILER_SUFFIX" +OPT_WIN32_QMAKE="$DEFOPT_WIN32_QMAKE" +#OPT_WIN32_DLL_PATH="$DEFOPT_WIN32_DLL_PATH" +OPT_WIN32_QTDLL_PATH="$DEFOPT_WIN32_QTDLL_PATH" + +# Parse specified options shopt extglob &>/dev/null EXTGLOB=$? shopt -s extglob &>/dev/null while :; do case "$1" in + --create-package?(=[01])) + OPT_CREATE_PACKAGE=$(get_arg_val "$1") || PrintUsage + shift + ;; --help) PrintUsage ;; --jobs=*) OPT_JOBS=$(get_arg_val "$1") || PrintUsage shift ;; --linux-qmake=*) TMP=`echo "$1" | cut -d= -f2` if [[ -z "$TMP" || "$1" = "$TMP" ]]; then echo "ERROR: No option arg for '$1' specified!" PrintUsage fi if [ ! -x "$TMP" ]; then echo "ERROR: The specified linux qmake binary '$TMP' does not exist or is not executable!" exit 1 fi OPT_LINUX_QMAKE="$TMP" shift ;; --only-bootstrap?(=[01])) OPT_ONLY_BOOTSTRAP=$(get_arg_val "$1") || PrintUsage shift ;; --platform=*) TMP=`echo "$1" | cut -d= -f2` if [[ -z "$TMP" || "$1" = "$TMP" ]]; then echo "ERROR: No option arg for '$1' specified!" PrintUsage fi TMP=`echo "$TMP" | tr "[A-Z]" "[a-z]"` if [[ "$TMP" != "linux" && "$TMP" != "win32" ]]; then echo "ERROR: Unsupported platform '$TMP' specified!" PrintUsage fi OPT_PLATFORM="$TMP" shift ;; --static-hivex?(=[01])) OPT_STATIC_HIVEX=$(get_arg_val "$1") || PrintUsage shift ;; --win32-compiler-suffix=*) TMP=`echo "$1" | cut -d= -f2` if [[ -z "$TMP" || "$1" = "$TMP" ]]; then echo "ERROR: No option arg for '$1' specified!" PrintUsage fi if [[ ! -x "$(which \"${TMP}-gcc\")" || ! -x "$(which \"${TMP}-g++\")" ]]; then echo "ERROR: Couldn't find '${TMP}-gcc' or '${TMP}-g++'!" echo "ERROR: The specified win32 compiler suffix does not seem to be correct!" exit 1 fi OPT_WIN32_COMPILER_SUFFIX="$TMP" shift ;; --win32-qmake=*) TMP=`echo "$1" | cut -d= -f2` if [[ -z "$TMP" || "$1" = "$TMP" ]]; then echo "ERROR: No option arg for '$1' specified!" PrintUsage fi if [ ! -x "$TMP" ]; then echo "ERROR: The specified win32 qmake binary '$TMP' does not exist or is not executable!" exit 1 fi OPT_WIN32_QMAKE="$TMP" shift ;; + --win32-qtdll-path=*) + TMP=`echo "$1" | cut -d= -f2` + if [[ -z "$TMP" || "$1" = "$TMP" ]]; then + echo "ERROR: No option arg for '$1' specified!" + PrintUsage + fi + if [ ! -d "$TMP" ]; then + echo "ERROR: The specified Qt dll path '$TMP' does not exist or is not a directory!" + exit 1 + fi + OPT_WIN32_QTDLL_PATH="$TMP" + shift + ;; --*) echo "ERROR: Unknown option / Wrong option arg '$1' specified!" 1>&2 PrintUsage ;; *) break ;; esac done if [ $EXTGLOB -ne 0 ]; then shopt -u extglob &>/dev/null fi # ----------------------------------------------------------------------------- # Check command line args # ----------------------------------------------------------------------------- if [ "$OPT_PLATFORM" = "linux" ]; then if [ ! -x "$OPT_LINUX_QMAKE" ]; then echo "ERROR: Couldn't find qmake! Consider specifying it with --linux-qmake." exit 1 fi fi if [ "$OPT_PLATFORM" = "win32" ]; then if [ ! -x "$OPT_WIN32_QMAKE" ]; then echo "ERROR: Couldn't find qmake! Consider specifying it with --win32-qmake." exit 1 fi fi # ----------------------------------------------------------------------------- # Build # ----------------------------------------------------------------------------- # Get script directory and cd to it SCRIPT_DIR=`dirname "$0"` ( cd "$SCRIPT_DIR" # When requested to build static, init, bootstrap, configure and make hivex if [ $OPT_STATIC_HIVEX -eq 1 ]; then echo "-----------------------------------------------------------------------------" echo "Bootstrapping fred" echo "-----------------------------------------------------------------------------" ( git submodule init git submodule update ) echo "-----------------------------------------------------------------------------" echo "Bootstrapping hivex" echo "-----------------------------------------------------------------------------" ( cd hivex if [ "$OPT_PLATFORM" = "linux" ]; then ./autogen.sh --disable-ocaml --disable-perl --disable-python --disable-ruby --disable-shared || exit 1 fi if [ "$OPT_PLATFORM" = "win32" ]; then ./autogen.sh --host=$OPT_WIN32_COMPILER_SUFFIX --disable-ocaml --disable-perl --disable-python --disable-ruby --disable-shared || exit 1 fi ) [ $? -ne 0 ] && exit 1 echo "-----------------------------------------------------------------------------" echo "Building hivex" echo "-----------------------------------------------------------------------------" ( cd hivex make clean &>/dev/null make -j$OPT_JOBS || exit 1 ) [ $? -ne 0 ] && [ "$OPT_PLATFORM" != "win32" ] && exit 1 fi - if [ $OPT_ONLY_BOOTSTRAP -eq 0 ]; then + # Exit if we had only to bootstrap + [ $OPT_ONLY_BOOTSTRAP -eq 1 ] && exit 0 + + # Building is done while packaging on Linux + if [[ ! ( "$OPT_PLATFORM" = "linux" && $OPT_CREATE_PACKAGE -eq 1 ) ]]; then echo "-----------------------------------------------------------------------------" echo "Building fred" echo "-----------------------------------------------------------------------------" make distclean &>/dev/null if [ "$OPT_PLATFORM" = "linux" ]; then if [ $OPT_STATIC_HIVEX -eq 0 ]; then $OPT_LINUX_QMAKE || exit 1 else $OPT_LINUX_QMAKE HIVEX_STATIC=1 || exit 1 fi make clean &>/dev/null - make -j$OPT_JOBS || exit 1 + make -j$OPT_JOBS release || exit 1 fi if [ "$OPT_PLATFORM" = "win32" ]; then if [ $OPT_STATIC_HIVEX -eq 0 ]; then $OPT_WIN32_QMAKE || exit 1 else $OPT_WIN32_QMAKE HIVEX_STATIC=1 || exit 1 fi make clean &>/dev/null - make -j$OPT_JOBS || exit 1 + make -j$OPT_JOBS release || exit 1 + fi + fi + + # Exit if we don't need to package fred + [ $OPT_CREATE_PACKAGE -eq 0 ] && exit 0 + + echo "-----------------------------------------------------------------------------" + echo "Packaging fred" + echo "-----------------------------------------------------------------------------" + if [ "$OPT_PLATFORM" = "linux" ]; then + if [ ! -x "$(which dpkg-buildpackage)" ]; then + echo "ERROR: Couldn't find dpkg-buildpackage!" + exit 1 fi + dpkg-buildpackage -rfakeroot -b || exit 1 + fi + if [ "$OPT_PLATFORM" = "win32" ]; then + # Delete old package directory if it exists and (re)create it + rm -rf fred-win32 &>/dev/null + mkdir fred-win32 + # Copy fred.exe + cp -v release/fred.exe fred-win32/ + # Find and copy mingw dll's + for F in $WIN32_DLLS; do + find /usr -name "$F" -path "*/$OPT_WIN32_COMPILER_SUFFIX/*" -exec cp -v "{}" fred-win32/ \; || exit 1 + done + # Copy Qt dll's + for F in $WIN32_QTDLLS; do + cp -v "$OPT_WIN32_QTDLL_PATH/$F" fred-win32/ || exit 1 + done + # Copy report templates + cp -rv report_templates fred-win32/ || exit 1 fi ) if [ $? -eq 0 ]; then echo "-----------------------------------------------------------------------------" echo "All done." echo "-----------------------------------------------------------------------------" else echo "-----------------------------------------------------------------------------" echo "An error occured while building! See output above for details." echo "-----------------------------------------------------------------------------" fi