/[svn]/libgig/trunk/osx/autoconf_builder.sh
ViewVC logotype

Contents of /libgig/trunk/osx/autoconf_builder.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1172 - (show annotations) (download) (as text)
Sun May 6 16:17:48 2007 UTC (16 years, 11 months ago) by schoenebeck
File MIME type: application/x-sh
File size: 4205 byte(s)
* added XCode project files for Mac OSX (patch by Toshi Nagata)

1 #!/bin/sh
2 # autoconf_builder.sh
3 # LinuxSampler
4 #
5 # Created by Toshi Nagata on 07/04/18.
6 # Copyright 2007 __MyCompanyName__. All rights reserved.
7 #
8 # Influential environmental variables:
9 # ACTION(*): autoconf - run "make -f Makefile.cvs"; configure - run "configure";
10 # make - run "make"; install - run "make install";
11 # build (or empty string) - autoconf && configure && make (&& install)
12 # "install" step is only done if WITH_INSTALL is non-empty
13 # BUILD_STYLE(*): The build style. If it ends with "ppc" or "i386", it also specifies the architecture.
14 # WITH_INSTALL: When non-empty, "install" action is automatically done in "build" action.
15 # CFLAGS, CXXFLAGS: Compiler flags
16 # CONFIG_OPTIONS: Options for "configure"
17 # BUILD_BASE_DIR: Temporary building and install directory. By default "$PWD/build".
18 # SDKROOT: The root directory for SDK
19 #
20 # The variables marked with (*) are automatically set by Xcode.
21
22 BASE_DIR=$PWD
23 BASE_NAME=`basename $PWD`
24
25 function rel2abs () {
26 (cd "$1"; pwd)
27 # pushd "$1" >/dev/null
28 # pwd
29 # popd >/dev/null
30 }
31
32 function abs2rel () {
33 /usr/bin/perl -e 'use File::Spec; print File::Spec->abs2rel($ARGV[0], $ARGV[1]), "\n";' "$1" "$2"
34 }
35
36 function link_recursive () {
37 local arg base i
38 arg="$1"
39 base=`basename "$arg"`
40 if test -d "$arg"; then
41 if expr "$base" = "CVS" "|" `rel2abs "$arg"` = "$BUILD_BASE_DIR" >/dev/null; then
42 echo "Skipping directory $arg"
43 else
44 echo "Copying directory $arg"
45 mkdir -p "$base"
46 cd "$base"
47 if ! expr "$arg" : "^/" >/dev/null; then
48 arg="../$arg"
49 fi
50 for i in "$arg"/*; do
51 link_recursive "$i"
52 done
53 cd ..
54 fi
55 else
56 echo "Linking $arg"
57 ln -sf $arg
58 fi
59 }
60
61 # Sanity checks
62 if test "x$BUILD_STYLE" = "x"; then
63 BUILD_STYLE="Default"
64 fi
65 if test "x$ACTION" = "x"; then
66 ACTION="build"
67 fi
68 if test "x$BUILD_BASE_DIR" = "x"; then
69 BUILD_BASE_DIR=$PWD/build
70 fi
71 BUILD_DIR="$BUILD_BASE_DIR/$BUILD_STYLE/$BASE_NAME.build"
72 mkdir -p "$BUILD_DIR" || exit $?
73 BUILD_BASE_DIR=`rel2abs "$BUILD_BASE_DIR"`
74 BUILD_DIR=`rel2abs "$BUILD_DIR"`
75 CONFIG_OPTIONS="--prefix=$BUILD_BASE_DIR/$BUILD_STYLE/local $CONFIG_OPTIONS"
76
77 if test -e "$SDKROOT"; then
78 SYSROOT_CFLAGS="-isysroot $SDKROOT"
79 else
80 SYSROOT_CFLAGS=
81 fi
82 PATH="/usr/local/bin:$PATH"
83
84
85 ARCH_CFLAGS=""
86 ARCH_CONFIG_OPTIONS=""
87 case "$BUILD_STYLE" in
88 *ppc)
89 ARCH="ppc"
90 ARCH_CFLAGS="-arch ppc"
91 ;;
92 *i386)
93 ARCH="i386"
94 ARCH_CFLAGS="-arch i386 -msse -msse2"
95 ARCH_CONFIG_OPTIONS="--host=i386-apple-darwin8"
96 ;;
97 *UB|*Universal)
98 ARCH="UB"
99 ;;
100 *)
101 echo "Warning: architecture cannot be recognized from the build style"
102 ARCH="unknown"
103 ;;
104 esac
105
106 case "$BUILD_STYLE" in
107 Development|Default)
108 OPT_CFLAGS="-O2 -g"
109 ;;
110 Deployment*)
111 OPT_CFLAGS="-O3"
112 ;;
113 esac
114
115 export CFLAGS="$SYSROOT_CFLAGS $ARCH_CFLAGS $OPT_CFLAGS $CFLAGS"
116 export CXXFLAGS="$SYSROOT_CFLAGS $ARCH_CFLAGS $OPT_CFLAGS $CXXFLAGS"
117
118 # Display all environments
119 set
120
121 # Move to the working directory
122 cd $BUILD_DIR
123
124 # Clean if specified
125 if test "x$ACTION" = "xclean"; then
126 if test "x$WITH_INSTALL" != "x" -a -e "Makefile"; then
127 echo "Doing make uninstall"
128 make uninstall
129 fi
130 echo "Removing files in $BUILD_DIR"
131 cd $BASE_DIR
132 rm -rf "$BUILD_DIR"
133 exit $?
134 fi
135
136 if test "x$ACTION" = "xbuild" -o "x$ACTION" = "xconfigure"; then
137 # Copy the source files if necessary
138 if test ! -e Makefile -a ! -e configure -a ! -e Makefile.cvs; then
139 echo "Copying the source files to $BUILD_DIR"
140 for i in `abs2rel "$BASE_DIR" "$BUILD_DIR"`/*; do
141 link_recursive $i
142 done
143 fi
144 # Make ./configure if necessary
145 if test -e Makefile.cvs -a ! -e configure; then
146 echo "Running make -f Makefile.cvs"
147 make -f Makefile.cvs || exit $?
148 fi
149 # Run ./configure if necessary
150 if test -e configure -a ! -e Makefile; then
151 CONFIG_ARGS="$CONFIG_OPTIONS $ARCH_CONFIG_OPTIONS $CONFIG_ENVS"
152 echo "Running configure $CONFIG_ARGS"
153 ./configure $CONFIG_ARGS || exit $?
154 fi
155 fi
156
157 if test "x$ACTION" = "xbuild" -o "x$ACTION" = "xmake"; then
158 # make
159 echo "Running make"
160 make || exit $?
161 fi
162
163 # make install if specified
164 if test "x$ACTION" = "xinstall" -o "(" "x$ACTION" = "xbuild" -a "x$WITH_INSTALL" != "x" ")"; then
165 echo "Running make install"
166 make install || exit $?
167 fi

  ViewVC Help
Powered by ViewVC