085d0e72e92112ccde42c4b8ca9bdf4143b8a82a
3 #####################################################################
5 # Compiles Faust programs to puredata #
8 #####################################################################
11 #-------------------------------------------------------------------
12 # Analyze command arguments :
13 # faust options -> OPTIONS
14 # if -omp : -openmp or -fopenmp -> OPENMP
15 # existing *.dsp files -> FILES
18 # PHASE 1 : Look for -icc option to force use of intel icc (actually icpc)
19 # without having to configure CXX and CXXFLAGS
21 if [ "$p" = -icc ]; then
23 CXXFLAGS
='-O3 -xHost -ftz -fno-alias -fp-model fast=2'
27 #PHASE 2 : dispatch command arguments
29 if [ "$p" = -omp ]; then
30 if [[ $CXX == "icpc" ]]; then
37 if [ "$p" = -icc ]; then
39 elif [ ${p:0:1} = "-" ]; then
41 elif [[ -e "$p" ]]; then
49 #-------------------------------------------------------------------
50 # Check darwin specifics
52 if [[ $
(uname
) == Darwin
]]; then
53 CXXFLAGS
="-O3 -mfpmath=sse -msse -ffast-math"
54 LIB
="-I/Applications/Pd-extended.app/Contents/Resources/include/ -bundle -undefined suppress -flat_namespace"
57 CXXFLAGS
="-O3 -march=native -mfpmath=sse -msse -ffast-math"
58 LIB
="-I/usr/include/pd -I/usr/include/pdextended -fPIC -shared"
65 #-------------------------------------------------------------------
66 # compile the *.dsp files
72 SRCDIR
=$
(dirname "$p")
74 # creates a temporary dir
75 TDR
=$
(mktemp
-d faust.XXX
)
79 # compile faust to c++ and xml
80 faust
-xml "$SRCDIR/$f" -o /dev
/null
;
81 mv "$SRCDIR/$f.xml" $TMP/
82 faust
-a puredata.cpp
$OPTIONS "$SRCDIR/$f" -o "$TMP/${f%.dsp}.cpp"
84 # compile c++ to binary
87 if [[ $
(uname
) == Darwin
]]; then
88 # On Darwin we build 32-bits and 64-bits plugins combined with lipo
89 ${CXX=g++} -arch i386 $CXXFLAGS $OMP $LIB -Dmydsp=${f%.dsp} -o ${f%.dsp}.i386 ${f%.dsp}.cpp
90 ${CXX=g++} -arch x86_64 $CXXFLAGS $OMP $LIB -Dmydsp=${f%.dsp} -o ${f%.dsp}.x86_64 ${f%.dsp}.cpp
91 lipo
-create "${f%.dsp}.i386" "${f%.dsp}.x86_64" -output "${f%.dsp}$EXT"
93 ${CXX=g++} $CXXFLAGS $OMP $LIB -Dmydsp=${f%.dsp} -o ${f%.dsp}$EXT ${f%.dsp}.cpp
95 if [ $
(which faust2pd
) ]; then
100 ##rm -rf "$SRCDIR/${f%.dsp}$EXT"
101 cp "$TMP/${f%.dsp}$EXT" "$SRCDIR/${f%.dsp}$EXT"
102 # collects all the files produced
103 BINARIES
="$BINARIES$SRCDIR/${f%.dsp}$EXT;"
104 if [ $
(which faust2pd
) ]; then
105 cp "$TMP/${f%.dsp}.pd" "$SRCDIR/${f%.dsp}.pd"
106 BINARIES
="$BINARIES$SRCDIR/${f%.dsp}.pd;"
113 # return the binaries names