chiark / gitweb /
Automate installation of the CGI at last.
authorRichard Kettlewell <rjk@greenend.org.uk>
Fri, 6 Jun 2008 09:27:16 +0000 (10:27 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Fri, 6 Jun 2008 09:27:16 +0000 (10:27 +0100)
configure will try to guess the install location, if it can't then you
can set cgidir=/path/to/cgi-bin to override it.

.bzrignore
CHANGES.html
README
cgi/Makefile.am
configure.ac
debian/rules
scripts/setup.in

index 9a601a2..99a65d9 100644 (file)
@@ -77,7 +77,7 @@ server/disorder-deadlock
 server/disorder-dump
 server/disorder-rescan
 server/disorder-speaker
-cgi/disorder.cgi
+cgi/disorder
 server/disorderd
 server/trackname
 sounds/Makefile
index a0dad8e..9cbcd90 100644 (file)
@@ -129,6 +129,10 @@ span.command {
   <p>Mail is now sent via the system sendmail program, though it remains
   possible to use TCP to connect to an SMTP server.  See <tt>sendmail</tt> and
   <tt>smtp_server</tt> in disorder_config(5).</p>
+
+  <p>The makefiles will now install the CGI automatically.  If they cannot
+  figure out the location of the cgi-bin directory on your system, set
+  <tt>cgidir</tt> on the <tt>configure</tt> command line.</p>
   
 </div>
 
@@ -297,5 +301,6 @@ span.command {
 <!--
 Local Variables:
 fill-column:79
+indent-tabs-mode:nil
 End:
 -->
diff --git a/README b/README
index 8aa4ccd..333b558 100644 (file)
--- a/README
+++ b/README
@@ -88,6 +88,11 @@ platform, please get in touch.
      --without-gtk          Don't build GTK+ client (Disobedience)
      --without-python       Don't build Python support
 
+   If configure cannot figure out where your CGI programs live, you must set
+   cgidir on the command line, e.g.:
+
+     ./configure cgidir=/whatever/cgi-bin
+
    See README.client for setting up a standalone client (or read the
    disobedience man page).
 
@@ -98,9 +103,6 @@ platform, please get in touch.
 
      make installdirs install
 
-   The CGI interface has to be installed separately; see under 'Web Interface'
-   below.
-
    NB steps 3 to 6 are covered by scripts/setup.  It should work on FreeBSD, OS
    X and Linux and could be adapted to other platforms.
 
@@ -238,20 +240,15 @@ You need to configure a number of things to make this work:
      cd /var/www
      ln -s /usr/local/share/disorder/static disorder
 
-4. Install disorder.cgi in an appropriate location.  Remember to make it
-   executable.  Example:
-
-     install -m 755 cgi/disorder.cgi /usr/lib/cgi-bin/disorder
-
-5. Try it out.  You should be able to perform read-only operations straight
+4. Try it out.  You should be able to perform read-only operations straight
    away, and after visiting the 'Login' page to authenticate, perform other
    operations like adding a track to the queue.
 
-6. If you run into problems, always look at the appropriate error log; the
+5. If you run into problems, always look at the appropriate error log; the
    message you see in your web browser will usually not be sufficient to
    diagnose the problem all by itself.
 
-7. If you have a huge number of top level directories, then you might find
+6. If you have a huge number of top level directories, then you might find
    that the 'Choose' page is unreasonably large.  If so add the following line
    to /etc/disorder/options.user:
      label sidebar.choosewhich choosealpha
index 86f6965..e2fa895 100644 (file)
 # USA
 #
 
-noinst_PROGRAMS=disorder.cgi
+cgi_PROGRAMS=disorder
 
 AM_CPPFLAGS=-I${top_srcdir}/lib -I../lib
 
-disorder_cgi_SOURCES=macros-disorder.c lookup.c options.c actions.c    \
+disorder_SOURCES=macros-disorder.c lookup.c options.c actions.c        \
        login.c cgimain.c disorder-cgi.h
-disorder_cgi_LDADD=../lib/libdisorder.a \
+disorder_LDADD=../lib/libdisorder.a \
        $(LIBPCRE) $(LIBGCRYPT) $(LIBDL) $(LIBDB)
-disorder_cgi_LDFLAGS=-export-dynamic
-disorder_cgi_DEPENDENCIES=../lib/libdisorder.a
-
-cgi.o: ../lib/definitions.h
+disorder_LDFLAGS=-export-dynamic
+disorder_DEPENDENCIES=../lib/libdisorder.a
index 18380c0..3f4c0b0 100644 (file)
@@ -33,6 +33,8 @@ AC_CANONICAL_HOST
 want_gtk=yes
 want_python=yes
 want_tests=yes
+want_server=yes
+want_cgi=yes
 
 # APIs we want
 want_alsa=yes
@@ -75,14 +77,13 @@ case "$host" in
   AC_CHECK_LIB([gpg-error], [gpg_strerror])
   AC_CHECK_LIB([pthread], [pthread_create])
   want_server=no
+  want_cgi=no
  ;;
 *linux* | *Linux* )
   AC_MSG_RESULT([Linux])
-  want_server=yes
   ;;
 *-apple-darwin* )
   AC_MSG_RESULT([Mac OS X])
-  want_server=yes
   if test $want_coreaudio = yes; then
     COREAUDIO="-framework CoreAudio"
   fi
@@ -112,7 +113,6 @@ case "$host" in
   ;;
 *-freebsd* )
   AC_MSG_RESULT([FreeBSD])
