faba0c18e6e7c14d8738f324995cee311521d20a
[Faustine.git] / interpretor / faust-0.9.47mr3 / tools / faust2appls / faust2alsa
1 #!/bin/bash
2
3 OSCDEFS=""
4 #####################################################################
5 # #
6 # Compiles Faust programs to alsa-gtk #
7 # (c) Grame, 2009-2011 #
8 # #
9 #####################################################################
10
11
12 #-------------------------------------------------------------------
13 # Default compilation flags for gcc and icc :
14 #
15 MYGCCFLAGS="-O3 -march=native -mfpmath=sse -msse -msse2 -msse3 -ffast-math -ftree-vectorize"
16 MYICCFLAGS="-O3 -xHost -ftz -fno-alias -fp-model fast=2"
17
18
19 #-------------------------------------------------------------------
20 # Analyze command arguments :
21 # faust options -> OPTIONS
22 # if -omp : -openmp or -fopenmp -> OPENMP
23 # existing *.dsp files -> FILES
24 #
25
26 # PHASE 1 : Look for -icc option to force use of intel icc (actually icpc)
27 # without having to configure CXX and CXXFLAGS
28 CXX=g++
29 CXXFLAGS=$MYGCCFLAGS
30 for p in $@; do
31 if [ "$p" = -icc ]; then
32 CXX=icpc
33 CXXFLAGS=$MYICCFLAGS
34 fi
35 done
36
37 #PHASE 2 : dispatch command arguments
38 for p in $@; do
39 if [ "$p" = -omp ]; then
40 if [[ $CXX == "icpc" ]]; then
41 OMP="-openmp"
42 else
43 OMP="-fopenmp"
44 fi
45 fi
46
47 if [ "$p" = -icc ]; then
48 ignore=" "
49 elif [ $p = "-osc" ]; then
50 OSCDEFS="-I/usr/local/lib/faust/osclib -DOSCCTRL -L/usr/local/lib/faust/osclib -lOSCFaust -loscpack"
51 elif [ ${p:0:1} = "-" ]; then
52 OPTIONS="$OPTIONS $p"
53 elif [[ -e "$p" ]]; then
54 FILES="$FILES $p"
55 else
56 OPTIONS="$OPTIONS $p"
57 fi
58 done
59
60
61
62
63 #-------------------------------------------------------------------
64 # compile the *.dsp files using ALSA and GTK on linux
65 #
66 for f in $FILES; do
67
68 # compile faust to c++
69 faust -a alsa-gtk.cpp $OPTIONS "$f" -o "$f.cpp"
70
71 # compile c++ to binary
72 (
73 $CXX $CXXFLAGS $OMP -I/usr/local/lib/faust "$f.cpp" `pkg-config --cflags --libs alsa gtk+-2.0` $OSCDEFS -o "${f%.dsp}"
74 ) > /dev/null
75 rm "$f.cpp"
76
77 # collect binary file name for FaustGIDE
78 BINARIES="$BINARIES${f%.dsp};"
79 done
80
81
82 echo $BINARIES
83
84