3781411b7c6f92ceb53dd5741f8c56f99b04d29f
[Faustine.git] / interpretor / preprocessor / faust-0.9.47mr3 / tools / faust2appls / faust2alqt
1 #!/bin/bash
2
3 #####################################################################
4 # #
5 # Compiles Faust programs to jack-qt #
6 # (c) Grame, 2009 #
7 # #
8 #####################################################################
9
10 OSCINC=""
11 QTDEFS=""
12 OSCLIB=""
13
14
15 #-------------------------------------------------------------------
16 # Analyze command arguments :
17 # faust options -> OPTIONS
18 # if -omp : -openmp or -fopenmp -> OPENMP
19 # existing *.dsp files -> FILES
20 #
21
22 # PHASE 1 : Look for -icc option to force use of intel icc (actually icpc)
23 # without having to configure CXX and CXXFLAGS
24 for p in $@; do
25 if [ "$p" = -icc ]; then
26 CXX=icpc
27 CXXFLAGS='-O3 -xHost -ftz -fno-alias -fp-model fast=2'
28 fi
29 done
30
31 #PHASE 2 : dispatch command arguments
32 for p in $@; do
33 if [ "$p" = -omp ]; then
34 if [[ $CXX == "icpc" ]]; then
35 OMP="-openmp"
36 else
37 OMP="-fopenmp"
38 fi
39 fi
40
41 if [ "$p" = -icc ]; then
42 ignore=" "
43 elif [ $p = "-osc" ]; then
44 OSCINC="INCLUDEPATH+=/usr/local/lib/faust/osclib"
45 QTDEFS="DEFINES += OSCCTRL"
46 OSCLIB="-L/usr/local/lib/faust/osclib -lOSCFaust -loscpack"
47 elif [ ${p:0:1} = "-" ]; then
48 OPTIONS="$OPTIONS $p"
49 elif [[ -e "$p" ]]; then
50 FILES="$FILES $p"
51 else
52 OPTIONS="$OPTIONS $p"
53 fi
54 done
55
56
57
58 #-------------------------------------------------------------------
59 # Check darwin specifics
60 #
61 if [[ $(uname) == Darwin ]]; then
62 SPEC="-spec macx-g++"
63 EXT=".app"
64 fi
65
66 #-------------------------------------------------------------------
67 # compile the *.dsp files
68 #
69 for p in $FILES; do
70
71 CUR=$(pwd)
72 f=$(basename "$p")
73 SRCDIR=$(dirname "$p")
74
75 # creates a temporary dir
76 TDR=$(mktemp -d faust.XXX)
77 TMP="$TDR/${f%.dsp}"
78 mkdir "$TMP"
79
80 # compile faust to c++
81 faust -a alsa-qt.cpp $OPTIONS "$SRCDIR/$f" -o "$TMP/${f%.dsp}.cpp"
82
83 # compile c++ to binary
84 (
85 cd "$TMP"
86 qmake -project "INCLUDEPATH+=$CUR" "INCLUDEPATH+=/usr/local/lib/faust/" "$OSCINC" "LIBS+=-lasound $OSCLIB" "HEADERS+=/usr/local/lib/faust/gui/faustqt.h" "$QTDEFS"
87 qmake $SPEC
88 make
89 ) > /dev/null
90
91 rm -rf "$SRCDIR/${f%.dsp}$EXT"
92 cp -r "$TMP/${f%.dsp}$EXT" "$SRCDIR/${f%.dsp}$EXT"
93 rm -rf "$TDR"
94
95 # collect binary file name for FaustGIDE
96 BINARIES="$BINARIES$SRCDIR/${f%.dsp}$EXT;"
97 done
98
99 echo $BINARIES
100
101