making the install script break out opensrf, openils, and evergreen a little
[Evergreen.git] / install.sh
index 3513170..2e438c8 100755 (executable)
@@ -34,33 +34,6 @@ function fail {
 }
 
 
-function verifyInstallPaths {
-
-       cat <<-WORDS
-
-       -----------------------------------------------------------------------
-       Verify the following install directories are sane.
-       Note: * indicates that you must have write privelages for the location
-       -----------------------------------------------------------------------
-
-       -----------------------------------------------------------------------
-       Install prefix            [$PREFIX]*
-       Temporary files directory [$TMP]*
-       Apache2 apxs binary       [$APXS2]
-       Apache2 header directory  [$APACHE2_HEADERS]
-       Libxml2 header directory  [$LIBXML2_HEADERS]
-       Building targets          [${TARGETS[@]:0}];
-       -----------------------------------------------------------------------
-
-       If these are not OK, use control-c to break out and fix the variables 
-       in install.config.  Otherwise, type enter.
-
-       To disable this message, run "./install.sh force".
-
-       WORDS
-       read OK;
-}
-
 #function postMessage {
 
 #cat <<-WORDS
@@ -69,31 +42,54 @@ function verifyInstallPaths {
 
 #}
 
+
+
 # --------------------------------------------------------------------
 # Makes sure the install directories exist and are writable
 # --------------------------------------------------------------------
 function mkInstallDirs {
 
-       mkdir -p "$PREFIX";
-       if [ "$?" != "0" ]; then
-               fail "Error creating $PREFIX";
-       fi
+       if installing; then
 
-       mkdir -p "$TMP";
-       if [ "$?" != "0" ]; then
-               fail "Error creating $TMP";
-       fi
+               mkdir -p "$PREFIX";
+               if [ "$?" != "0" ]; then
+                       fail "Error creating $PREFIX";
+               fi
+
+               if [ ! -w "$PREFIX" ]; then
+                       fail "We don't have write access to $PREFIX";
+               fi
 
-       if [ ! -w "$PREFIX" ]; then
-               fail "We don't have write access to $PREFIX";
        fi
 
-       if [ ! -w "$TMP" ]; then
-               fail "We don't have write access to $TMP";
+       if building; then
+
+               mkdir -p "$TMP";
+               if [ "$?" != "0" ]; then
+                       fail "Error creating $TMP";
+               fi
+
+               if [ ! -w "$TMP" ]; then
+                       fail "We don't have write access to $TMP";
+               fi
        fi
 
+       
+
 }
 
+function installing {
+       if [ -z "$INSTALLING" ]; then return 1; fi;
+       return 0;
+}
+
+function building {
+       if [ -z "$BUILDING" ]; then return 1; fi;
+       return 0;
+}
+
+
+
 # --------------------------------------------------------------------
 # Loads the config file.  If it can't fine CONFIG_FILE, it attempts to
 # use DEFAULT_CONFIG_FILE.  If it can't find that, it fails.
@@ -101,6 +97,7 @@ function mkInstallDirs {
 function loadConfig {
        if [ ! -f "$CONFIG_FILE" ]; then
                if [ -f "$DEFAULT_CONFIG_FILE" ]; then
+                       echo "+ + + Copying $DEFAULT_CONFIG_FILE to $CONFIG_FILE and using its settings...";
                        cp "$DEFAULT_CONFIG_FILE" "$CONFIG_FILE";
                else
                        fail "config file \"$CONFIG_FILE\" cannot be found";
@@ -110,12 +107,25 @@ function loadConfig {
 }
 
 
+
+
+# install targets
+#
+# opensrf_jserver - custom 'single-domain' jabber server which may be used in place of jabberd2
+# opensrf_router  - jabber router.  
+# opensrf_gateway - mod_ils_gateway, Apache module for proxying API calls
+# opensrf_srfsh   - diagnostic shell interface to OpenSRF
+# opensrf_perl         - install the OpenSRF perl modules
+# opensrf_all          - builds all OpenSRF compenents
+# openils_marcdumper - utility code for converting MARC to MARCXML
+# openils_perl                 - install the Open-ILS perl modules
+# openils_all                  - builds all OpenILS compenents
+# openils_web                  - copies over the javascript and html templates to the web root directory
+# evergreen_xul_client   - client XUL application
+# evergreen_all        - builds all Evergreen components
 function runInstall {
 
 
-       loadConfig;
-       #[ -z "$FORCE" ] && verifyInstallPaths;
-       mkInstallDirs;
 
        # pass the collected variables to make
        for target in ${TARGETS[@]:0}; do
@@ -128,13 +138,62 @@ function runInstall {
 
                MSG
 
-               MAKE="make APXS2=$APXS2 PREFIX=$PREFIX TMP=$TMP APACHE2_HEADERS=$APACHE2_HEADERS LIBXML2_HEADERS=$LIBXML2_HEADERS"; 
+               MAKE="make APXS2=$APXS2 PREFIX=$PREFIX TMP=$TMP \
+                       APACHE2_HEADERS=$APACHE2_HEADERS LIBXML2_HEADERS=$LIBXML2_HEADERS \
+                       BINDIR=$BINDIR LIBDIR=$LIBDIR PERLDIR=$PERLDIR INCLUDEDIR=$INCLUDEDIR";
 
-               echo "Passing to sub-makes: $VARS"
-                       
                case "$target" in
-                       
-                       "jserver" | "router" | "gateway" | "srfsh" ) $MAKE -C "$OPENSRF_DIR" "$target" "$target-install";;
+       
+                       # OpenSRF ---                   
+
+                       "opensrf_all")
+                               if building;    then $MAKE -C "$OPENSRF_DIR" all; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" install; fi;
+                               ;;
+
+                       "opensrf_jserver" )
+                               if building;    then $MAKE -C "$OPENSRF_DIR" "jserver"; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "jserver-install"; fi;
+                               ;;      
+
+                       "opensrf_router" ) 
+                               if building;    then $MAKE -C "$OPENSRF_DIR" "router"; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "router-install"; fi;
+                               ;;
+
+                       "opensrf_gateway" )
+                               if building;    then $MAKE -C "$OPENSRF_DIR" "gateway"; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "gateway-install"; fi;
+                               ;;
+
+                       "opensrf_srfsh" ) 
+                               if building;    then $MAKE -C "$OPENSRF_DIR" "srfsh"; fi;
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "srfsh-install"; fi;
+                               ;;
+
+                       "opensrf_perl")
+                               if installing; then $MAKE -C "$OPENSRF_DIR" "perl-install"; fi;
+                               ;;
+
+
+                       # OpenILS ---                   
+
+                       "openils_all")
+                               if building;    then $MAKE -C "$OPENILS_DIR" all; fi;
+                               if installing; then $MAKE -C "$OPENILS_DIR" install; fi;
+                               ;;
+
+                       "openils_perl")
+                               if installing; then $MAKE -C "$OPENILS_DIR" "perl-install"; fi;
+                               ;;
+
+
+                       # Evergreen ---                         
+
+                       "evergreen_xul_client")
+                               if building;    then $MAKE -C "$EVERGREEN_DIR" xul; fi;
+                               ;;
+
 
                        *) fail "Unknown target: $target";;
 
