# Makefile for Windows NT and Windows 95/98/2000

# Targets are:
#   _apacher   - build Apache in Release mode
#   _apached   - build Apache in Debug mode
#   installr   - build and install a Release build
#   installd   - build and install a Debug build
#   clean      - remove (most) generated files
#   _cleanr    - remove (most) files generated by a Release build
#   _cleand    - remove (most) files generated by a Debug build
#   _browse    - build the browse info file
#
# The following install defaults may be customized;
#
#   Option      Default
#   INSTDIR     \Apache2
#   PORT        80
#   SERVERNAME  localhost
#
# For example;
#
#   nmake /f Makefile.win PORT=80 INSTDIR="d:\Program Files\Apache" installr
#
# Be aware that certain awk's will not accept backslahed names,
# so the server root should be given in forward slashes (quoted),
# preferably with the drive designation!

default: _apacher

!IF ("$(CTARGET)" == "") && EXIST("Apache.sln")
CTARGET=/build
!ENDIF

!IF !EXIST("srclib\apr") || !EXIST("srclib\apr-util") || !EXIST("srclib\apr-iconv")
!MESSAGE Please check out or download and unpack the Apache Portability Runtime
!MESSAGE sources (apr, apr-iconv and apr-util) into your $(INSTDIR)\srclib dir.
!MESSAGE Apache cannot build without these libraries!
!MESSAGE 
!ERROR Need $(INSTDIR)\srclib\  apr, apr-iconv and apr-util
!ENDIF

# Note; _tryssl: is only used by the msvc developer studio environment to 'fix up'
#	the build, since conditional dependencies aren't supported.
#
!IF EXIST("srclib\openssl")
!IF "$(LONG)" == "Debug"
SSLBIN=out32dll.dbg
!ELSE
SSLBIN=out32dll
!ENDIF

_tryssl:
!IF EXIST("modules\ssl\mod_ssl.mak")
	cd modules\ssl
	$(MAKE) $(MAKEOPT) -f mod_ssl.mak CFG="mod_ssl - Win32 $(LONG)" RECURSE=0 .\$(LONG)\mod_ssl.so
	cd ..\..
	cd support
	$(MAKE) $(MAKEOPT) -f abs.mak CFG="abs - Win32 $(LONG)" RECURSE=0 .\$(LONG)\abs.exe
	cd ..
!ELSEIF EXIST("Apache.sln")
	devenv Apache.sln /useenv $(CTARGET) $(LONG) /project mod_ssl
	devenv Apache.sln /useenv $(CTARGET) $(LONG) /project abs
!ELSE
	@msdev Apache.dsw /USEENV /MAKE \
		"mod_ssl - Win32 $(LONG)" \
		"abs - Win32 $(LONG)" /NORECURSE $(CTARGET)
!ENDIF

!ELSE
#     NOT EXIST("srclib\openssl")

_tryssl:
	@echo -----
	@echo mod_ssl and ab/ssl will not build unless openssl is installed
	@echo in srclib\openssl.  They must be precompiled using the 
	@echo ms/ntdll.mak file, see srclib\openssl\INSTALL.W32.  The most
	@echo recent version confirmed to build with mod_ssl and ab is 0.9.6h.
	@echo Available from http://www.openssl.org/
!ENDIF

!IF EXIST("srclib\zlib")

_tryzlib:
!IF EXIST("modules\filters\mod_deflate.mak")
	cd modules\filters
	$(MAKE) $(MAKEOPT) -f mod_deflate.mak CFG="mod_deflate - Win32 $(LONG)" RECURSE=0 .\$(LONG)\mod_deflate.so
	cd ..\..
!ELSEIF EXIST("Apache.sln")
	devenv Apache.sln /useenv $(CTARGET) $(LONG) /project mod_deflate
!ELSE
	@msdev Apache.dsw /USEENV /MAKE \
		"mod_deflate - Win32 $(LONG)" /NORECURSE $(CTARGET)
!ENDIF

!ELSE
#     NOT EXIST("srclib\zlib")

_tryzlib:
	@echo -----
	@echo mod_deflate will not build unless zlib is installed in srclib\zlib.  
	@echo zlib does not need to be built, we compile the sources directly.
	@echo Available from http://www.gzip.org/zlib/

!ENDIF

!IF "$(INSTDIR)" == ""
INSTDIR=\Apache2
!ENDIF
!IF "$(SERVERNAME)" == ""
SERVERNAME=localhost
!ENDIF
!IF "$(PORT)" == ""
PORT=80
!ENDIF 

