New way of running configuration scripts during compilation

This commit is contained in:
Pierre Pronchery 2010-12-31 16:46:43 +00:00
parent cc59cecdf3
commit b3d2d5ac50
2 changed files with 49 additions and 23 deletions

View File

@ -10,7 +10,7 @@ INSTALL = install
all: $(TARGETS)
libDesktop.pc: libDesktop.pc.in ../config.sh
./pkgconfig.sh "libDesktop.pc"
./pkgconfig.sh -P "$(PREFIX)" -- "libDesktop.pc"
clean:
$(RM) -- $(libDesktop.pc_OBJS)
@ -19,9 +19,9 @@ distclean: clean
$(RM) -- $(TARGETS)
install: all
./pkgconfig.sh -p "$(DESTDIR)$(PREFIX)" install "libDesktop.pc"
./pkgconfig.sh -P "$(DESTDIR)$(PREFIX)" -i -- "libDesktop.pc"
uninstall:
./pkgconfig.sh -p "$(DESTDIR)$(PREFIX)" uninstall "libDesktop.pc"
./pkgconfig.sh -P "$(DESTDIR)$(PREFIX)" -u -- "libDesktop.pc"
.PHONY: all clean distclean install uninstall

View File

@ -24,32 +24,58 @@ _debug()
#usage
_usage()
{
echo "Usage: pkgconfig.sh target" 1>&2
echo " pkgconfig.sh -p prefix install target" 1>&2
echo " pkgconfig.sh -p prefix uninstall target" 1>&2
echo "Usage: pkgconfig.sh [-i|-u][-P prefix] target" 1>&2
return 1
}
#main
if [ $# -eq 4 -a "$1" = "-p" ]; then
PREFIX="$2"
PKGCONFIG="$PREFIX/lib/pkgconfig"
if [ "$3" = "install" ]; then
$DEBUG $MKDIR "$PKGCONFIG" || exit 2
$DEBUG $INSTALL "$4" "$PKGCONFIG/$4" || exit 2
exit 0
elif [ "$3" = "uninstall" ]; then
$DEBUG $RM "$PKGCONFIG/$4" || exit 2
exit 0
else
echo "pkgconfig.sh: $3: Unknown operation" 1>&2
fi
fi
if [ $# -ne 1 ]; then
args=`getopt iuP: $*`
if [ $? -ne 0 ]; then
_usage
exit $?
fi
set -- $args
install=0
uninstall=0
while [ $# -gt 0 ]; do
case "$1" in
-i)
install=1
;;
-u)
uninstall=1
;;
-P)
PREFIX="$2"
shift
;;
--)
shift
break
;;
esac
shift
done
$SED -e "s,PREFIX,$PREFIX," -e "s,VERSION,$VERSION," "$1.in" > "$1"
PKGCONFIG="$PREFIX/lib/pkgconfig"
while [ $# -gt 0 ]; do
target="$1"
shift
#uninstall
if [ "$uninstall" -eq 1 ]; then
$DEBUG $RM "$PKGCONFIG/$target" || exit 2
continue
fi
#create
$SED -e "s,PREFIX,$PREFIX," -e "s,VERSION,$VERSION," "$target.in" \
> "$target" || exit 2
#install
if [ "$install" -eq 1 ]; then
$DEBUG $MKDIR "$PKGCONFIG" || exit 2
$DEBUG $INSTALL "$target" "$PKGCONFIG/$target" || exit 2
fi
done