Magellan Linux

Contents of /branches/R11-unstable/include/apache2-module.sminc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 24893 - (show annotations) (download)
Tue Nov 25 02:21:44 2014 UTC (9 years, 5 months ago) by niro
File size: 3286 byte(s)
-release R11-unstable
1 # build apache2 modules
2
3 sminclude mtools
4
5 # some sane default dependencies and values
6 : ${PCAT="net-www"}
7 : ${DEPEND=">= net-www/apache2-2"}
8
9 # default SRCFILE SRCDIR and SRC_URI
10 : ${SRCFILE="${PNAME/#apache2-/}-${PVER}.tar.bz2"}
11 : ${SRCDIR="${BUILDDIR}/${PNAME/#apache2-/}-${PVER}"}
12 : ${SRC_URI=( mirror://${PNAME}/${SRCFILE} )}
13
14 # module name
15 : ${APACHE_MOD="${PNAME/#apache2-/}"}
16
17 # default configure opts
18 : ${APACHE_CONF_OPTS=""}
19 : ${APACHE_MAKE_OPTS=""}
20
21 # export postinstall function
22 SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS} apache2_modules_postinstall"
23 SPECIAL_VARS="${SPECIAL_VARS} APACHE_MOD"
24
25 apache2_modules_src_prepare()
26 {
27 munpack ${SRCFILE} || die
28 }
29
30 apache2_modules_src_compile()
31 {
32 cd ${SRCDIR}
33
34 # check for a configure script
35 if [[ -x configure ]]
36 then
37 mconfigure ${APACHE_CONF_OPTS} || die
38 fi
39
40 # check for a makefile
41 if [[ -f Makefile ]]
42 then
43 mmake ${APACHE_MAKE_OPTS} || die
44
45 # non found? then use apxs to compile the module
46 elif [[ -f ${APACHE_MOD}.c ]]
47 then
48 apxs -c ${APACHE_MOD}.c || die
49 else
50 die "No appropriate compile method found!"
51 fi
52 }
53
54 apache2_modules_so_install()
55 {
56 # get modules directory
57 local APACHE_MOD_DIR="$(apxs -q LIBEXECDIR)"
58 minstalldir ${APACHE_MOD_DIR} || die
59
60 # first check ${SRCDIR}/.lib dir for the compiled module
61 if [[ -f .libs/${APACHE_MOD}.so ]]
62 then
63 minstallexec .libs/${APACHE_MOD}.so ${APACHE_MOD_DIR} || die
64
65 # if not exist check ${SRCDIR}
66 elif [[ -f ${APACHE_MOD}.so ]]
67 then
68 minstallexec ${APACHE_MOD}.so ${APACHE_MOD_DIR} || die
69 else
70 die "No compiled module '${APACHE_MOD}.so' found"
71 fi
72 }
73
74 apache2_modules_conf_install()
75 {
76 # install loader config if a special one exist
77 local APACHE_SYSCONFDIR="$(apxs -q SYSCONFDIR)"
78 if [[ -f ${SOURCESDIR}/${PNAME}/${APACHE_MOD}.conf ]]
79 then
80 minstalldir ${APACHE_SYSCONFDIR}/modules.d
81 minstallfile -s ${APACHE_MOD}.conf ${APACHE_SYSCONFDIR}/modules.d || die
82
83 # if not then generate one automatically
84 else
85 echo "<IfModule !${APACHE_MOD}.c>" > ${APACHE_MOD}.conf
86 echo " LoadModule ${APACHE_MOD/mod_/}_module modules/${APACHE_MOD}.so" >> ${APACHE_MOD}.conf
87 echo "</IfModule>" >> ${APACHE_MOD}.conf
88
89 minstalldir ${APACHE_SYSCONFDIR}/modules.d
90 minstallfile ${APACHE_MOD}.conf ${APACHE_SYSCONFDIR}/modules.d || die
91 fi
92 }
93
94 apache2_modules_src_install()
95 {
96 cd ${SRCDIR}
97
98 # check for a makefile installation
99 if [[ -f Makefile ]]
100 then
101 mmake DESTDIR=${BINDIR} install || die
102 else
103 # install .so module
104 apache2_modules_so_install || die
105 fi
106
107 # install modules config file
108 apache2_modules_conf_install
109
110 local i
111 for i in ABOUT-NLS AUTHORS BUGS CHANGES ChangeLog COPYING \
112 FAQ LICENSE NEWS README TODO
113 do
114 if [ -f ${SRCDIR}/${i} ]
115 then
116 minstalldocs ${i} || die
117 fi
118 done
119
120 # do not use extended test constructs here [[ ]] because of the *
121 if [ -f *.html ]
122 then
123 minstallhtml *.html || die
124 fi
125 }
126
127 apache2_modules_postinstall()
128 {
129 local APACHE_SYSCONFDIR="$(apxs -q SYSCONFDIR)"
130
131 echo
132 echo "To use the '${APACHE_MOD}' module, you need to enable it in your apache config."
133 echo "Just add a line like:"
134 echo " 'Include ${APACHE_SYSCONFDIR}/modules.d/${APACHE_MOD}.conf'"
135 echo "to your httpd config file ${APACHE_SYSCONFDIR}/httpd.conf."
136 echo
137 }
138
139 export_inherits apache2_modules src_prepare src_compile src_install postinstall