1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#!/bin/bash -ex
CFLAGS="$CFLAGS -Werror -Isrc -D_REENTRANT"
SRCS="pmount kerndep mtab"
target ()
{
case "$1" in
clean)
rm -rf tmp out
rm -f src/*~ stamp-*
;;
build|"") if test -e stamp-build ; then return ; fi
mkdir -p tmp out
for i in $SRCS ; do
gcc $CFLAGS -fPIC -c src/$i.c -o tmp/$i.o
done
gcc -Wl,-z,defs -Wl,-soname,libpmount.so.0.0 \
-shared tmp/*.o -o out/libpmount.so.0.0
for i in $SRCS ; do
gcc $CFLAGS -c src/$i.c -o tmp/$i.o
done
ar cru out/libpmount.a tmp/*.o
touch stamp-build
;;
check) target build
# check if we are root, and it's not fake
if [ $UID = 0 ] && test -z $FAKEROOTKEY ; then
for i in tests/*.sh ; do sh $i ; done
else
echo "Not running as root, skipping checks."
fi
;;
install) target build
mkdir -p $DESTDIR/usr/include/ $DESTDIR/{usr/,}lib
install -m644 src/pmount.h $DESTDIR/usr/include/
install -s -m755 out/libpmount.so.0.0 $DESTDIR/lib/
strip --strip-unneeded $DESTDIR/lib/libpmount.so.0.0
install -m755 out/libpmount.a $DESTDIR/usr/lib/
ln -s /lib/libpmount.so.0 $DESTDIR/usr/lib/libpmount.so
ln -s libpmount.so.0.0 $DESTDIR/lib/libpmount.so.0
;;
esac
}
for i in "$@" ; do
case "$i" in
clean|install|build|check|"")
target $i ;;
*)
echo "Unknown target: $i"
exit 1
;;
esac
done
|