@@ -148,7 +207,8 @@ function runInstall {
 # Checks command line parameters for special behavior
 # Supported params are:
 # clean - cleans all build files
-# force - forces build without the initial message
+# build - builds the specified sources
+# install - installs the specified sources
 # --------------------------------------------------------------------
 function checkParams {
 
@@ -161,26 +221,41 @@ function checkParams {
                case "$arg" in
 
                        "clean") 
-                               make -C OpenSRF/src clean
-                               make -C Open-ILS/src clean
-                               make -C Evergreen/src clean;;
+                               cleanMe;;
 
-                       "force")
-                               FORCE="1";;
+                       "build")
+                               BUILDING="1";;
+
+                       "install")
+                               INSTALLING="1";;
 
                        *) fail "Unknown command line argument: $arg";;
                esac
        done
 
-       echo "LAST $lastArg";
        if [ "$lastArg" = "clean" ]; then exit 0; fi;
 }
 
-# if user passes in the word 'clean' as the first shell arg, clean all
+
+function cleanMe {
+       loadConfig;
+       make -C "$OPENSRF_DIR" clean;
+       make -C "$OPENILS_DIR"  clean;
+       make -C "$EVERGREEN_DIR" clean;
+}
+
 checkParams "$@";
 
 
+if building; then echo "Building..."; fi;
+if installing; then echo "Installing..."; fi;
+
+
+# --------------------------------------------------------------------
 # Kick it off...
+# --------------------------------------------------------------------
+loadConfig;
+mkInstallDirs;
 runInstall;