fix ASAN build
[folly.git] / folly / build / buck_run_autoconf.sh
1 #!/bin/sh
2
3 get_ldflags() {
4   # Convert paths to .so/.dylib/.dll into directories that can be used with
5   # -L/path and -Wl,-rpath,/path compiler args. Also strip out -l flags,
6   # as autoconf will add them for us for feature detection.
7   for i in "$@"; do
8     if [ "$i" = "-Wl,-rpath" ]; then continue; fi
9     echo "$i" | perl -p -e "s/'/\\\\'/g;" \
10       -e 's/-l[\w-]*//g;' \
11       -e 's;(.*)[/\\].*\.(so|dylib|dll)$;-L\1 -Wl,-rpath,\1;g;'
12   done
13 }
14
15 # This is an extra linker flag that buck appends on OSX that's not valid
16 # This probably requires a patch to buck
17 LDFLAGS=$(get_ldflags "$@" | uniq | tr '\n' ' ' | perl -pe 's;-Xlinker \@executable_path\S*;;g')
18
19 export LDFLAGS
20 export BOOST_LDFLAGS="$LDFLAGS"
21 export BOOST_CPPFLAGS="$CPPFLAGS"
22
23 SRCROOT=$(dirname "$(readlink "$SRCDIR"/configure.ac)")
24 # Temp dir because autoconf doesn't like '#' in the working directory
25 conf_dir=$(mktemp -d)
26 trap 'rm -rf "$conf_dir"' EXIT
27 cd "$conf_dir" && \
28 autoreconf -iv "$SRCROOT" && \
29 "$SRCROOT/configure" "$BOOST_FLAG" && \
30 cp -pvf folly-config.h "$OUT"