!IF "$(LONG)" == ""
!MESSAGE
!MESSAGE INSTDIR    = $(INSTDIR)
!MESSAGE SERVERNAME = $(SERVERNAME)
!MESSAGE PORT       = $(PORT)
!MESSAGE
!MESSAGE To change these options use 'nmake /f Makefile.win [option=value]'
!MESSAGE Example: nmake /f Makefile.win PORT=8080
!MESSAGE
!MESSAGE
!ENDIF

!IFNDEF MAKEOPT
# Only default the behavior if MAKEOPT= is omitted
!IF "$(MAKE)" == "NMAKE"
# Microsoft NMake options
MAKEOPT=-nologo
!ELSEIF "($MAKE)" == "make"
# Borland make options?  Not really supported (yet)
MAKEOPT=-s -N
!ENDIF
!ENDIF

_dummy:

_browse:
	cd Browse
	  bscmake.exe -nologo -Iu -o Apache.bsc *.sbr
	cd ..

_apacher: 
	@$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=R LONG=Release _build

_apached: 
	@$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=D LONG=Debug   _build

installr: 
	@$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=R LONG=Release _build _install

installd: 
	@$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=D LONG=Debug   _build _install

clean:	_cleanr _cleand
	-if exist Browse\. rd /s Browse < << > nul
y
<<

!IF EXIST("Apache.mak")

_cleanr:
	$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=R LONG=Release CTARGET=CLEAN _build

_cleand:  
	$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=D LONG=Debug   CTARGET=CLEAN _build

_build:
	echo Building Win32 $(LONG) targets ($(SHORT) suffixes)
	cd srclib\apr
	 $(MAKE) $(MAKEOPT) -f apr.mak             CFG="apr - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f libapr.mak          CFG="libapr - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd srclib\apr-iconv
	 $(MAKE) $(MAKEOPT) -f apriconv.mak  CFG="apriconv - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f libapriconv.mak  CFG="libapriconv - Win32 $(LONG)" RECURSE=0 $(CTARGET)
!IF "$(CTARGET)" == "CLEAN"
	$(MAKE) $(MAKEOPT) /f build\modules.mk.win clean \
		BUILD_MODE=$(LONG) BIND_MODE=shared API_SOURCE=.
!ELSE
	cd ccs
	$(MAKE) /nologo /f Makefile.win all \
		BUILD_MODE=$(LONG) BIND_MODE=shared
	cd ..\ces
	$(MAKE) /nologo /f Makefile.win all \
		BUILD_MODE=$(LONG) BIND_MODE=shared
	cd ..
!ENDIF
	cd ..\..
	cd srclib\apr-util\uri
	 $(MAKE) $(MAKEOPT) -f gen_uri_delims.mak  CFG="gen_uri_delims - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..\..
	cd srclib\apr-util\xml\expat\lib
	 $(MAKE) $(MAKEOPT) -f xml.mak             CFG="xml - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..\..
	 $(MAKE) $(MAKEOPT) -f aprutil.mak         CFG="aprutil - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f libaprutil.mak      CFG="libaprutil - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd srclib\pcre
	 $(MAKE) $(MAKEOPT) -f dftables.mak        CFG="dftables - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f pcre.mak            CFG="pcre - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f pcreposix.mak       CFG="pcreposix - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd server
	 $(MAKE) $(MAKEOPT) -f gen_test_char.mak   CFG="gen_test_char - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..
	 $(MAKE) $(MAKEOPT) -f libhttpd.mak        CFG="libhttpd - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f Apache.mak          CFG="Apache - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd modules\aaa
	 $(MAKE) $(MAKEOPT) -f mod_access.mak      CFG="mod_access - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_auth.mak        CFG="mod_auth - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_auth_anon.mak   CFG="mod_auth_anon - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_auth_dbm.mak    CFG="mod_auth_dbm - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_auth_digest.mak CFG="mod_auth_digest - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd modules\arch\win32
	 $(MAKE) $(MAKEOPT) -f mod_isapi.mak       CFG="mod_isapi - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..\..
	cd modules\cache
	 $(MAKE) $(MAKEOPT) -f mod_file_cache.mak  CFG="mod_file_cache - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd modules\dav\main
	 $(MAKE) $(MAKEOPT) -f mod_dav.mak         CFG="mod_dav - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..\..
	cd modules\dav\fs
	 $(MAKE) $(MAKEOPT) -f mod_dav_fs.mak      CFG="mod_dav_fs - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..\..
	cd modules\experimental
	 $(MAKE) $(MAKEOPT) -f mod_cache.mak       CFG="mod_cache - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_charset_lite.mak CFG="mod_charset_lite - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_mem_cache.mak   CFG="mod_mem_cache - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_disk_cache.mak  CFG="mod_disk_cache - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f util_ldap.mak       CFG="util_ldap - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_auth_ldap.mak   CFG="mod_auth_ldap - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd modules\filters
