# build apache2 modules sminclude mtools # some sane default dependencies and values : ${PCAT="net-www"} : ${DEPEND=">= net-www/apache2-2"} # default SRCFILE SRCDIR and SRC_URI : ${SRCFILE="${PNAME/#apache2-/}-${PVER}.tar.bz2"} : ${SRCDIR="${BUILDDIR}/${PNAME/#apache2-/}-${PVER}"} : ${SRC_URI=( mirror://${PNAME}/${SRCFILE} )} # module name : ${APACHE_MOD="${PNAME/#apache2-/}"} # default configure opts : ${APACHE_CONF_OPTS=""} : ${APACHE_MAKE_OPTS=""} # export postinstall function SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} apache2_modules_postinstall" SPECIAL_VARS="${SPECIAL_VARS} APACHE_MOD" apache2_modules_src_prepare() { munpack ${SRCFILE} || die } apache2_modules_src_compile() { cd ${SRCDIR} # check for a configure script if [[ -x configure ]] then mconfigure ${APACHE_CONF_OPTS} || die fi # check for a makefile if [[ -f Makefile ]] then mmake ${APACHE_MAKE_OPTS} || die # non found? then use apxs to compile the module elif [[ -f ${APACHE_MOD}.c ]] then apxs -c ${APACHE_MOD}.c || die else die "No appropriate compile method found!" fi } apache2_modules_so_install() { # get modules directory local APACHE_MOD_DIR="$(apxs -q LIBEXECDIR)" minstalldir ${APACHE_MOD_DIR} || die # first check ${SRCDIR}/.lib dir for the compiled module if [[ -f .libs/${APACHE_MOD}.so ]] then minstallexec .libs/${APACHE_MOD}.so ${APACHE_MOD_DIR} || die # if not exist check ${SRCDIR} elif [[ -f ${APACHE_MOD}.so ]] then minstallexec ${APACHE_MOD}.so ${APACHE_MOD_DIR} || die else die "No compiled module '${APACHE_MOD}.so' found" fi } apache2_modules_conf_install() { # install loader config if a special one exist local APACHE_SYSCONFDIR="$(apxs -q SYSCONFDIR)" if [[ -f ${SOURCESDIR}/${PNAME}/${APACHE_MOD}.conf ]] then minstalldir ${APACHE_SYSCONFDIR}/modules.d minstallfile -s ${APACHE_MOD}.conf ${APACHE_SYSCONFDIR}/modules.d || die # if not then generate one automatically else echo "" > ${APACHE_MOD}.conf echo " LoadModule ${APACHE_MOD/mod_/}_module modules/${APACHE_MOD}.so" >> ${APACHE_MOD}.conf echo "" >> ${APACHE_MOD}.conf minstalldir ${APACHE_SYSCONFDIR}/modules.d minstallfile ${APACHE_MOD}.conf ${APACHE_SYSCONFDIR}/modules.d || die fi } apache2_modules_src_install() { cd ${SRCDIR} # check for a makefile installation if [[ -f Makefile ]] then mmake DESTDIR=${BINDIR} install || die else # install .so module apache2_modules_so_install || die fi # install modules config file apache2_modules_conf_install local i for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \ FAQ LICENSE NEWS README TODO do if [ -f ${SRCDIR}/${i} ] then minstalldocs ${i} || die fi done # do not use extended test constructs here [[ ]] because of the * if [ -f *.html ] then minstallhtml *.html || die fi } apache2_modules_postinstall() { local APACHE_SYSCONFDIR="$(apxs -q SYSCONFDIR)" echo echo "To use the '${APACHE_MOD}' module, you need to enable it in your apache config." echo "Just add a line like:" echo " 'Include ${APACHE_SYSCONFDIR}/modules.d/${APACHE_MOD}.conf'" echo "to your httpd config file ${APACHE_SYSCONFDIR}/httpd.conf." echo } export_inherits apache2_modules src_prepare src_compile src_install postinstall