***************************************** 
README:
runtime-src/packages/apache-httpd
***************************************** 

This Readme explains the customisations made Apache Httpd
zipped files in this folder.

********************************************************************************************
(A) FILE: httpd-2.2.11-gs.tar.gz: Apache Httpd 2 src code with
modifications for Greenstone.
********************************************************************************************
July 2024 - ak19

Mac compilers are stricter now and produce errors where there used to be warnings. Among these are instances where httpd-2.2.11's original config.guess files got run and it would guess the current x86_64 darwin OS was i386 instead.

Newer versions of apache-httpd have more up to date config.guess files (and their accessory config.sub files), that correctly work out that our Mac Monterey is x86_64.

I have modified the httpd-2.2.11-gs.tar.gz with copies of the config.guess and config.sub from the newest apache-httpd at the time of writing: httpd-2.4.68. It has only one config.guess as newer apache's don't come with bundled with apr and apr-util (nor apr-iconv) any more. However, I've also put copies of the config.guess and config.sub files of httpd-2.2.34 (2.2.34 being the last version of apache-httpd that still came bundled with apr, apr-util and I think apr-iconv). The 2.2.34 versions are stored unused at the top level as unusedConfigDotGuess-from-2.2.34 and unusedConfigDotSub-from-2.2.34. [*]

There were 4 each of config.guess and config.sub in the original httpd-2.2.11. Each of these have been replaced with the same httpd-2.4.68/build/config.guess and httpd-2.4.68/build/config.sub
and then made executable, as follows.

DETAILS:

cd /path/to/GS2/runtime-src/packages/apache-httpd/httpd-2.2.11

# Eyeball how many config.guess and config.sub files are in http-2.2.11 that need replacing

httpd-2.2.11 % find . -name config.sub                                           
./srclib/apr-util/xml/expat/conftools/config.sub
./srclib/apr-util/build/config.sub
./srclib/apr/build/config.sub
./build/config.sub

httpd-2.2.11 % find . -name config.guess                                         
./srclib/apr-util/xml/expat/conftools/config.guess
./srclib/apr-util/build/config.guess
./srclib/apr/build/config.guess
./build/config.guess

  # Note that diffing showed that ./srclib/apr-util/xml/expat/conftools/config.guess was
  # different from the others which all looked identical to each other.
  # Similarly in httpd-2.2.34: the ./srclib/apr-util/xml/expat/conftools/config.guess and
  # config.sub there once again looked different from the others, but just a few lines this time
  # and these didn't appear to be relevant to retain. I've captured both httpd-2.2.11's common
  # original config.guess and config.sub, and the unique ones in srclib/apr-util/xml/expat/conftools/
  # in the toplevel httpd-2.2.11 folder as:
  origCommonConfigDotGuess
  origCommonConfigDotSub
  origExpatConfigDotGuess
  origExpatConfigDotSub

  # [*] Also stored at httpd-2.2.11's top level are unusedExpatConfigDotGuess-from-2.2.34
  # and unusedExpatConfigDotSub-from-2.2.34, which are the slightly divergent versions
  # in httpd-2.2.34's srclib/apr-util/xml/expat/conftools/

# Replace each config.guess in httpd-2.2.11 with the one from 2.4.68 located at full path to httpd-2.4.68/build/config.(guess|sub) 
find . -name config.guess -exec cp /Users/greenstone/gs2-svn-26Jun2026/runtime-src/packages/apache-httpd/httpd-2.4.68/build/config.guess {} \;
find . -name config.sub -exec cp /Users/greenstone/gs2-svn-26Jun2026/runtime-src/packages/apache-httpd/httpd-2.4.68/build/config.sub {} \;

# Make them all executable
find . -name config.guess -exec chmod u+x {} \;
find . -name config.sub -exec chmod u+x {} \;

# Eyeball that they're all made executable
find . -name config.guess -exec ls -la {} \;
find . -name config.sub -exec ls -la {} \;

---------------------------------------------------------

Sep 2022 - kjdon

I have updated a few of the windows files so that it will compile using Visual Studio 2017. Note, I'm not sure what version below this is the cutoff for these
changes not to be needed.
Also note, the windows version of 2.2.11 is for win32, so you need to use vcvars32, not vcvars64 when setting up Visual Studio environment.

The following files were modified. All mods are signalled with kjdon 2022 in comments. The help pages where I found these solutions plus some info from them detailed also.

***** ./httpd-2.2.11/srclib/apr/atomic/win32/apr_atomic.c 
---------------------------------------------------------

see https://marc.info/?l=apr-dev&m=138386228311375&w=2


In the Platform Toolset v120 (VS2013), the function InterlockedIncrement() and the friends are specified with 

#pragma intrinsic(_InterlockedIncrement)

for all the platforms, including x86. Whereas in the former versions of SDK, the intrisnic pragma directive is used for x64 but NOT for x86. I can clearly see the difference comparing the header files. And there doesn't seem to be any defines which would allow us to revert the behavior.

Thus, the function casts introduced in apr_atomic.c resolve/work for former versions but cause link errors with v120 since the function calls for x86 are now intrinsic as they have been for x64.

Given all these differences between platforms and toolset versions, I'd simply not use the function cast wrappers but still take care of the differences between APR and underlying Windows interfaces.)

***** ./httpd-2.2.11/srclib/apr-iconv/build/modules.mk.win 
----------------------------------------------------------

see https://stackoverflow.com/questions/36897691/compile-apache-apr-on-windows

***** ./httpd-2.2.11/support/win32/ApacheMonitor.c
---------------------------------------------------