!IF EXIST("srclib\zlib")
	 $(MAKE) $(MAKEOPT) -f mod_deflate.mak     CFG="mod_deflate - Win32 $(LONG)" RECURSE=0 $(CTARGET)
!ENDIF
	 $(MAKE) $(MAKEOPT) -f mod_ext_filter.mak  CFG="mod_ext_filter - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_include.mak     CFG="mod_include - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd modules\generators
	 $(MAKE) $(MAKEOPT) -f mod_asis.mak        CFG="mod_asis - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_autoindex.mak   CFG="mod_autoindex - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_cgi.mak         CFG="mod_cgi - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_info.mak        CFG="mod_info - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_status.mak      CFG="mod_status - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd modules\http
	 $(MAKE) $(MAKEOPT) -f mod_mime.mak        CFG="mod_mime - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd modules\loggers
	 $(MAKE) $(MAKEOPT) -f mod_log_config.mak  CFG="mod_log_config - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_logio.mak       CFG="mod_logio - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd modules\mappers
	 $(MAKE) $(MAKEOPT) -f mod_actions.mak     CFG="mod_actions - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_alias.mak       CFG="mod_alias - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_dir.mak         CFG="mod_dir - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_imap.mak        CFG="mod_imap - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_negotiation.mak CFG="mod_negotiation - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_rewrite.mak     CFG="mod_rewrite - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_speling.mak     CFG="mod_speling - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_userdir.mak     CFG="mod_userdir - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_vhost_alias.mak CFG="mod_vhost_alias - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd modules\metadata
	 $(MAKE) $(MAKEOPT) -f mod_cern_meta.mak   CFG="mod_cern_meta - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_env.mak         CFG="mod_env - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_expires.mak     CFG="mod_expires - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_headers.mak     CFG="mod_headers - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_mime_magic.mak  CFG="mod_mime_magic - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_setenvif.mak    CFG="mod_setenvif - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_unique_id.mak   CFG="mod_unique_id - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_usertrack.mak   CFG="mod_usertrack - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
	cd modules\proxy
	 $(MAKE) $(MAKEOPT) -f mod_proxy.mak       CFG="mod_proxy - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_proxy_connect.mak CFG="mod_proxy_connect - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_proxy_ftp.mak   CFG="mod_proxy_ftp - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f mod_proxy_http.mak  CFG="mod_proxy_http - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..
!IF EXIST("srclib\openssl")
	cd modules\ssl
	 $(MAKE) $(MAKEOPT) -f mod_ssl.mak         CFG="mod_ssl - Win32 $(LONG)" RECURSE=0 $(CTARGET) .\$(LONG)\mod_ssl.so
	cd ..\..
	cd support
	 $(MAKE) $(MAKEOPT) -f abs.mak             CFG="abs - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..
!ENDIF
	cd support
	 $(MAKE) $(MAKEOPT) -f ab.mak              CFG="ab - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f htdbm.mak           CFG="htdbm - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f htdigest.mak        CFG="htdigest - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f htpasswd.mak        CFG="htpasswd - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f logresolve.mak      CFG="logresolve - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f rotatelogs.mak      CFG="rotatelogs - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..
	cd support\win32
	 $(MAKE) $(MAKEOPT) -f ApacheMonitor.mak   CFG="ApacheMonitor - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	 $(MAKE) $(MAKEOPT) -f wintty.mak          CFG="wintty - Win32 $(LONG)" RECURSE=0 $(CTARGET)
	cd ..\..

!ELSEIF EXIST("Apache.sln")

_cleanr:  
	$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=R LONG=Release CTARGET="/clean" _build

_cleand:  
	$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=D LONG=Debug   CTARGET="/clean" _build

_build:
	echo Building Win32 $(LONG) targets ($(SHORT) suffixes)
	devenv Apache.sln /useenv $(CTARGET) $(LONG) /project BuildBin
