#!/bin/sh # Copyright 2001-2005 The Apache Software Foundation, or its licensors, as # applicable. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. prefix="" cmd="module" while test $# -gt 0; do case "$1" in -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac case "$1" in # It is possible for the user to override our prefix. --prefix=*) prefix=$optarg ;; --with-apxs=*) prefix=$optarg ;; --clean) echo "Cleaning files" rm *.o *.lo *.slo *.la exit 0 ;; --build) cmd="build" ;; --install) cmd="install" ;; --build-module) cmd="build-module" ;; --install-module) cmd="install-module" ;; --build-helpers) cmd="build-helpers" ;; --install-helpers) cmd="install-helpers" ;; esac # Next please. shift done if test -z "$prefix"; then echo "$0 options:" echo "--prefix Location of httpd-2.x install [required]" echo '--build Compile DSO and helpers [default]' echo '--build-module Compile mod_mbox DSO' echo "--build-helpers Compile helper programs" echo "--install Install DSO and helper programs" echo "--install-module Install DSO" echo "--install-helpers Install helper programs" echo '--all Compile and install DSO and helpers' echo "--clean Clean local directory" exit 0 fi if [ -x $prefix/bin/apxs ]; then apxs_loc=$prefix/bin/apxs elif [ -x $prefix ]; then apxs_loc=$prefix else echo "APXS not found! (try --prefix=/path/to/httpd-2.0)" exit 1 fi common_files="mbox_cache.c mbox_parse.c mbox_sort.c mbox_thread.c" helper_programs="mod-mbox-util generate_index calc_threads load_index load_msgid" build_helpers() { $apxs_loc -c -p -o libcommon.a $common_files for prg in $helper_programs; do $apxs_loc -c -p -o $prg $prg.c .libs/libcommon.a retval=$? if test $retval -ne 0; then exit $retval fi done } install_helpers() { bindir=`$apxs_loc -q bindir` for prg in $helper_programs; do echo "Installing $prg" if [ -f .libs/$prg ]; then cp .libs/$prg $bindir/$prg elif [ -f $prg ]; then cp $prg $bindir/$prg else echo "$prg is not found! Did you compile first?" exit 2 fi chmod +x $bindir/$prg done } build_module() { $apxs_loc -c mod_mbox.c $common_files retval=$? if test $retval -ne 0; then exit $retval fi } install_module() { $apxs_loc -i -a mod_mbox.la } case "$cmd" in build-helpers) build_helpers echo "=== Run $0 --install-helpers to install the helpers. ===" ;; build-module) build_module echo "=== Run $0 --install-module to install the DSO. ===" ;; build) build_module build_helpers echo "=== Run $0 --install to install the DSO and helpers. ===" ;; install-helpers) install_helpers ;; install-module) install_module ;; install) install_module install_helpers ;; esac exit 0