Adjust regex to match variable names including underscores
[samba.git] / source / script / installman.sh
index 5b6bba69edbfb09bbe5aab2863894ffc8f4aa447..085e86227c29f732e6e9f216ffc4dee37575038c 100755 (executable)
@@ -5,7 +5,7 @@
 #   modified to accomodate international man pages (inspired
 #   by Japanese edition's approach)
 
-MANDIR=$1
+MANDIR=`echo $1 | sed 's/\/\//\//g'`
 SRCDIR=$2/
 langs=$3
 
@@ -13,9 +13,17 @@ if [ $# -ge 4 ] ; then
   GROFF=$4                    # sh cmd line, including options 
 fi
 
+if test ! -d $SRCDIR../docs/manpages; then
+       echo "No manpages present.  Development version maybe?"
+       exit 0
+fi
+
+# Get the configured feature set
+test -f "${SRCDIR}/config.log" && \
+       eval `grep "^[[:alnum:]_]*=.*" "${SRCDIR}/config.log"`
 
 for lang in $langs; do
-    if [ "X$lang" = Xen ]; then
+    if [ "X$lang" = XC ]; then
        echo Installing default man pages in $MANDIR/
        lang=.
     else
@@ -36,13 +44,21 @@ for lang in $langs; do
     for sect in 1 5 7 8 ; do
        for m in $langdir/man$sect ; do
            for s in $SRCDIR../docs/manpages/$lang/*$sect; do
-           FNAME=$m/`basename $s`
+           MP_BASENAME=`basename $s`
+
+           # Check if this man page if required by the configured feature set
+           case "${MP_BASENAME}" in
+               cifs.upcall.8) test -z "${CIFSUPCALL_PROGS}" && continue ;;
+               smbsh.1) test -z "${SMBWRAPPER}" && continue ;;
+               *) ;;
+           esac
+
+           FNAME="$m/${MP_BASENAME}"
+
            # Test for writability.  Involves 
            # blowing away existing files.
  
            if (rm -f $FNAME && touch $FNAME); then
-               rm $FNAME
                if [ "x$GROFF" = x ] ; then
                    cp $s $m            # Copy raw nroff 
                else