!IF EXIST("srclib\openssl")
	devenv Apache.sln /useenv $(CTARGET) $(LONG) /project mod_ssl
	devenv Apache.sln /useenv $(CTARGET) $(LONG) /project abs
!ENDIF
!IF EXIST("srclib\zlib")
	devenv Apache.sln /useenv $(CTARGET) $(LONG) /project mod_deflate
!ENDIF

!ELSE

_cleanr:  
	@$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=R LONG=Release CTARGET="/CLEAN" _build

_cleand:  
	@$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=D LONG=Debug   CTARGET="/CLEAN" _build

_build:
	@echo Building Win32 $(LONG) targets ($(SHORT) suffixes)
	@msdev Apache.dsw /USEENV /MAKE \
		"BuildBin - Win32 $(LONG)" $(CTARGET)
!IF "$(CTARGET)" == "/CLEAN"
	@cd srclib\apr-iconv
	@$(MAKE) $(MAKEOPT) /f build\modules.mk.win clean \
		BUILD_MODE=$(LONG) BIND_MODE=shared API_SOURCE=.
	@cd ..\..
!ENDIF
!IF EXIST("srclib\openssl")
	@msdev Apache.dsw /USEENV /MAKE \
		"mod_ssl - Win32 $(LONG)" \
		"abs - Win32 $(LONG)" /NORECURSE $(CTARGET)
!ENDIF
!IF EXIST("srclib\zlib")
	@msdev Apache.dsw /USEENV /MAKE \
		"mod_deflate - Win32 $(LONG)" /NORECURSE $(CTARGET)
!ENDIF

!ENDIF


_copybin:
	copy $(LONG)\Apache.$(src_exe) 				"$(inst_exe)" <.y
	copy $(LONG)\libhttpd.$(src_dll) 			"$(inst_dll)" <.y
	copy srclib\apr\$(LONG)\libapr.$(src_dll) 		"$(inst_dll)" <.y
	copy srclib\apr-iconv\$(LONG)\libapriconv.$(src_dll) 	"$(inst_dll)" <.y
	copy srclib\apr-util\$(LONG)\libaprutil.$(src_dll) 	"$(inst_dll)" <.y
	copy modules\aaa\$(LONG)\mod_access.$(src_so) 		"$(inst_so)" <.y
	copy modules\aaa\$(LONG)\mod_auth.$(src_so) 		"$(inst_so)" <.y
	copy modules\aaa\$(LONG)\mod_auth_anon.$(src_so) 	"$(inst_so)" <.y
	copy modules\aaa\$(LONG)\mod_auth_dbm.$(src_so) 	"$(inst_so)" <.y
	copy modules\aaa\$(LONG)\mod_auth_digest.$(src_so) 	"$(inst_so)" <.y
	copy modules\arch\win32\$(LONG)\mod_isapi.$(src_so) 	"$(inst_so)" <.y
	copy modules\cache\$(LONG)\mod_file_cache.$(src_so) 	"$(inst_so)" <.y
	copy modules\dav\fs\$(LONG)\mod_dav_fs.$(src_so) 	"$(inst_so)" <.y
	copy modules\dav\main\$(LONG)\mod_dav.$(src_so)		"$(inst_so)" <.y
	copy modules\experimental\$(LONG)\mod_cache.$(src_so)		"$(inst_so)" <.y
	copy modules\experimental\$(LONG)\mod_charset_lite.$(src_so)	"$(inst_so)" <.y
	copy modules\experimental\$(LONG)\mod_mem_cache.$(src_so)	"$(inst_so)" <.y
	copy modules\experimental\$(LONG)\mod_disk_cache.$(src_so)	"$(inst_so)" <.y
	copy modules\experimental\$(LONG)\util_ldap.$(src_so)		"$(inst_so)" <.y
	copy modules\experimental\$(LONG)\mod_auth_ldap.$(src_so)	"$(inst_so)" <.y
!IF EXIST("srclib\zlib")
	copy modules\filters\$(LONG)\mod_deflate.$(src_so) 	"$(inst_so)" <.y