see https://lists.apache.org/thread/9rkox41zmhc6g1nb1jx4h9ph02zklkrv

setargv() is supposed to read in the console args because that's a GUI app
and they have to use WinMain. For that to work, one should actually link
with setargv.obj
https://msdn.microsoft.com/en-us/library/8bch7bkk%28v=vs.140%29.aspx . That
is not being done, so not sure how it even works with VC9/VC11. First I
tried to declare UNICODE, but that's a bad idea - the whole app isn't
prepared for that. Thus, I've tried to remove the _setargv() call.

That worked - under VC14 argv seems to be set


******************************************************************

This Readme file was originally created on 22 July 2010. The dates in
the commit messages below, upto and including point 6, are relative to
this.  Some more notes to do with Apache Httpd and how Greenstone
compiles and installs it (including upon Installation of Greenstone) are
at the bottom.

* Apache Httpd 2, whose unmodified source code was
  originally being compiled up on Linux alone. The first
  greenstone-modified version was added to include windows makefiles
  to compile the Linux source code.

The httpd tar.gz file works with the files httpd.conf.in for linux and
windows-httpd.conf.in for windows.
http://trac.greenstone.org/browser/gsdl/trunk/runtime-src/packages/apache-httpd/windows-httpd.conf.in?rev=20171
Revision 20171, 17.6 KB (checked in by ak19, 12 months ago) explains:
"Windows httpd.conf.in file is not the same as the one for linux and
darwin (Mac), since one gets the Modules Already Loaded message on
Linux if the existing httpd.conf.in was interchanged with the Windows
one."


1. http://trac.greenstone.org/browser/gsdl/trunk/runtime-src/packages/apache-httpd/httpd-2.2.11-gs.tar.gz?rev=20169

Revision 20169, 7.9 MB (checked in by ak19, 12 months ago)

Adding the customised apache web server source folder: a linux source
release plus apache's official windows makefiles. Now it compiles up
on both OS.

    * Property svn:mime-type set to application/octet-stream


2. http://trac.greenstone.org/browser/gsdl/trunk/runtime-src/packages/apache-httpd/httpd-2.2.11-gs.tar.gz?rev=20349

Revision 20349, 7.9 MB (checked in by ak19, 11 months ago)

Dr Bainbridge fixed the configure.in (and generated the configure file
from it) so that it generates the libexpat.so.0 file it needs. This
way the apache web server won't look elsewhere for the so file and
perhaps find an incompatible version of it.

    * Property svn:mime-type set to application/octet-stream


3. http://trac.greenstone.org/browser/gsdl/trunk/runtime-src/packages/apache-httpd/httpd-2.2.11-gs.tar.gz?rev=20668

Revision 20668, 7.9 MB (checked in by davidb, 10 months ago)

better to include builtin libiconv support. Should prevent .so version
conflicts on Mac

    * Property svn:mime-type set to application/octet-stream


4. http://trac.greenstone.org/browser/gsdl/trunk/runtime-src/packages/apache-httpd/httpd-2.2.11-gs.tar.gz?rev=20850

Revision 20850, 7.7 MB (checked in by ak19, 9 months ago)

Teaches the apache web server being compiled up where the static
libiconv lib file, libiconv.a, is to be found (which greenstone would
have compiled up during the greenstone configure stage). The
with-iconv flag is set in runtime-src/packages/configure file to point
to the common-src/packages/iconv folder wherein the lib folder
contains the generated libiconv.a file. The apache server tar file is
updated as well: no longer does it add the with-iconv flag explicitly
since this is now already set at a higher up level and is passed down
to it.

    * Property svn:mime-type set to application/octet-stream


5. http://trac.greenstone.org/browser/gsdl/trunk/runtime-src/packages/apache-httpd/httpd-2.2.11-gs.tar.gz?rev=20892

Revision 20892, 7.7 MB (checked in by oranfry, 9 months ago)

the change I think will force apr not to use sendfile

    * Property svn:mime-type set to application/octet-stream


6. http://trac.greenstone.org/browser/gsdl/trunk/runtime-src/packages/apache-httpd/httpd-2.2.11-gs.tar.gz?rev=20893
(http://trac.greenstone.org/browser/main/trunk/greenstone2/runtime-src/packages/apache-httpd/httpd-2.2.11-gs.tar.gz)

Revision 20893, 7.9 MB (checked in by ak19, 9 months ago)

Dr Bainbridge updated srclib/apr/configure.in so that sendfile is set
to 0 for Darwin (Mac) to tell Darwin systems that we won't be working
with calls to sendfile, since Tiger OS does not have sendfile even
though we are compiling on Leopard which does.

    * Property svn:mime-type set to application/octet-stream



*****************************************************************
NOTES ON COMPILING AND INSTALLING APACHE HTTPD 2.2 FOR GREENSTONE
*****************************************************************

The Relocatable Apache web server:


A) RELEASE KIT needs to run:

1. ./configure --enable-apache-httpd
2. make
3. make install
4. make apache-for-dist


B) INSTALLER needs to:

1. Copy the compiled up apache-httpd folder and put it into its
   destination for installation:
GSDLHOME/apache-httpd.

X 2. Not necessary: 
cd into there and into the linux (=GSDLOS) folder in there:
	cd <GSDLHOME>/apache-httpd/linux

3. Run the script install-bindist.sh (in apache-httpd/<GSDLOS> folder)
   passing as argument: <GSDLHOME>/apache-httpd/linux

4. Now it should be good to go: can run the webserver after
   configuring the port (in linux/conf/httpd.conf) as follows
	./bin/apachectl start

- Change port in httpd.conf file
- run gs2-server.sh

