Server-Root/libraries/build_jemalloc.sh

53 lines
1.8 KiB
Bash
Raw Normal View History

2018-08-25 10:42:06 -04:00
#!/bin/bash
2019-10-13 12:52:17 -04:00
source ../build-helpers/build_helper.sh || { echo "Failed to include build helper script. Abort"; exit 1; }
2018-08-25 10:42:06 -04:00
2019-10-13 12:52:17 -04:00
library_path=jemalloc
requires_rebuild ${library_path}
[[ $? -eq 0 ]] && exit 0
# Generate the configure file
cd jemalloc
2018-08-25 10:42:06 -04:00
if ! [ -f configure ]; then
autoconf
2019-10-13 12:52:17 -04:00
check_err_exit ${library_path} "Failed to create configure file"
2018-08-25 10:48:42 -04:00
if ! [ -f configure ]; then
2019-10-13 12:52:17 -04:00
err_exit ${library_path} "Failed to create configure file"
2018-08-25 10:42:06 -04:00
exit 1
fi
fi
2019-10-13 12:52:17 -04:00
cd ..
2018-08-25 10:42:06 -04:00
2019-10-13 12:52:17 -04:00
# Generate the build environment
generate_build_path "${library_path}"
if [[ -d ${build_path} ]]; then
echo "Removing old build directory"
rm -rf ${build_path}
2018-08-25 10:42:06 -04:00
fi
2019-10-13 12:52:17 -04:00
mkdir -p ${build_path}
check_err_exit ${library_path} "Failed to create build directory"
cd ${build_path}
check_err_exit ${library_path} "Failed to enter build directory"
# Building jemalloc
../../configure
check_err_exit ${library_path} "Failed to create makefile"
2018-08-25 10:42:06 -04:00
(cat Makefile | sed 's/.*$(CC) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) $(LDTARGET) $+ $(LDFLAGS) $(LIBS) $(EXTRA_LDFLAGS).*/ $(CXX) $(DSO_LDFLAGS) $(call RPATH,$(RPATH_EXTRA)) $(LDTARGET) $+ $(LDFLAGS) $(LIBS) $(EXTRA_LDFLAGS)/') > tmp
rm Makefile
mv tmp Makefile
2019-09-10 05:42:58 -04:00
make build_lib_shared -j 12 LIBS="-pthread -static-libgcc -static-libstdc++ -fPIC" CFLAGS="-static-libgcc -static-libstdc++ -fPIC" CXXFLAGS="-static-libgcc -static-libstdc++ -fPIC"
2018-08-25 10:42:06 -04:00
#make -j 12 LIBS="-pthread -static-libgcc -static-libstdc++" CFLAGS="-fPIC" CXXFLAGS="-fPIC"
#make -j 12 LIBS="-pthread -lm -l/usr/lib/gcc/x86_64-linux-gnu/5/libstdc++.a" ${MAKE_OPTIONS} CFLAGS="-shared -static-libstdc++ -static-libgcc -fPIC" CXXFLAGS="-static-libstdc++ -static-libgcc -shared -fPIC"
2019-10-13 12:52:17 -04:00
check_err_exit ${library_path} "Failed to build jemalloc"
2018-11-17 11:16:40 -05:00
2018-08-25 10:42:06 -04:00
sudo make install &>/dev/null
if [ $? -ne 0 ]; then #Workaround because the install fails
exit 0
fi
2019-10-13 12:52:17 -04:00
#
cd ../../../
set_build_successful ${library_path}
2018-08-25 10:42:06 -04:00