!ENDIF
	copy modules\filters\$(LONG)\mod_ext_filter.$(src_so) 	"$(inst_so)" <.y
	copy modules\filters\$(LONG)\mod_include.$(src_so) 	"$(inst_so)" <.y
	copy modules\generators\$(LONG)\mod_asis.$(src_so) 	"$(inst_so)" <.y
	copy modules\generators\$(LONG)\mod_autoindex.$(src_so) "$(inst_so)" <.y
	copy modules\generators\$(LONG)\mod_cgi.$(src_so) 	"$(inst_so)" <.y
	copy modules\generators\$(LONG)\mod_info.$(src_so) 	"$(inst_so)" <.y
	copy modules\generators\$(LONG)\mod_status.$(src_so) 	"$(inst_so)" <.y
	copy modules\http\$(LONG)\mod_mime.$(src_so) 		"$(inst_so)" <.y
	copy modules\loggers\$(LONG)\mod_log_config.$(src_so) 	"$(inst_so)" <.y
	copy modules\loggers\$(LONG)\mod_logio.$(src_so) 	"$(inst_so)" <.y
	copy modules\mappers\$(LONG)\mod_actions.$(src_so) 	"$(inst_so)" <.y
	copy modules\mappers\$(LONG)\mod_alias.$(src_so) 	"$(inst_so)" <.y
	copy modules\mappers\$(LONG)\mod_dir.$(src_so) 		"$(inst_so)" <.y
	copy modules\mappers\$(LONG)\mod_imap.$(src_so) 	"$(inst_so)" <.y
	copy modules\mappers\$(LONG)\mod_negotiation.$(src_so) 	"$(inst_so)" <.y
	copy modules\mappers\$(LONG)\mod_rewrite.$(src_so) 	"$(inst_so)" <.y
	copy modules\mappers\$(LONG)\mod_speling.$(src_so) 	"$(inst_so)" <.y
	copy modules\mappers\$(LONG)\mod_userdir.$(src_so) 	"$(inst_so)" <.y
	copy modules\mappers\$(LONG)\mod_vhost_alias.$(src_so) 	"$(inst_so)" <.y
	copy modules\metadata\$(LONG)\mod_cern_meta.$(src_so) 	"$(inst_so)" <.y
	copy modules\metadata\$(LONG)\mod_env.$(src_so) 	"$(inst_so)" <.y
	copy modules\metadata\$(LONG)\mod_expires.$(src_so) 	"$(inst_so)" <.y
	copy modules\metadata\$(LONG)\mod_headers.$(src_so) 	"$(inst_so)" <.y
	copy modules\metadata\$(LONG)\mod_mime_magic.$(src_so) 	"$(inst_so)" <.y
	copy modules\metadata\$(LONG)\mod_setenvif.$(src_so) 	"$(inst_so)" <.y
	copy modules\metadata\$(LONG)\mod_unique_id.$(src_so) 	"$(inst_so)" <.y
	copy modules\metadata\$(LONG)\mod_usertrack.$(src_so) 	"$(inst_so)" <.y
	copy modules\proxy\$(LONG)\mod_proxy.$(src_so) 		"$(inst_so)" <.y
	copy modules\proxy\$(LONG)\mod_proxy_connect.$(src_so) 	"$(inst_so)" <.y
	copy modules\proxy\$(LONG)\mod_proxy_ftp.$(src_so) 	"$(inst_so)" <.y
	copy modules\proxy\$(LONG)\mod_proxy_http.$(src_so) 	"$(inst_so)" <.y
!IF EXIST("srclib\openssl")
	copy modules\ssl\$(LONG)\mod_ssl.$(src_so) 			"$(inst_so)" <.y
	$(quiet)copy srclib\openssl\$(SSLBIN)\openssl.$(src_exe) 	"$(inst_exe)" <.y
	$(quiet)copy srclib\openssl\$(SSLBIN)\libeay32.$(src_dll) 	"$(inst_dll)" <.y
	$(quiet)copy srclib\openssl\$(SSLBIN)\ssleay32.$(src_dll) 	"$(inst_dll)" <.y
	copy support\$(LONG)\abs.$(src_exe) 			"$(inst_exe)\ab.$(src_exe)" <.y
!ELSE
	copy support\$(LONG)\ab.$(src_exe) 			"$(inst_exe)" <.y
!ENDIF
	copy support\$(LONG)\htdbm.$(src_exe) 			"$(inst_exe)" <.y
	copy support\$(LONG)\htdigest.$(src_exe) 		"$(inst_exe)" <.y
	copy support\$(LONG)\htpasswd.$(src_exe) 		"$(inst_exe)" <.y
	copy support\$(LONG)\logresolve.$(src_exe) 		"$(inst_exe)" <.y
	copy support\$(LONG)\rotatelogs.$(src_exe) 		"$(inst_exe)" <.y
	copy support\win32\$(LONG)\ApacheMonitor.$(src_exe) 	"$(inst_exe)" <.y
	copy support\win32\$(LONG)\wintty.$(src_exe) 		"$(inst_exe)" <.y

