Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Jun 2005 19:31:52 +0200
From:      Clement Laforet <sheepkiller@cultdeadsheep.org>
To:        apache@FreeBSD.org
Subject:   ${PORTSDIR}/Mk/bsd.apache.mk available for review
Message-ID:  <20050604173152.GC42661@goofy.cultdeadsheep.org>

next in thread | raw e-mail | index | archive | help

--HnQK338I3UIa/qiP
Content-Type: multipart/mixed; boundary="Ycz6tD7Th1CMF4v7"
Content-Disposition: inline


--Ycz6tD7Th1CMF4v7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi!

I finally wrote bsd.apache.mk, it was pending on my todo list for so=20
long, and now it's nearly ready for wide spread. So please test it :)

There's few changes from ports/www/apache2/Makefile.modules.3rd.
We now support "and superior" version scheme, you can now define
1.3/1.3+/2.0/2.0+/2.1/2.1+. USE_APACHE =3D apr will be functionnal soon,
I didn't have time to write it.

bsd.apache.mk should be used in all apache related ports, modules and
servers.

USE_APACHE=3D common{13,20,21} is designed for apache servers.
	- allows you to build apache and its modules staticly or
	dynamically linked. you still need to define modules/categories
	lists. It disables all default modules too.
	- suExec support for all versions.
	TODO:
	add server specific targets.

USE_APACHE=3D	<apache version> is designed for apache modules.
	- Find version of apache installed, check if modules is supported
	by installed version, or prefered version via APACHE_PORTS
	- AP_FAST_BUILD is still present
	- PLIST_SUB stuff is set

Not done:
USE_APACHE=3D apr is designed for ports depending on apr.
	It will allow you to select apr from devel ports or apache ports
	for your applications.

and maybe more...
Of course, it's fully backward compatible. USE_APACHE=3DYES and
WITH_APACHE2=3DYES will be deprecated as soon as it is committed.

How to test:
# cd /usr/ports
# fetch http://people.freebsd.org/~clement/ports/Mk/bsd.apache.mk.diff
# patch -p0 < bsd.apache.mk.diff

And patch your favorite makefiles ;-)

It's not intended to be perfect or bug free. If you have suggestions,
ideas, feel free to contact me (please Cc: -apache@ too, since it have
to be discussed)

clem

--Ycz6tD7Th1CMF4v7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="bsd.apache.mk.diff"
Content-Transfer-Encoding: quoted-printable

