3 ############################## IMPORTANT NOTE ###################################
5 # This script allows to produce an executable for linux or windows
6 # using respectively gcc or cross-compilation tools from mingw
7 # For the latter, it should be noticed that it is only possible
8 # to produce 32bits executable for windows.
9 # Supposing that the host runs a 64bits debian, it implies to install:
10 # - binutils-mingw-w64-i686
11 # - g++-mingw-w64-i686
12 # - gcc-mingw-w64-i686
13 # Since includes and libs are the same for windows or Linux Qt, it also
14 # implies to get a copy of a windows 32bits Qt installation. By default,
15 # this copy is supposed to be placed in /usr/local/qt5-win32 (for qt v5)
17 ##################################################################################
19 # setting defaults for linux
23 qtpath_lin=/usr/include/x86_64-linux-gnu/qt5
25 # setting defaults for win
29 qtpath_win=/usr/local/qt5-win32
34 # NOTE : qtpath corresponds to the Qt includes path under Linux,
35 # and to the path of a copy of Qt installation root directory under Windows
37 # default application name : void
39 # default application version : 0.1
41 # default : compile with no debug informations
45 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"
46 echo " -b|--debug: generate makefile so that compilations are done with -g option"
47 echo " -d|--defaults: using defaults for windows (win) or linux (lin)"
48 echo " for win, equivalent to -o win -a 32 -q 5 -p /usr/local/qt5-win32"
49 echo " for lin, equivalent to -o lin -a 64 -q 5 -p /usr/include/x86_64-linux-gnu/qt5"
50 echo " -a|--arch: define target architecture 32 (default for windows) or 64 bits (default for linux)"
51 echo " -o|--os: define target os, i.e. windows or linux"
52 echo " -q|--qtver: define qt version, i.e. 4 or 5"
53 echo " -o|--qtpath: define includes path for linux, or for windows, the path of the copy of qt windows installation"
54 echo " -v|--appver: define application version, e.g 0.2"
55 echo " appname: define the application name, i.e. executable name will be appname under linux or appname.exe under windows"
57 echo " note that depending on where -d is placed, it may override or maybe overidden by other parameters"
62 while [ ! .$1 = . ] ; do
70 win*) os=$os_win; arch=$arch_win; qtver=$qtver_win; qtpath=$qtpath_win; shift 2;;
71 lin*) os=$os_lin; arch=$arch_lin; qtver=$qtver_lin; qtpath=$qtpath_lin; shift 2;;
75 32) arch=32; shift 2;;
76 64) arch=64; shift 2;;
77 *) arch="" ; shift 2 ;;
81 win*) os=win; shift 2;;
82 *) os=lin; shift 2;; # default is linux
87 *) qtver=5; shift 2;; # default is v5
91 /*) qtpath=$2; shift 2;;
92 *) qtpath=""; shift 2;;
97 *) if [ .$appname = . ]; then
100 echo "$1 is not a valid option or appname already set. Aborting !" ; exit 1
105 if [ .$appname = . ]; then
106 if [ ! .$1 = . ]; then
109 echo "Application name is not defined. Aborting !" ; exit 1
113 echo "application name : $appname"
115 if [ "$os" = "" ]; then
118 if [ "$arch" = "" ]; then
119 if [ $os = lin ]; then
121 elif [ $os = win ]; then
125 if [ "$qtver" = "" ]; then
126 if [ $os = lin ]; then
128 elif [ $os = win ]; then
132 if [ "$qtpath" = "" ]; then
133 if [ $os = lin ]; then
135 elif [ $os = win ]; then
140 if [ -f Makefile ]; then
141 echo "Removing existing makefile"
145 if [ $os = lin ]; then
146 echo "creating makefile for building linux ($arch bits) version $appver of $appname"
148 echo "creating makefile for building windows ($arch bits) version $appver of $appname"
151 mkdir -p build/${os}${arch}
153 # get the app. name in capitals
154 appdef=$(echo $appname | tr [a-z] [A-Z])
156 # generate the real Makefile
158 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
159 # 2 - adding includes dependencies to Makefile
161 gcc -MM $src | sed 's!^\(.*\):!$(BUILDPATH)/\1:!' | cat >> Makefile
164 # generate the real installation script for linux
165 cat install.sh.in | sed "s|@@APPNAME@@|${appname}|g" > install.sh