# First we create the tree and populate the README so that 
# whatever happens, all licensing has already propagated.  
# Then repeatedly invoke the _copybin build to copy the
# real binaries, then pdb symbols, anf finally dbg syms.
# Then hit docs of various sorts, then includes and libs,
# and finally do the .conf magic.
#
_install:
	echo Y >.y
	echo A >.A
	-mkdir "$(INSTDIR)"
	-mkdir "$(INSTDIR)\bin"
	-mkdir "$(INSTDIR)\bin\iconv"
	-mkdir "$(INSTDIR)\cgi-bin"
	-mkdir "$(INSTDIR)\conf"
	-mkdir "$(INSTDIR)\error"
	-mkdir "$(INSTDIR)\htdocs"
	-mkdir "$(INSTDIR)\manual"
	-mkdir "$(INSTDIR)\icons"
	-mkdir "$(INSTDIR)\include"
	-mkdir "$(INSTDIR)\lib"
	-mkdir "$(INSTDIR)\logs"
	-mkdir "$(INSTDIR)\modules"
	-mkdir "$(INSTDIR)\proxy"
 	-mkdir "$(INSTDIR)\symbols"
 	-mkdir "$(INSTDIR)\symbols\exe"
 	-mkdir "$(INSTDIR)\symbols\dll"
 	-mkdir "$(INSTDIR)\symbols\so"
	copy ABOUT_APACHE 	"$(INSTDIR)\ABOUT_APACHE.txt" <.y
	copy CHANGES 		"$(INSTDIR)\CHANGES.txt" <.y
	copy INSTALL 		"$(INSTDIR)\INSTALL.txt" <.y
	copy LICENSE 		"$(INSTDIR)\LICENSE.txt" <.y
	copy README 		"$(INSTDIR)\README.txt" <.y
!IF EXIST("srclib\openssl")
	type << >> "$(INSTDIR)\README.txt"

  This binary distribution includes cryptographic software written by
  Eric Young (eay@cryptsoft.com), software written by Tim Hudson 
  (tjh@cryptsoft.com), and software developed by the OpenSSL Project 
  for use in the OpenSSL Toolkit <http://www.openssl.org/>.
<<
	-awk -f <<script.awk < "srclib\openssl\LICENSE" >> "$(INSTDIR)\LICENSE.txt"
BEGIN {
    print "";
    print "For the libeay32.dll, ssleay32.dll and certtool.exe components:";
    print "";
    while ( getline > 0 ) {
	print $$0;
   }
}
<<
	copy << + srclib\openssl\NEWS "$(INSTDIR)\OPENSSL-NEWS.txt" <.y

 Apache HTTP Server 2.0 Limited OpenSSL Distribution

 This binary distribution includes the minimal components of OpenSSL required
 to support mod_ssl for Apache HTTP Server version 2.0 (details are listed 
 in OPENSSL-README.txt.)  For the complete list of CHANGES to this and later 
 versions of OpenSSL, please refer to the definative source,
 <http://www.openssl.org/news/changelog.html>, or see the CHANGES file in the
 full binary or source distribution package from <http://www.openssl.org/>.

 These OpenSSL binaries were built for distribution from the U.S. without 
 support for the patented encryption methods IDEA, MDC-2 or RC5.

--------------------------------------------------------------------------------
<<
	copy << + srclib\openssl\README "$(INSTDIR)\OPENSSL-README.txt" <.y

 Apache HTTP Server 2.0 Limited OpenSSL Distribution

 This binary installation of OpenSSL is a limited distribution of the documents
 OPENSSL-LICENSE.txt, OPENSSL-NEWS.txt and OPENSSL-README.txt, and the binaries

   libeay32.dll
   ssleay32.dll
   openssl.exe

 These are the minimal libraries and tools required to use mod_ssl as 
 distributed with Apache HTTP Server version 2.0.  No library link files, 
 headers or sources are distributed with this binary distribution.  Please 
 refer to the <http://www.openssl.org/> site for complete source or binary 
 distributions.

 These OpenSSL binaries were built for distribution from the U.S. without 
 support for the patented encryption methods IDEA, MDC-2 or RC5.

 The Apache HTTP Project only supports the binary distribution of these files
 and development of the mod_ssl module.  We cannot provide support assistance
 for using or configuring the OpenSSL package or these modules.  Please refer
 all installation and configuration questions to the appropriate forum,
 such as the user supported lists, <http://httpd.apache.org/userslist.html> 
 the Apache HTTP Server user's list or <http://www.openssl.org/support/> the
 OpenSSL support page.

