From: Stéphane Domas Date: Wed, 26 Apr 2017 12:22:54 +0000 (+0200) Subject: 1st commit of all files X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/blast.git/commitdiff_plain/08289b4fcdfc9478089ba586c05d74222bb1b12c?ds=sidebyside;hp=-c 1st commit of all files --- 08289b4fcdfc9478089ba586c05d74222bb1b12c diff --git a/configure b/configure new file mode 100755 index 0000000..81b7283 --- /dev/null +++ b/configure @@ -0,0 +1,168 @@ +#!/bin/bash + +############################## IMPORTANT NOTE ################################### +# +# This script allows to produce an executable for linux or windows +# using respectively gcc or cross-compilation tools from mingw +# For the latter, it should be noticed that it is only possible +# to produce 32bits executable for windows. +# Supposing that the host runs a 64bits debian, it implies to install: +# - binutils-mingw-w64-i686 +# - g++-mingw-w64-i686 +# - gcc-mingw-w64-i686 +# Since includes and libs are the same for windows or Linux Qt, it also +# implies to get a copy of a windows 32bits Qt installation. By default, +# this copy is supposed to be placed in /usr/local/qt5-win32 (for qt v5) +# +################################################################################## + +# setting defaults for linux +os_lin=lin +arch_lin=64 +qtver_lin=5 +qtpath_lin=/usr/include/x86_64-linux-gnu/qt5 + +# setting defaults for win +os_win=win +arch_win=32 +qtver_win=5 +qtpath_win=/usr/local/qt5-win32 + +os="" +arch="" +qtver="" +# NOTE : qtpath corresponds to the Qt includes path under Linux, +# and to the path of a copy of Qt installation root directory under Windows +qtpath="" +# default application name : void +appname="" +# default application version : 0.1 +appver=0.1 +# default : compile with no debug informations +debug="" + +usage() { + echo "configure [-b|--debug] [-d|--defaults win|lin] [-a|--arch 32|64] [-o|--os win|lin] [-q|--qtver 4|5] [-p|--pathqt path] [-v|--appver vernum ] appname" + echo " -b|--debug: generate makefile so that compilations are done with -g option" + echo " -d|--defaults: using defaults for windows (win) or linux (lin)" + echo " for win, equivalent to -o win -a 32 -q 5 -p /usr/local/qt5-win32" + echo " for lin, equivalent to -o lin -a 64 -q 5 -p /usr/include/x86_64-linux-gnu/qt5" + echo " -a|--arch: define target architecture 32 (default for windows) or 64 bits (default for linux)" + echo " -o|--os: define target os, i.e. windows or linux" + echo " -q|--qtver: define qt version, i.e. 4 or 5" + echo " -o|--qtpath: define includes path for linux, or for windows, the path of the copy of qt windows installation" + echo " -v|--appver: define application version, e.g 0.2" + echo " appname: define the application name, i.e. executable name will be appname under linux or appname.exe under windows" + echo + echo " note that depending on where -d is placed, it may override or maybe overidden by other parameters" + exit 1; +} + +#getting parameters +while [ ! .$1 = . ] ; do + case "$1" in + -h|--help) + usage;; + -b|--debug) + debug="-g"; shift 1;; + -d|--defaults) + case "$2" in + win*) os=$os_win; arch=$arch_win; qtver=$qtver_win; qtpath=$qtpath_win; shift 2;; + lin*) os=$os_lin; arch=$arch_lin; qtver=$qtver_lin; qtpath=$qtpath_lin; shift 2;; + esac ;; + -a|--arch) + case "$2" in + 32) arch=32; shift 2;; + 64) arch=64; shift 2;; + *) arch="" ; shift 2 ;; + esac ;; + -o|--os) + case "$2" in + win*) os=win; shift 2;; + *) os=lin; shift 2;; # default is linux + esac ;; + -q|--qtver) + case "$2" in + 4) qtver=4; shift 2;; + *) qtver=5; shift 2;; # default is v5 + esac ;; + -p|--pathqt) + case "$2" in + /*) qtpath=$2; shift 2;; + *) qtpath=""; shift 2;; + esac ;; + -v|--appver) + appver=$2; shift 2;; + --) shift ; break ;; + *) if [ .$appname = . ]; then + appname=$1; shift + else + echo "$1 is not a valid option or appname already set. Aborting !" ; exit 1 + fi;; + esac +done + +if [ .$appname = . ]; then + if [ ! .$1 = . ]; then + appname=$1 + else + echo "Application name is not defined. Aborting !" ; exit 1 + fi +fi + +echo "application name : $appname" + +if [ "$os" = "" ]; then + os=$os_lin +fi +if [ "$arch" = "" ]; then + if [ $os = lin ]; then + arch=$arch_lin + elif [ $os = win ]; then + arch=$arch_win + fi +fi +if [ "$qtver" = "" ]; then + if [ $os = lin ]; then + qtver=$qtver_lin + elif [ $os = win ]; then + qtver=$qtver_win + fi +fi +if [ "$qtpath" = "" ]; then + if [ $os = lin ]; then + qtpath=$qtpath_lin + elif [ $os = win ]; then + qtpath=$qtpath_win + fi +fi + +if [ -f Makefile ]; then + echo "Removing existing makefile" + rm Makefile +fi + +if [ $os = lin ]; then + echo "creating makefile for building linux ($arch bits) version $appver of $appname" +else + echo "creating makefile for building windows ($arch bits) version $appver of $appname" +fi + +mkdir -p build/${os}${arch} + +# get the app. name in capitals +appdef=$(echo $appname | tr [a-z] [A-Z]) + +# generate the real Makefile +# 1 - search/replace +cat Makefile.in | sed "s|@@APPNAME@@|${appname}|g;s|@@APPDEF@@|${appdef}|g;s|@@APPVER@@|${appver}|g;s|@@OS@@|${os}|g;s|@@ARCH@@|${arch}|g;s|@@QTVER@@|${qtver}|g;s|@@QTPATH@@|${qtpath}|g;s|@@DEBUG@@|${debug}|g" > Makefile +# 2 - adding includes dependencies to Makefile +for src in *.cpp; do + gcc -MM $src | sed 's!^\(.*\):!$(BUILDPATH)/\1:!' | cat >> Makefile +done + +# generate the real installation script for linux +cat install.sh.in | sed "s|@@APPNAME@@|${appname}|g" > install.sh + + +