Index: Mk/bsd.apache.mk
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: Mk/bsd.apache.mk
diff -N Mk/bsd.apache.mk
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Mk/bsd.apache.mk	4 Jun 2005 16:58:40 -0000
@@ -0,0 +1,364 @@
+#-*- mode: makefile; tab-width: 4; -*-
+# ex:ts=3D4
+#
+# $FreeBSD$
+#
+# bsd.apache.mk - Apache related macros.
+# Author: Clement Laforet <clement@FreeBSD.org>
+#
+# Please view me with 4 column tabs!
+
+# This file includes several functionnalities:
+#	- automatic detection of installed apache version and/or set correct
+#	dependencies
+#	- semi-automatic target to make module porting easier
+#	- modules selection for apache server ports
+#
+
+##########################################################################
+#
+# Variables definition
+# USE_APACHE:	Call this script. Values can be:
+#		<version>: 1.3/13/2.0/20/2.1/1.3+/2.0+/2.1+
+#		common*: common13, common20 and common21
+#		apr: deal with apr stuff ;-)
+#
+# APXS:
+# APACHE_PORT:
+
+# Print warnings
+_ERROR_MSG=3D	: Error from bsd.apache.mk.
+APACHE_SUPPORTED_VERSION=3D	13 20 21
+.if ${USE_APACHE:Mcommon*} !=3D ""
+AP_PORT_IS_SERVER=3D	YES
+.elif ${USE_APACHE:L} =3D=3D apr
+APR_DEPS=3D			YES
+.elif ${USE_APACHE:C/\.//:C/\+//:M[12][310]} !=3D ""
+AP_PORT_IS_MODULE=3D	YES
+
+#### for backward compatibility
+.elif ${USE_APACHE:L} =3D=3D yes
+APXS=3D	${LOCALBASE}/sbin/apxs
+.   if defined(WITH_APACHE2)
+APACHE_PORT?=3D	www/apache20
+.   else
+APACHE_PORT?=3D	www/apache13
+.   endif
+APXS?=3D			${LOCALBASE}/sbin/apxs
+BUILD_DEPENDS+=3D	${APXS}:${PORTSDIR}/${APACHE_PORT}
+RUN_DEPENDS+=3D	${APXS}:${PORTSDIR}/${APACHE_PORT}
+#### End of backward compatibility
+
+.else
+IGNORE=3D		${_ERROR_MSG} Illegal use of USE_APACHE
+.endif
+
+.if defined(AP_PORT_IS_SERVER)
+# For slave ports:
+.if defined(SLAVE_DESIGNED_FOR) && ${PORTVERSION} !=3D ${SLAVE_DESIGNED_FO=
R}
+IGNORE=3D	"Sorry, ${SLAVENAME} and ${PORTNAME} versions are out of sync"
+.endif
+
+.if defined(SLAVE_PORT_MODULES)
+DEFAULT_MODULES_CATEGORIES+=3D	SLAVE_PORT
+ALL_MODULES_CATEGORIES+=3D		SLAVE_PORT
+.endif
+
+# Module selection
+.for category in ${DEFAULT_MODULES_CATEGORIES}
+DEFAULT_MODULES+=3D			${${category}_MODULES}
+WITH_${category}_MODULES=3D 	YES
+.endfor
+
+.for category in ${ALL_MODULES_CATEGORIES}
+AVAILABLE_MODULES+=3D			${${category}_MODULES}
+.endfor
+
+# Setting "@comment " as default.
+.for module in ${AVAILABLE_MODULES}
+${module}_PLIST_SUB=3D		"@comment "
+.endfor
+
+# Configure
+# dirty hacks to make sure all modules are disabled before we select them
+.if ${USE_APACHE} =3D=3D common13
+CONFIGURE_ARGS+=3D	--disable-module=3D"all"
+.elif ${USE_APACHE} =3D=3D common20
+CONFIGURE_ARGS+=3D	--disable-access --disable-auth \
+			--disable-charset-lite --disable-include \
+			--disable-log-config --disable-env --disable-setenvif \
+			--disable-mime --disable-status --disable-autoindex \
+			--disable-asis --disable-cgid --disable-cgi \
+			--disable-negotiation --disable-dir --disable-imap \
+			--disable-actions --disable-userdir --disable-alias
+.elif ${USE_APACHE} =3D=3D common21
+CONFIGURE_ARGS+=3D	--disable-authn-file --disable-authn-default \
+			--disable-authz-host --disable-authz-groupfile \
+			--disable-authz-user --disable-authz-default \
+			--disable-auth-basic --disable-charset-lite \
+			--disable-include --disable-log-config --disable-env \
+			--disable-setenvif --disable-mime --disable-status \
+			--disable-autoindex --disable-asis --disable-cgid \
+			--disable-cgi --disable-negotiation --disable-dir \
+			--disable-imap --disable-actions --disable-userdir \
+			--disable-alias
+.endif
+
+.if defined(WITH_MODULES)
+_APACHE_MODULES+=3D	${WITH_MODULES}
+.else
+.for category in ${ALL_MODULES_CATEGORIES}
+.if defined (WITHOUT_${category}_MODULES) || defined (WITH_CUSTOM_${catego=
ry})
+.        if defined(WITH_${category}_MODULES})
+.        undef WITH_${category}_MODULES
+.        endif
+.    if defined (WITH_CUSTOM_${category})
+_APACHE_MODULES+=3D	${WITH_CUSTOM_${category}}
+.    endif
+.elif defined(WITH_${category}_MODULES)
+_APACHE_MODULES+=3D	${${category}_MODULES}
+.endif
+.endfor
+.    if defined(WITH_EXTRA_MODULES)
+_APACHE_MODULES+=3D	${WITH_EXTRA_MODULES}
+.    endif
+.endif
+
+.if !defined(WITH_STATIC_APACHE)
+.    if ${USE_APACHE:Mcommon2*} !=3D ""
+# FYI
+#DYNAMIC_MODULES=3D	so
+CONFIGURE_ARGS+=3D	--enable-so
+.    endif
+.else
+.    if ${USE_APACHE:Mcommon2*} !=3D ""
+CONFIGURE_ARGS+=3D	--disable-so
+.    endif
+WITH_ALL_STATIC_MODULES=3D	YES
+.endif
+
+.if defined(WITH_SUEXEC) || defined(WITH_SUEXEC_MODULES)
+.if ${USE_APACHE} =3D=3D common13
+SUEXEC_CONFARGS=3D	suexec
+CONFIGURE_ARGS+=3D	--enable-suexec
+.elif ${USE_APACHE:Mcommon2*} !=3D ""
+SUEXEC_CONFARGS=3D	with-suexec
+.endif
+
+# From now we're defaulting to apache 2.*
+SUEXEC_DOCROOT?=3D		${PREFIX}/www/data
+SUEXEC_USERDIR?=3D		public_html
+SUEXEC_SAFEPATH?=3D		${PREFIX}/bin:${LOCALBASE}/bin:/usr/bin:/bin
+SUEXEC_LOGFILE?=3D		/var/log/httpd-suexec.log
+SUEXEC_UIDMIN?=3D			1000
+SUEXEC_GIDMIN?=3D			1000
+SUEXEC_CALLER?=3D			${WWWOWN}
+_APACHE_MODULES+=3D		${SUEXEC_MODULES}
+CONFIGURE_ARGS+=3D		--${SUEXEC_CONFARGS}-caller=3D${SUEXEC_CALLER} \
+				--${SUEXEC_CONFARGS}-uidmin=3D${SUEXEC_UIDMIN} \
+				--${SUEXEC_CONFARGS}-gidmin=3D${SUEXEC_GIDMIN} \
+				--${SUEXEC_CONFARGS}-userdir=3D"${SUEXEC_USERDIR}" \
+				--${SUEXEC_CONFARGS}-docroot=3D"${SUEXEC_DOCROOT}" \
+				--${SUEXEC_CONFARGS}-safepath=3D"${SUEXEC_SAFEPATH}" \
+				--${SUEXEC_CONFARGS}-logfile=3D"${SUEXEC_LOGFILE}" \
+				--${SUEXEC_CONFARGS}-bin=3D"${PREFIX}/sbin/suexec"
+.   if defined(WITH_SUEXEC_UMASK)
+CONFIGURE_ARGS+=3D		--${SUEXEC_CONFARGS}-umask=3D${WITH_SUEXEC_UMASK}
+.   endif
+.endif
+
+.if !defined(WITHOUT_MODULES)
+APACHE_MODULES=3D		${_APACHE_MODULES}
+.else
+APACHE_MODULES!=3D	\
+			for module in ${_APACHE_MODULES}; do \
+				${ECHO_CMD} ${WITHOUT_MODULES} | ${GREP} -wq $${module} 2> /dev/null |=
| \
+				${ECHO_CMD} $${module}; \
+			done
+.endif
+
+.if defined(WITH_STATIC_MODULES)
+.   if ${USE_APACHE} =3D=3D	common13
+STATIC_MODULE_CONFARG=3D	--enable-module=3D$${module}
+DSO_MODULE_CONFARG=3D		--enable-module=3D$${module} --enable-shared=3D$${m=
odule}
+.   else
+STATIC_MODULE_CONFARG=3D	--enable-$${module}
+DSO_MODULE_CONFARG=3D		--enable-$${module}=3Dshared
+.endif
+_CONFIGURE_ARGS!=3D	\
+			for module in ${APACHE_MODULES} ; do \
+				${ECHO_CMD} ${WITH_STATIC_MODULES} | \
+					${GREP} -wq $${module} 2> /dev/null ; \
+				if [ "$${?}" =3D "0" ] ; then \
+						${ECHO_CMD} "${STATIC_MODULE_CONFARG}"; \
+					else \
+						${ECHO_CMD} "${DSO_MODULE_CONFARG}"; \
+					fi; done
+CONFIGURE_ARGS+=3D	${_CONFIGURE_ARGS}
+.elif defined(WITH_STATIC_APACHE) || defined(WITH_ALL_STATIC_MODULES)
+WITH_STATIC_MODULES=3D	${APACHE_MODULES}
+.    if ${USE_APACHE} =3D=3D common13
+.      for module in ${APACHE_MODULES}
+CONFIGURE_ARGS+=3D	--enable-module=3D${module}
+.      endfor
+.    else
+CONFIGURE_ARGS+=3D	--enable-modules=3D"${APACHE_MODULES}"
+.    endif
+.else
+.    if ${USE_APACHE} =3D=3D common13
+.      for module in ${APACHE_MODULES}
+CONFIGURE_ARGS+=3D	--enable-module=3D${module} --enable-shared=3D${module}
+.      endfor
+.    else
+CONFIGURE_ARGS+=3D	--enable-mods-shared=3D"${APACHE_MODULES}"
+.    endif
+.endif
+
+.if defined(WITH_STATIC_MODULES)
+_SHARED_MODULES!=3D	\
+			for module in ${APACHE_MODULES} ; do \
+				${ECHO_CMD} ${WITH_STATIC_MODULES} | ${GREP} -wq $${module} 2> /dev/nu=
ll || \
+				${ECHO_CMD} $${module}; \
+			done
+SHARED_MODULES=3D		${_SHARED_MODULES}
+.elif !defined(WITH_ALL_STATIC_MODULES)
+SHARED_MODULES=3D		${APACHE_MODULES}
+.endif
+
+.  for module in ${SHARED_MODULES}
+${module}_PLIST_SUB=3D	""
+.  endfor
+
+.for module in ${AVAILABLE_MODULES}
+PLIST_SUB+=3D	MOD_${module:U}=3D${${module}_PLIST_SUB}
+.endfor
+####End of PORT_IS_SERVER ####
+
+.elif defined(APR_DEPS)
+IGNORE=3D		${_ERROR_MSG} apr support is not yet implemented
+#### XXX End of APR_DEPS ####
+
+.elif defined(AP_PORT_IS_MODULE)
+#### XXX Start of PORT IS MODULE ####
+AP_VERSION=3D	${USE_APACHE:C/\.//}
+
+APXS?=3D		${LOCALBASE}/sbin/apxs
+HTTPD?=3D		${LOCALBASE}/sbin/httpd
+
+MODULENAME?=3D	${PORTNAME}
+SHORTMODNAME?=3D	${MODULENAME:S/mod_//}
+SRC_FILE?=3D	${MODULENAME}.c
+OVERRIDABLE_VARS=3D	SRC_FILE MODULENAME SHORTMODNAME WRKSRC \
+					PKGNAMESUFFIX
+
+.if exists(${HTTPD})
+AP_CUR_VERSION!=3D	${HTTPD} -V | ${SED} -ne 's/^Server version: Apache\/\(=
[0-9]\)\.\([0-9]*\).*/\1\2/p'
+.   if ${AP_CUR_VERSION} > 13
+APACHE_MPM!=3D		${APXS} -q MPM_NAME
+.   endif =09
+.elif defined(APACHE_PORT)
+AP_CUR_VERSION!=3D	${ECHO_CMD} ${APACHE_PORT} | ${SED} -ne 's,.*/apache\([=
0-9]*\).*,\1,p'
+.endif
+
+.if defined(AP_CUR_VERSION)
+VERSION_CHECK!=3D		eval `${ECHO_CMD} "[ ${AP_VERSION} -eq ${AP_CUR_VERSION=
} ]" | ${SED} -e 's/- -eq/ -ge/ ; s/+ -eq/ -le/' ` ; ${ECHO_CMD} $${?}
+.   if ${VERSION_CHECK} =3D=3D 1
+IGNORE=3D		${_ERROR_MSG} apache${AP_CUR_VERSION} is installed (or APACHE_P=
ORT is defined) and port requires ${USE_APACHE}
+.   endif
+APACHE_VERSION=3D	${AP_CUR_VERSION}
+.else
+AP_CUR_VERSION=3D	none
+.   if defined(${APACHE_PORT})
+#Fallback to smallest version...
+APACHE_VERSION=3D	${AP_VERSION:C/\+//}
+.   endif
+.endif
+
+.if exists(${APXS})
+APXS_PREFIX!=3D	${APXS} -q prefix 2> /dev/null || echo NULL
+.   if ${APXS_PREFIX} =3D=3D NULL
+IGNORE=3D	: Your apache does not support DSO modules
+.   endif
+.   if defined(AP_GENPLIST) && ${APXS_PREFIX} !=3D ${PREFIX}
+IGNORE?=3D	PREFIX must be egal to APXS_PREFIX.
+.   endif
+.endif
+
+.if ${APACHE_VERSION} =3D=3D "20"
+AP_BUILDEXT=3D	la
+PLIST_SUB+=3D	APACHEMODDIR=3D"libexec/apache2" \
+			APACHEINCLUDEDIR=3D"include/apache2"
+APACHE_PORT=3D	www/apache${APACHE_VERSION}
+.elif ${APACHE_VERSION} =3D=3D "21"
+AP_BUILDEXT=3D	la
+PLIST_SUB+=3D	APACHEMODDIR=3D"libexec/apache${APACHE_VERSION}" \
+			APACHEINCLUDEDIR=3D"include/apache${APACHE_VERSION}"
+APACHE_PORT=3D	www/apache${APACHE_VERSION}
+.else
+AP_BUILDEXT=3D	so
+PLIST_SUB+=3D	APACHEMODDIR=3D"libexec/apache" \
+			APACHEINCLUDEDIR=3D"include/apache"
+APACHE_PORT?=3D www/apache13
+.endif
+.for VAR in ${OVERRIDABLE_VARS}
+.  if defined(AP${APACHE_VERSION}_${VAR})
+${VAR} =3D${AP${APACHE_VERSION}_${VAR}}
+.  endif
+.endfor
+
+BUILD_DEPENDS+=3D	${APXS}:${PORTSDIR}/${APACHE_PORT}
+RUN_DEPENDS+=3D	${APXS}:${PORTSDIR}/${APACHE_PORT}
+PLIST_SUB+=3D	AP_NAME=3D"${SHORTMODNAME}"
+PLIST_SUB+=3D	AP_MODULE=3D"${MODULENAME}.so"
+
+.if defined(AP_GENPLIST)
+PLIST?=3D		${WRKDIR}/ap-plist
+.endif
+
+.if defined(AP_INC)
+AP_EXTRAS+=3D	-I ${AP_INC}
+.endif
+.if defined(AP_LIB)
+AP_EXTRAS+=3D	-L ${AP_LIB}
+.endif
+
+#### XXX End of PORT IS MODULE ####
+.endif
+
+### XXX TARGETS ###
+.if defined(AP_PORT_IS_SERVER)
+#### XXX Start of PORT IS SERVER ####
+#### XXX End of PORT IS SERVER ####
+.elif defined(AP_PORT_IS_MODULE)
+#### XXX Start of PORT IS MODULE ####
+
+.if defined(AP_FAST_BUILD)
+.if !target(ap-gen-plist)
+ap-gen-plist:
+.if defined(AP_GENPLIST)
+.   if !exists(${PLIST})
+	@${ECHO} "=3D=3D=3D>  Generating apache plist"
+	@${ECHO} "@unexec %D/sbin/apxs -e -A -n %%AP_NAME%% %D/%%APACHEMODDIR%%/%=
%AP_MODULE%%" > ${PLIST}
+	@${ECHO} "%%APACHEMODDIR%%/%%AP_MODULE%%" >> ${PLIST}
+	@${ECHO} "@exec %D/sbin/apxs -e -A -n %%AP_NAME%% %D/%F" >> ${PLIST}
+	@${ECHO} "@unexec echo \"Don't forget to remove all ${MODULENAME}-related=
 directives in your httpd.conf\"">> ${PLIST}
+.   endif
+.else
+	@${DO_NADA}
+.endif
+.endif
+
+.if !target(do-build)
+do-build: ap-gen-plist
+	@cd ${WRKSRC} && ${APXS} -c ${AP_EXTRAS} -o ${MODULENAME}.${AP_BUILDEXT} =
${SRC_FILE}
+.endif
+
+.if !target(do-install)
+do-install:
+	@${APXS} -i -A -n ${SHORTMODNAME} ${WRKSRC}/${MODULENAME}.${AP_BUILDEXT}
+.endif
+
+.endif
+
+#### XXX End of PORT IS MODULE ####
+.endif
Index: Mk/bsd.port.mk
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /home/ncvs/ports/Mk/bsd.port.mk,v
retrieving revision 1.511
diff -u -r1.511 bsd.port.mk
--- Mk/bsd.port.mk	17 Mar 2005 23:22:07 -0000	1.511
+++ Mk/bsd.port.mk	4 Jun 2005 16:51:54 -0000
@@ -1769,6 +1769,10 @@
 .include "${PORTSDIR}/Mk/bsd.python.mk"
 .endif
=20
+.if defined(USE_APACHE)
+.include "${PORTSDIR}/Mk/bsd.apache.mk"
+.endif
+
 .if exists(${PORTSDIR}/../Makefile.inc)
 .include "${PORTSDIR}/../Makefile.inc"
 USE_SUBMAKE=3D	yes

--Ycz6tD7Th1CMF4v7--

--HnQK338I3UIa/qiP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFCoeWIsRhfjwcjuh0RApH2AJ4mlp2feYQ5+K57IeXvVx4rxKX8uQCfS1/X
u0yC0MDKVib2d2qjW/Fi14c=
=THq3
-----END PGP SIGNATURE-----

--HnQK338I3UIa/qiP--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050604173152.GC42661>