--------------------------------------------------------------------------------
<<
!ENDIF
!IF EXIST("srclib\zlib")
	type << >> "$(INSTDIR)\README.txt"

  This binary distribution of mod_deflate.so includes zlib compression code
  <http://www.gzip.org/zlib/> written by Jean-loup Gailly (jloup@gzip.org)
  and Mark Adler (madler@alumni.caltech.edu) .
<<
	-awk -f <<script.awk < "srclib\zlib\README" >> "$(INSTDIR)\LICENSE.txt"
BEGIN {
    while ( getline > 0 ) {
	if ( $$0 ~ /Copyright notice:/ ) {
	    print "";
	    print "For the mod_deflate zlib compression component:";
	    while ( getline > 0 && $$0 !~ /^[^ ]/ ) {
		print $$0;
            }
            exit 0;
        }
    }
    exit 1;
}
<<
!ENDIF
	$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=$(SHORT) LONG=$(LONG) \
		_copybin src_exe=exe src_dll=dll src_so=so             \
		inst_exe="$(INSTDIR)\bin"                              \
		inst_dll="$(INSTDIR)\bin"                              \
		inst_so="$(INSTDIR)\modules"
	$(MAKE) $(MAKEOPT) -f Makefile.win SHORT=$(SHORT) LONG=$(LONG) \
		_copybin src_exe=pdb src_dll=pdb src_so=pdb quiet="-"  \
		inst_exe="$(INSTDIR)\bin"                              \
		inst_dll="$(INSTDIR)\bin"                              \
		inst_so="$(INSTDIR)\modules"
	cd srclib\apr-iconv
	$(MAKE) $(MAKEOPT) -f build\modules.mk.win install \
		BUILD_MODE=$(LONG) BIND_MODE=shared API_SOURCE=. \
		INSTALL_DIR="$(INSTDIR)\bin\iconv"
	cd ..\..
	copy docs\cgi-examples\printenv "$(INSTDIR)\cgi-bin\printenv.pl" <.y
	-awk -f <<script.awk "docs/cgi-examples/printenv" > "$(INSTDIR)\cgi-bin\printenv.pl"
    BEGIN { 
	if ( "perl -e \"print $$^X;\"" | getline perlroot ) {
	    gsub( /\\/, "/", perlroot );
	    print "#!" perlroot;
	}
    }
    {
	if ( $$0 !~ /^#!/ ) {
	    print $$0;
	}
    }