-  want_server=yes
   # Ports install to /usr/local but the compiler stupidly doesn't look
   # there by default
   LDFLAGS="${LDFLAGS} -L/usr/local/lib"
@@ -134,7 +134,6 @@ case "$host" in
   ;;
 * )
   AC_MSG_RESULT([unknown, winging it])
-  want_server=no
   ;;
 esac
 AC_SUBST([COREAUDIO])
@@ -162,6 +161,10 @@ AC_ARG_WITH([server],
            [AS_HELP_STRING([--without-server],
                            [do not build server])],
            [want_server=$withval])
+AC_ARG_WITH([cgi],
+           [AS_HELP_STRING([--without-cgi],
+                           [do not build CGI])],
+           [want_cgi=$withval])
 AC_ARG_WITH([gtk],
            [AS_HELP_STRING([--without-gtk],
                            [do not build GTK+ client])],
@@ -171,6 +174,33 @@ AC_ARG_WITH([python],
                            [do not build Python support])],
            [want_python=$withval])
 
+if test $want_server = no; then
+  want_cgi=no
+fi
+
+if test $want_cgi = yes; then
+  if test -z "$cgidir"; then
+    AC_CACHE_CHECK([for CGI directory],[rjk_cv_cgidir],[
+      rjk_cv_cgidir="not found"
+      for dir in /usr/lib/cgi-bin \
+                 /Library/WebServer/CGI-Executables \
+                 /usr/local/lib/cgi-bin \
+                 /usr/local/www/cgi-bin \
+                 /usr/local/www/*/cgi-bin; do
+        if test -d "$dir"; then
+          rjk_cv_cgidir="$dir"
+          break
+        fi
+      done
+    ])
+    if test "$rjk_cv_cgidir" = "not found"; then
+      AC_MSG_ERROR([cannot identify CGI install directory.  Set cgidir on configure command line])
+    fi
+    cgidir="$rjk_cv_cgidir"
+  fi
+fi
+AC_ARG_VAR([cgidir], [location of cgi-bin directory, e.g. /usr/lib/cgi-bin])
+
 subdirs="scripts lib"
 if test $want_tests = yes; then
   subdirs="${subdirs} libtests"
@@ -178,7 +208,10 @@ fi
 subdirs="${subdirs} clients doc examples debian"
 
 if test $want_server = yes; then
-  subdirs="${subdirs} server cgi plugins driver templates sounds images"
+  subdirs="${subdirs} server plugins driver sounds"
+fi
+if test $want_cgi = yes; then
+  subdirs="${subdirs} cgi templates images"
 fi
 if test $want_gtk = yes; then
   subdirs="${subdirs} disobedience"
@@ -615,3 +648,7 @@ fi
 if test $want_python = no; then
   AC_MSG_WARN([cannot run the test suit without Python])
 fi
+
+# Local Variables:
+# indent-tabs-mode:nil
+# End:
index 424f506..831fd68 100755 (executable)
@@ -155,7 +155,7 @@ pkg-disorder-server: build
                debian/disorder-server/etc/disorder/options
        $(INSTALL_DATA) debian/etc.disorder.options.user \
                debian/disorder-server/etc/disorder/options.user
-       $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) cgi/disorder.cgi \
+       $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) cgi/disorder \
                $(shell pwd)/debian/disorder-server/usr/lib/cgi-bin/disorder
        dpkg-shlibdeps -Tdebian/substvars.disorder-server \
                debian/disorder-server/usr/lib/cgi-bin/disorder \
index 3a0c66b..8c8b3b0 100755 (executable)
@@ -437,7 +437,6 @@ Mac )
   launchctl load /Library/LaunchDaemons
   echo "Starting DisOrder server"
   launchctl start uk.org.greenend.rjk.disorder
-  CGIBIN=/Library/WebServer/CGI-Executables
   DOCROOT=/Library/WebServer/Documents
   sever_running=true
   ;;
@@ -465,7 +464,6 @@ FreeBSD )
   esac
   web=$1
   echo "Found $web"
-  CGIBIN=$web/cgi-bin
   DOCROOT=$web/data
   server_running=true
   ;;
@@ -503,13 +501,6 @@ Linux )
       break
     fi
   done
-  echo "Looking for cgi-bin directory"
-  for d in /var/www/cgi-bin /usr/lib/cgi-bin; do
-    if [ -d $d ]; then
-      CGIBIN=$d
-      break
-    fi
-  done
   server_running=true
   ;;
 * )
@@ -529,14 +520,6 @@ else
   ln -s pkgdatadir/static $DOCROOT/disorder
 fi
 
-echo
-if [ -z "$CGIBIN" ]; then
-  echo "Cannot find your web server's cgi-bin directory"
-else
-  echo "Installing CGI in $CGIBIN"
-  install -m 555 cgi/disorder.cgi $CGIBIN/disorder
-fi
-
 if $server_running; then
   first=true
   sleep 5