Bug 18960

Summary: Add USE_APACHE to bsd.port.mk for Apache module ports
Product: Ports & Packages Reporter: Scot W. Hetzel <hetzels>
Component: Individual Port(s)Assignee: Port Management Team <portmgr>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Scot W. Hetzel 2000-06-02 02:50:00 UTC
	The apache module ports will be needing to depend on different
	Apache ports (apache13, apache13+ipv6, apache13-ssl).  In order for
	them to accomplish this, they will need to have their dependancies
	very depending on which Apache port is installed.

Fix: USE_APACHE defines some common variables and build, run dependancies
	used by the Apache module ports.
Comment 1 Scot W. Hetzel 2000-06-02 03:51:27 UTC
Attached is an additional patch for USE_APACHE that will allow it
to distingush between an apache13 and an apache13-ssl installation.

Scot

--- bsd.port.mk.orig	Thu Jun  1 20:33:48 2000
+++ bsd.port.mk	Thu Jun  1 21:37:24 2000
@@ -713,12 +713,16 @@
 APXS=		${PREFIX}/sbin/apxs
 
 .if exists(${APXS})
+AP_TARGET!=	${APXS} -q TARGET
 AP_PORT!=	if ${APXS} -q AP_PORT > /dev/null 2>&1 ; then \
 			${APXS} -q AP_PORT ; \
 		else \
-			echo "apache13" ; \
+			if [ "${AP_TARGET}" = "httpsd" ] ; then \
+				echo "apache13-ssl" ; \
+			else \
+				echo "apache13" ; \
+			fi ; \
 		fi
-AP_TARGET!=	${APXS} -q TARGET
 AP_SBINDIR!=	${APXS} -q SBINDIR
 AP_INCLUDE!=	${APXS} -q INCLUDEDIR
 AP_LIBEXEC!=	${APXS} -q LIBEXECDIR
@@ -726,7 +730,11 @@
 AP_PREFIX!=	${APXS} -q PREFIX
 .else
 AP_PORT?=	apache13
+.if ${AP_PORT} == "apache13-ssl"
+AP_TARGET?=	httpsd
+.else
 AP_TARGET?=	httpd
+.endif
 AP_SBINDIR?=	${PREFIX}/sbin
 AP_INCLUDE?=	${PREFIX}/include/apache
 AP_LIBEXEC?=	${PREFIX}/libexec/apache
Comment 2 Tim Vanderhoek 2000-06-02 07:31:10 UTC
On Thu, Jun 01, 2000 at 08:48:11PM -0500, hetzels@westbend.net wrote:
> 
> +AP_TARGET!=	${APXS} -q TARGET
> +AP_SBINDIR!=	${APXS} -q SBINDIR
> +AP_INCLUDE!=	${APXS} -q INCLUDEDIR
> +AP_LIBEXEC!=	${APXS} -q LIBEXECDIR
> +AP_SYSCONF!=	${APXS} -q SYSCONFDIR
> +AP_PREFIX!=	${APXS} -q PREFIX

All of these should probably also be added to the list of precious
make vars preserved through the environment at the end of bsd.port.mk.

It would be faster to do something like:

_AP_PATHS!= ${APXS} -q TARGET SBINDIR INCLUDEDIR ... | \
    ${AWK} '{print "TARGET:" $1 " " "SBINDIR:" $2 ...}'
