2019-01-18 12:50:09 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-03-13 18:45:23 +01:00
|
|
|
#SafeC=libsafec
|
|
|
|
SafeC=safeclib
|
|
|
|
SafeCpatches="$1"; shift
|
|
|
|
|
2019-01-18 12:50:09 +01:00
|
|
|
[ -r CMakeLists.txt ]
|
|
|
|
|
2020-02-27 11:57:33 +01:00
|
|
|
perl -pi.10 -e '
|
2019-01-18 12:50:09 +01:00
|
|
|
s<(\$\{CMAKE_THREAD_LIBS_INIT\})><PUBLIC $1>;
|
|
|
|
if (!$f) {
|
|
|
|
$f=1 if (s<(\$\{LIBSAFEC)(_LIBRARIES)><PRIVATE ${1}_LDFLAGS\} ${1}_STATIC${2}>);
|
|
|
|
}
|
|
|
|
$_ .= " RENAME ipmctl\n" if (m{/logrotate\.d});
|
|
|
|
' CMakeLists.txt
|
2020-02-27 11:57:33 +01:00
|
|
|
#diff -u CMakeLists.txt{.10,} || sleep 2
|
2019-01-18 12:50:09 +01:00
|
|
|
|
|
|
|
CONTRIB=$PWD/contrib
|
|
|
|
if [ -d $CONTRIB/include ]; then
|
2019-03-14 14:30:59 +01:00
|
|
|
cd $CONTRIB/src/${SafeC}*
|
2019-01-18 12:50:09 +01:00
|
|
|
LSC=${PWD##*/}
|
|
|
|
cp -p COPYING $CONTRIB/COPYING.$LSC
|
|
|
|
sleep 2
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-03-13 18:45:23 +01:00
|
|
|
mkdir -p contrib/{src,patches/${SafeC}}
|
|
|
|
|
|
|
|
mv ${SafeC}* contrib/src
|
2019-01-18 12:50:09 +01:00
|
|
|
|
2019-03-13 18:45:23 +01:00
|
|
|
cd contrib/src/${SafeC}*
|
|
|
|
LSC=${PWD##*/}
|
|
|
|
API="$(perl -n -e 'print "$1\n"
|
|
|
|
if (m{AC_SUBST\(\[SAFEC_API_VERSION\], \[([0-9]+\.[0-9+])\]\)})
|
|
|
|
' configure.ac)"
|
|
|
|
SafeCver="${LSC##*-$API.v}"
|
|
|
|
[ "$SafeCtar" != "$SafeCver" ] || {
|
|
|
|
echo "unsupported $SafeC version!" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
SafeCver="${SafeCver%.tar.*}"
|
|
|
|
SafeCver="${SafeCver/+git/-}"
|
2019-01-18 12:50:09 +01:00
|
|
|
|
2019-03-13 18:45:23 +01:00
|
|
|
if [ -n "$SafeCpatches" -a -s "$SafeCpatches" ]; then
|
|
|
|
tar xvfC "$SafeCpatches" ../../patches/${SafeC}
|
|
|
|
for p in ../../patches/${SafeC}/*.patch; do
|
|
|
|
patch -p1 < $p
|
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "$SafeCver" > .tarball-version
|
2020-02-27 11:57:33 +01:00
|
|
|
perl -pi.10 -e '
|
2019-03-13 18:45:23 +01:00
|
|
|
s{\[libsafec\]}{[safec-'"$API"']}
|
|
|
|
' configure.ac
|
2020-02-27 11:57:33 +01:00
|
|
|
diff -u configure.ac{.10,} || sleep 4
|
2019-03-13 18:45:23 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
autoreconf -Wall --install || exit
|
|
|
|
./configure --disable-shared --disable-doc \
|
2019-01-18 12:50:09 +01:00
|
|
|
--enable-static --enable-strmax=0x8000 \
|
|
|
|
--prefix=$CONTRIB \
|
2019-03-13 18:45:23 +01:00
|
|
|
CFLAGS="$RPM_OPT_FLAGS -DHAVE_C99 -DNO_MSABI_VA_FUNCS -fPIC"
|
|
|
|
make "$@"
|
2019-01-18 12:50:09 +01:00
|
|
|
make install
|
|
|
|
|
|
|
|
cp -p COPYING $CONTRIB/COPYING.$LSC
|
|
|
|
|
2019-03-13 18:45:23 +01:00
|
|
|
[ -r $CONTRIB/include/*/safe_mem_lib.h ] || exit 1
|
|
|
|
|
2019-01-18 12:50:09 +01:00
|
|
|
cd $CONTRIB/..
|
2019-03-13 18:45:23 +01:00
|
|
|
tar cf /tmp/${SafeC}-prebuild.tar contrib
|