<<
	xcopy docs\error 	"$(INSTDIR)\error" /s /d < .a
	xcopy docs\docroot 	"$(INSTDIR)\htdocs" /d < .a
	xcopy docs\icons 	"$(INSTDIR)\icons" /s /d < .a
	xcopy docs\manual 	"$(INSTDIR)\manual" /s /d < .a
	xcopy srclib\pcre\pcre*.h 			"$(INSTDIR)\include" /d < .a
	xcopy srclib\apr-util\xml\expat\lib\expat.h 	"$(INSTDIR)\include" /d < .a
	xcopy srclib\apr\include\*.h 			"$(INSTDIR)\include" /d < .a
	xcopy srclib\apr-util\include\*.h 		"$(INSTDIR)\include" /d < .a
	xcopy include\*.h 				"$(INSTDIR)\include" /d < .a
	copy srclib\apr\Lib$(SHORT)\apr.lib 		"$(INSTDIR)\lib" <.y
	copy srclib\apr\Lib$(SHORT)\apr_src.pdb 	"$(INSTDIR)\lib" <.y
	copy srclib\apr-util\Lib$(SHORT)\aprutil.lib 	"$(INSTDIR)\lib" <.y
	copy srclib\apr-util\Lib$(SHORT)\aprutil_src.pdb "$(INSTDIR)\lib" <.y
	copy srclib\pcre\Lib$(SHORT)\pcre.lib 		"$(INSTDIR)\lib" <.y
	copy srclib\pcre\Lib$(SHORT)\pcre_src.pdb 	"$(INSTDIR)\lib" <.y
	copy srclib\pcre\Lib$(SHORT)\pcreposix.lib 	"$(INSTDIR)\lib" <.y
	copy srclib\pcre\Lib$(SHORT)\pcreposix_src.pdb 	"$(INSTDIR)\lib" <.y
	copy srclib\apr-util\xml\expat\lib\Lib$(SHORT)\xml.lib "$(INSTDIR)\lib" <.y
	copy srclib\apr-util\xml\expat\lib\Lib$(SHORT)\xml_src.pdb "$(INSTDIR)\lib" <.y
	copy srclib\apr\$(LONG)\libapr.lib 		"$(INSTDIR)\lib" <.y
	copy srclib\apr\$(LONG)\libapr.exp 		"$(INSTDIR)\lib" <.y
	copy srclib\apr-iconv\$(LONG)\libapriconv.lib 	"$(INSTDIR)\lib" <.y
	copy srclib\apr-iconv\$(LONG)\libapriconv.exp 	"$(INSTDIR)\lib" <.y
	copy srclib\apr-util\$(LONG)\libaprutil.lib 	"$(INSTDIR)\lib" <.y
	copy srclib\apr-util\$(LONG)\libaprutil.exp 	"$(INSTDIR)\lib" <.y
	copy $(LONG)\libhttpd.exp 			"$(INSTDIR)\lib" <.y
	copy $(LONG)\libhttpd.lib 			"$(INSTDIR)\lib" <.y
	copy modules\dav\main\$(LONG)\mod_dav.exp 	"$(INSTDIR)\lib" <.y
	copy modules\dav\main\$(LONG)\mod_dav.lib 	"$(INSTDIR)\lib" <.y
	copy docs\conf\magic "$(INSTDIR)\conf\magic.default" <.y
	if not exist "$(INSTDIR)\conf\magic" \
	    copy "$(INSTDIR)\conf\magic.default" "$(INSTDIR)\conf\magic"
	copy docs\conf\mime.types "$(INSTDIR)\conf\mime.types.default" <.y
	if not exist "$(INSTDIR)\conf\mime.types" \
	    copy "$(INSTDIR)\conf\mime.types.default" "$(INSTDIR)\conf\mime.types"
	copy docs\conf\httpd-win.conf "$(INSTDIR)\conf\httpd.default.conf" <.y
	-awk -f <<script.awk "docs/conf/httpd-win.conf" "$(INSTDIR)" > "$(INSTDIR)\conf\httpd.default.conf"
    BEGIN { 
	serverroot = ARGV[2];
	delete ARGV[2];
	gsub( /\\/, "/", serverroot );
	"cd" | getline root;
	gsub( /^\//, substr( root, 1, 2 ) "/", serverroot );
    }
    {
	gsub( /@@ServerRoot@@/, serverroot );
	gsub( /@@ServerName@@/, "$(SERVERNAME)" );
	gsub( /@@Port@@/, "$(PORT)" );
	print $$0;
    }
<<
	if not exist "$(INSTDIR)\conf\httpd.conf" \
	    copy "$(INSTDIR)\conf\httpd.default.conf" "$(INSTDIR)\conf\httpd.conf"
	copy docs\conf\ssl-std.conf "$(INSTDIR)\conf\ssl.default.conf" <.y
	-awk -f <<script.awk "docs/conf/ssl-std.conf" "$(INSTDIR)" > "$(INSTDIR)\conf\ssl.default.conf"
    BEGIN { 
	serverroot = ARGV[2];
	delete ARGV[2];
	gsub( /\\/, "/", serverroot );
	"cd" | getline root;
	gsub( /^\//, substr( root, 1, 2 ) "/", serverroot );
    }
    {
	gsub( /@@ServerRoot@@/, serverroot );
	print $$0;
    }
<<
	if not exist "$(INSTDIR)\conf\ssl.conf" \
	    copy "$(INSTDIR)\conf\ssl.default.conf" "$(INSTDIR)\conf\ssl.conf"
	-awk -f <<script.awk "support/dbmmanage.in" >"$(INSTDIR)\bin\dbmmanage.pl"
    { if ( $$0 ~ /^BEGIN \{ @AnyDBM_File::/ ) {
	  sub( /ISA = qw\(.*\)/, "ISA = qw(SDBM_File)" ); 
      }
      if ( $$0 !~ /^#!@perlbin@/ )
	  print $$0;
    }
<<
	del .y
	del .a