AP_TARGET=${_AP_PATHS:MTARGET*:S/^TARGET//}
AP_SBINDIR=${_AP_PATHS:MSBINDIR*:S/^SBINDIR//}
...

Then only _AP_PATHS would be worthwhile for listing as a previous make
variable.

For more trickery, you could get away with something like

AP_TARGET=	`${APXS} -q TARGET`

for most cases, I imagine.  That's fastest of all.

There's also no particular reason why ports that need these vars can't
simply set the vars themselves.

> +		AP_LIBEXEC=${AP_LIBEXEC:S/^${PREFIX}\///} \
> +		AP_SYSCONF=${AP_SYSCONF:S/^${PREFIX}\///}
>  .endif

It also looks like there's an .endif missing, but I'm probably just
not reading the patch right.  :)


-- 
Signature withheld by request of author.
Comment 3 Tim Vanderhoek 2000-06-02 08:41:09 UTC
On Thu, Jun 01, 2000 at 11:40:06PM -0700, Tim Vanderhoek wrote:
>  
>  Then only _AP_PATHS would be worthwhile for listing as a previous make
>  variable.

"precious make variable", even.
Comment 4 Scot W. Hetzel 2000-06-03 05:15:59 UTC
From: "Tim Vanderhoek" <vanderh@ecf.utoronto.ca>
> On Thu, Jun 01, 2000 at 08:48:11PM -0500, hetzels@westbend.net wrote:
> > 
> > +AP_TARGET!= ${APXS} -q TARGET
> > +AP_SBINDIR!= ${APXS} -q SBINDIR
> > +AP_INCLUDE!= ${APXS} -q INCLUDEDIR
> > +AP_LIBEXEC!= ${APXS} -q LIBEXECDIR
> > +AP_SYSCONF!= ${APXS} -q SYSCONFDIR
> > +AP_PREFIX!= ${APXS} -q PREFIX
> 
> All of these should probably also be added to the list of precious
> make vars preserved through the environment at the end of bsd.port.mk.
> 
> It would be faster to do something like:
> 
> _AP_PATHS!= ${APXS} -q TARGET SBINDIR INCLUDEDIR ... | \
>     ${AWK} '{print "TARGET:" $1 " " "SBINDIR:" $2 ...}'
> AP_TARGET=${_AP_PATHS:MTARGET*:S/^TARGET//}
> AP_SBINDIR=${_AP_PATHS:MSBINDIR*:S/^SBINDIR//}
> ...
> 
> Then only _AP_PATHS would be worthwhile for listing as a previous make
> variable.
> 
So your suggesting that using _AP_PATHS would make it so that ${APXS} -q ...
gets executed only once, instead of multiple times for each AP_* variable
and each make target?

I recreated USE_APACHE as you suggested, but had only a couple of problems:

1. ${_AP_PATHS:MTARGET*:S/^TARGET//} would return with ":httpd". I removed
   the ":" from the awk script, and that made it return with the correct
   value "httpd".

2. ${AWK} is not defined early enough in the bsd.port.mk file, so I used
   /usr/bin/awk instead.

> For more trickery, you could get away with something like
> 
> AP_TARGET= `${APXS} -q TARGET`
> 
> for most cases, I imagine.  That's fastest of all.
> 

Only one problem with this approach, AP_* gets defined as:

`/usr/local/sbin/apxs -q <apxs_variable>`

While this works with RUN_DEPENDS, it doesn't work when you use the var
in PLIST_SUB.

===>   Generating temporary packing list
/usr/local/sbin/apxs!g: not found

and the work/.PLIST.mktmp contains:

/libphp3.so

instead of

libexec/apache/libphp3.so

> There's also no particular reason why ports that need these vars can't
> simply set the vars themselves.
> 
There will be eight Apache module ports:

 mod_auth_mysql		New port
 mod_dav
 mod_dtcl
 mod_frontpage		apache13-fp
 mod_jserv		apache-jserv
 mod_php3		apache13-php3
 mod_php4		apache13-php4
 mod_ssl		apache13-modssl

that will need some form of the "if exists(${APXS}) .. else .. if" code, along
with the ability to build/run depend on any of the 3 main apache ports:

 apache13
 apache13+ipv6
 apache13-ssl

Having USE_APACHE defined in the bsd.port.mk, along with the AP_* vars, will
make these ports consistant, as well as making it easier to add new Apache
module ports.

> It also looks like there's an .endif missing, but I'm probably just
> not reading the patch right.  :)
> 
The .endif is there (see +.endif at top of 2nd section). :)

Scot

NOTE for Satoshi Asami:  Use this patch instead of the originally submitted patch
if it meets with your approval.

--- bsd.port.mk.orig	Sat May  6 20:09:14 2000
+++ bsd.port.mk	Fri Jun  2 21:45:37 2000
@@ -118,6 +118,15 @@
 #
 # Use these if your port uses some of the common software packages.
 #
+# USE_APACHE	- Says that the port uses Apache for building and running.
+# AP_PORT	- Set to the name of the apache port (default: apache13)
+# AP_TARGET	- Set to the name of the apache server (default: httpd)
+# AP_SBINDIR	- Set to the location of the apache sbin directory
+# AP_INCLUDE	- Set to the location of the apache include directory
+# AP_LIBEXEC	- Set to the location of the apache libexec directory
+# AP_SYSCONF	- Set to the location of the apache config directory
+# AP_PREFIX	- Set to the apache prefix (default: ${PREFIX})
+#
 # USE_BZIP2		- Says that the port tarballs use bzip2, not gzip, for
 #				  compression.
 # USE_ZIP		- Says that the port distfile uses zip, not tar w/[bg]zip
@@ -700,6 +709,59 @@
 USE_NEWGCC=	yes
 .endif
 
+.if defined(USE_APACHE)
+APXS=		${PREFIX}/sbin/apxs
+
+.if exists(${APXS})
+.if !defined(_AP_PATHS)
+_AP_PATHS!=	${APXS} -q TARGET SBINDIR INCLUDEDIR LIBEXECDIR SYSCONFDIR PREFIX | \
+		/usr/bin/awk '{print "TARGET" $$1 " SBINDIR" $$2 " INCLUDEDIR" $$3 " LIBEXECDIR" $$4 " SYSCONFDIR" $$5 " PREFIX" $$6 }'
+.endif
+AP_TARGET=	${_AP_PATHS:MTARGET*:S/^TARGET//}
+AP_SBINDIR=	${_AP_PATHS:MSBINDIR*:S/^SBINDIR//}
+AP_INCLUDE=	${_AP_PATHS:MINCLUDEDIR*:S/^INCLUDEDIR//}
+AP_LIBEXEC=	${_AP_PATHS:MLIBEXECDIR*:S/^LIBEXECDIR//}
+AP_SYSCONF=	${_AP_PATHS:MSYSCONFDIR*:S/^SYSCONFDIR//}
+AP_PREFIX=	${_AP_PATHS:MPREFIX*:S/^PREFIX//}
+
+AP_PORT!=	if ${APXS} -q AP_PORT > /dev/null 2>&1 ; then \
+			${APXS} -q AP_PORT ; \
+		else \
+			if [ "${AP_TARGET}" = "httpsd" ] ; then \
+				echo "apache13-ssl" ; \
+			else \
+				echo "apache13" ; \
+			fi ; \
+		fi
+.else
+AP_PORT?=	apache13
+.if ${AP_PORT} == "apache13-ssl"
+AP_TARGET?=	httpsd
+.else
+AP_TARGET?=	httpd
+.endif
+AP_SBINDIR?=	${PREFIX}/sbin
+AP_INCLUDE?=	${PREFIX}/include/apache
+AP_LIBEXEC?=	${PREFIX}/libexec/apache
+AP_SYSCONF?=	${PREFIX}/etc/apache
+AP_PREFIX?=	${PREFIX}
+.endif
+
+.if ${AP_PORT} == "apache13-ssl"
+PKGNAMESUFFIX= -ap_ssl
+.elif ${AP_PORT} == "apache13+ipv6"
+PKGNAMESUFFIX=	-ap+ipv6
+.endif
+
+BUILD_DEPENDS+=	${APXS}:${PORTSDIR}/www/${AP_PORT}
+RUN_DEPENDS+=	${PREFIX}/sbin/${AP_TARGET}:${PORTSDIR}/www/${AP_PORT}
+
+PLIST_SUB+=	AP_SBINDIR=${AP_SBINDIR:S/^${PREFIX}\///} \
+		AP_INCLUDE=${AP_INCLUDE:S/^${PREFIX}\///} \
+		AP_LIBEXEC=${AP_LIBEXEC:S/^${PREFIX}\///} \
+		AP_SYSCONF=${AP_SYSCONF:S/^${PREFIX}\///}
+.endif
+
 .if defined(USE_BZIP2)
 BUILD_DEPENDS+=		bzip2:${PORTSDIR}/archivers/bzip2
 .endif
@@ -2831,7 +2893,7 @@
 .endif
 
 .if !defined(NOPRECIOUSMAKEVARS)
-.for softvar in CKSUMFILES _MLINKS PKGBASE
+.for softvar in CKSUMFILES _MLINKS PKGBASE _AP_PATHS
 .if defined(${softvar})
 __softMAKEFLAGS+=      '${softvar}+=${${softvar}:S/'/'\''/g}'
 .endif
Comment 5 Tim Vanderhoek 2000-06-03 06:43:08 UTC
On Fri, Jun 02, 2000 at 09:20:04PM -0700, Scot W. Hetzel wrote:
>  
> I recreated USE_APACHE as you suggested, but had only a couple of problems:

It was a casual suggestion.  :-)


>> For more trickery, you could get away with something like
>> 
>> AP_TARGET= `${APXS} -q TARGET`
>  
>  Only one problem with this approach, AP_* gets defined as:

You need to use

AP_TARGET=	"`${APXS} -q TARGET`"

and then I think it will work.  Sorry about that.


>  +AP_PORT!=	if ${APXS} -q AP_PORT > /dev/null 2>&1 ; then \
>  +			${APXS} -q AP_PORT ; \

This can't be a precious variable?


>   .if !defined(NOPRECIOUSMAKEVARS)
>  -.for softvar in CKSUMFILES _MLINKS PKGBASE
>  +.for softvar in CKSUMFILES _MLINKS PKGBASE _AP_PATHS
>   .if defined(${softvar})
>   __softMAKEFLAGS+=      '${softvar}+=${${softvar}:S/'/'\''/g}'
>   .endif

How is PKGBASE different from ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}?

I have a feeling it isn't different.  :-)


[If there are any more changes you want to make to the patch, you may
 choose to wait for this to be approved in concept before sending them.]


-- 
Signature withheld by request of author.
Comment 6 Scot W. Hetzel 2000-06-03 16:40:57 UTC
From: "Tim Vanderhoek" <vanderh@ecf.utoronto.ca>
> >  +AP_PORT!= if ${APXS} -q AP_PORT > /dev/null 2>&1 ; then \
> >  + ${APXS} -q AP_PORT ; \
>
> This can't be a precious variable?
>
I'm not sure if it can be used as a precious variable, as AP_PORT can also
be used on the make command line to specify which apache13* port to build
the module for.  AP_PORT needs to be overriden when ${APXS} exist on the
system, as a patched ${APXS} will know which apache13* port is installed.
Wrapping AP_PORT in a .if defined(AP_PORT) .. .endif will prevent this from
occuring.

> >   .if !defined(NOPRECIOUSMAKEVARS)
> >  -.for softvar in CKSUMFILES _MLINKS PKGBASE
> >  +.for softvar in CKSUMFILES _MLINKS PKGBASE _AP_PATHS
> >   .if defined(${softvar})
> >   __softMAKEFLAGS+=      '${softvar}+=${${softvar}:S/'/'\''/g}'
> >   .endif
>
> How is PKGBASE different from ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}?
>
> I have a feeling it isn't different.  :-)
>
According to bsd.port.mk:

# The "latest version" link -- ${PKGNAME} minus everything after the last
'-'
PKGLATESTREPOSITORY?=   ${PACKAGES}/Latest
.if !defined(PKGBASE)
PKGBASE!=       ${ECHO} ${PKGNAME} | ${SED} -e 's/-[^-]*$$//'

>[If there are any more changes you want to make to the patch, you may
> choose to wait for this to be approved in concept before sending them.]

I believe that the patch is now complete and won't be making any further
changes.

Scot
Comment 7 Tim Vanderhoek 2000-06-04 01:53:11 UTC
On Sat, Jun 03, 2000 at 08:50:03AM -0700, Scot W. Hetzel wrote:
> 
>  I'm not sure if it can be used as a precious variable, as AP_PORT can also
>  be used on the make command line to specify which apache13* port to build
>  the module for.  AP_PORT needs to be overriden when ${APXS} exist on the
>  system, as a patched ${APXS} will know which apache13* port is installed.

Hmm...

Ugh.  Conditional over-riding of a commandline variable.

I hope you know what you're doing...  Commandline variables are
entered into the environment.  That is how they are passed to
successive invocations of make(1).  A commandline variable
(generally?) can't be overridden from within make.  However, an
environment variable can be overridden from within make.  When
bsd.port.mk calls itself recursively, the AP_PORT variable will be
over-rideable.  When it is on the non-recursive call, AP_PORT will not
be over-rideable.

I can't entirely remember why the softMAKEFLAGS use '+=' instead of
'=', but I think this was one of the reasons I did it that way.  And
then there was some reason they needed to be normal rather than
environment variables.  I blame Satoshi Asami for not forcing me to write
comments surrounding that stuff.  ;-)


Anyways, other than the potential problems with overriding a
commandline variable, I don't think there's any reason that such a
variable can't also be a precious make variable.  Just change the line

AP_PORT!= ...

to

_AP_PORT!= ...

and make _AP_PORT the precious variable.  Then conditionally set
AP_PORT to _AP_PORT.

I can look more closely at how to do that later if the patch is
approved in concept (and if overriding a commandline variable is
really what you want to do).


>  > How is PKGBASE different from ${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}?
>  >
>  > I have a feeling it isn't different.  :-)
>
>  According to bsd.port.mk:

The correct answer was "No, there is no difference."  :-)

Just to make sure, I'm running a quick check-pkg_base-equals-portname:
target on all the ports right now, but I expect no surprises.


-- 
Signature withheld by request of author.
Comment 8 Scot W. Hetzel 2000-06-04 02:51:21 UTC
From: "Tim Vanderhoek" <vanderh@ecf.utoronto.ca>
> On Sat, Jun 03, 2000 at 08:50:03AM -0700, Scot W. Hetzel wrote:
> >
> >  I'm not sure if it can be used as a precious variable, as AP_PORT can
also
> >  be used on the make command line to specify which apache13* port to
build
> >  the module for.  AP_PORT needs to be overriden when ${APXS} exist on
the
> >  system, as a patched ${APXS} will know which apache13* port is
installed.
>
> Hmm...
>
> Ugh.  Conditional over-riding of a commandline variable.
>

>
> Anyways, other than the potential problems with overriding a
> commandline variable, I don't think there's any reason that such a
> variable can't also be a precious make variable.  Just change the line
>
> AP_PORT!= ...
>
> to
>
> _AP_PORT!= ...
>
> and make _AP_PORT the precious variable.  Then conditionally set
> AP_PORT to _AP_PORT.
>
> I can look more closely at how to do that later if the patch is
> approved in concept (and if overriding a commandline variable is
> really what you want to do).
>
I just thought of another ideal, that would make this more appealing.  We
turn AP_PORT in to a precious variable as you suggested.  Then we return an
error if AP_PORT is defined and doesn't match _AP_PORT.

.if defined(AP_PORT) && ${AP_PORT} != ${_AP_PORT}
.BEGIN
    echo "${_AP_PORT} previously installed"
    false
.END
.elif !defined(AP_PORT)
AP_PORT=    ${_AP_PORT}
.endif

Scot
Comment 9 Tim Vanderhoek 2000-06-04 05:41:17 UTC
On Sat, Jun 03, 2000 at 07:00:01PM -0700, Scot W. Hetzel wrote:
> 
>  I just thought of another ideal, that would make this more appealing.  We
>  turn AP_PORT in to a precious variable as you suggested.  Then we return an
>  error if AP_PORT is defined and doesn't match _AP_PORT.

I like this much much more than trying to override a command=line
variable...  :-)


-- 
Signature withheld by request of author.
Comment 10 alex freebsd_committer freebsd_triage 2000-06-12 16:34:12 UTC
Responsible Changed
From-To: freebsd-ports->asami

bsd.port.mk is PW's baby.
Comment 11 Will Andrews freebsd_committer freebsd_triage 2001-04-04 09:11:43 UTC
Responsible Changed
From-To: asami->portmgr

Over to new maintainer.
Comment 12 Joe Marcus Clarke freebsd_committer freebsd_triage 2003-11-15 20:51:30 UTC
State Changed
From-To: open->closed

USE_APACHE has been added to bsd.port.mk.