This patch is for the Cygwin platform. 

There are a couple of clean-ups and enhancements, especially for
configuring and building shared module DLLs using the
--enable-shared=<foobar> configure switch.

Installation now performs without any errors, even a libhttpd.ep fake
is installed for a clean "make install" run.

The manual page htdocs/manual/cygwin.html has been changed to reflect
the features for the configuration and building process of shared
module DLLs too.

Please commit changed to CVS, Jim, Martin?!


Here is what has been changed:

  * configure: added case for Cygwin to translate shared module
extensions from .so to .dll. Almost the same as for OS2.

  * htdocs/manual/cywin.html: added related changes to the configure
and build process for shared module DLLs.

  * src/Configure: cleaned up Cygwin case for OS specific variable
declaration. Removed no longer need $DLL_IMPORT_DEF and
$DLL_IMPORT_LIB variables.

  * src/Makefile.tmpl: removed no longer needed $DLL_IMPORT_LIB
variable.

  * src/main/http_main.c: added dllexport declaration for int REALMAIN
for SHARED_CORE support.

  * src/modules/standard/Makefile.Cygwin: added this new file to
refelct the extra rules needed to link the shared module DLLs. Very
similar to src/modules/standard/Makefile.OS2.

  * src/os/cygwin/os.h: added explicit dllimport and dllexport
declarations for API_VAR_EXPORT and API_EXPORT(type).



Stipe

[EMAIL PROTECTED]
-------------------------------------------------------------------
Wapme Systems AG

M�nsterstr. 248
40470 D�sseldorf

Tel: +49-211-74845-0
Fax: +49-211-74845-299

E-Mail: [EMAIL PROTECTED]
Internet: http://www.wapme-systems.de
-------------------------------------------------------------------
wapme.net - wherever you are
diff -urN apache-1.3/configure apache-1.3-cygwin/configure
--- apache-1.3/configure        Wed Aug 29 16:12:08 2001
+++ apache-1.3-cygwin/configure Tue Sep 25 14:42:25 2001
@@ -1537,6 +1537,10 @@
         echo $SEO "s%/mod_\\(.\\{1,8\\}\\).*\\.so%/\\1\\.dll%" >>$sedsubst
         echo $SEO "s%/\\(lib.*\\)\\.so$%/\\1.dll%" >>$sedsubst
         ;;
+    *cygwin* ) 
+        echo $SEO "s%/\\(mod_.*\\)\\.so$%/\\1.dll%" >>$sedsubst
+        echo $SEO "s%/\\(lib.*\\)\\.so$%/\\1.dll%" >>$sedsubst
+        ;;
 esac
 
 #   split sedsubst into chunks of 50 commands
diff -urN apache-1.3/htdocs/manual/cygwin.html 
apache-1.3-cygwin/htdocs/manual/cygwin.html
--- apache-1.3/htdocs/manual/cygwin.html        Wed Sep 26 00:48:28 2001
+++ apache-1.3-cygwin/htdocs/manual/cygwin.html Wed Sep 26 00:45:29 2001
@@ -38,7 +38,7 @@
    operating systems.  While it is considered release quality, it is slower
    and less thoroughly tested than the Unix ports.  The Cygwin alternative
    uses the well tested Unix code by using the Cygwin portability layer for
-   Unix emulation.  The Cygwin port may suffer from gaps in security or
+   POSIX.1 emulation.  The Cygwin port may suffer from gaps in security or
    reliability due to the interaction of the Cygwin compatibility layer with
    the native Windows API.</p>
 
@@ -188,6 +188,7 @@
 
 <ul>
 
+
 <li><strong>Static linked version</strong>
 <p>To build a static linked version of <code>httpd</code> including
    additional modules, use the following commands in the shell:</p>
@@ -199,6 +200,7 @@
 <p>This will produce the required extra libraries or object files for
    <i>module</i> and link everything to <code>src/httpd.exe</code>.</p>
 
+
 <li><strong>Shared core, DLL linked version ('one-for-all' version)</strong>
 <p>To build a DLL version of <code>httpd</code> including additional
    modules, use the following commands:</p>
@@ -223,11 +225,18 @@
 <pre>
   $ mv /usr/local/apache/libexec/libhttpd.dll /usr/local/apache/bin
 </pre>
+  The core DLL module <code>libhttpd.dll</code> is the <i>only</i> file that
+  should reside in <code>/usr/local/apache/bin</code> directory. All other shared DLL
+  modules <code>mod_foo.dll</code> should be located in 
+  <code>/usr/local/apache/libexec</code>.
+<p>
+
 
 <li><strong>Shared DLL modules linked version</strong>
 <p>This method is currently <strong>ONLY</strong> supported using
-   a patched version of <code>ld.exe</code>. Please see the
-   <a href="#req">requirements</a> section for where to get that version.
+   a patched version of <code>ld.exe</code> which support the 
+       <code>--auto-import</code> option. Please see the 
+       <a href="#req">requirements</a> section for where to get that version.
 
 <p>To build a dynamic loadable DLL version of <code>httpd</code> which can
    load DLL modules on the fly (at runtime), proceed as follows:</p>
@@ -241,46 +250,43 @@
        [--enable-module=<i>module</i>|--add-module=<i>/path/to/module</i>] \
        [--enable-shared=<i>module</i>]
   $ make
-  $ make install
 </pre>
-<p>Now the <code>make</code> process will break when trying to compile the
-  shared module defined using <code>--enable-shared</code>. You will have
-  to use a work-around, due to the fact that currently there is no
-  <code>src/libhttpd.dll</code> (required to link against by the
-  shared module build process).</p>
+<p>You will notice that there is a warning message shown which lets you
+       know that the shared core DLL library <code>src/libhttpd.dll</code>
+       is missing while trying to link the shared DLL modules 
+       <code>mod_foo.dll</code>.
+
+<p>Unfortunatly while Apache's build process the shared modules are linked
+       before the shared core import library <code>src/libhttpd.dll</code> has
+       been made. The shared modules depend on this import library, so they
+       can not link for the first time you run <code>make</code>.</p>
 
-<li>Create an empty file to satisfy <code>make</code> and
-  restart the <code>make</code> process again:
+<li>Re-run <code>make</code> to build the shared module DLLs and install the
+    whole package to the installation directory:
 <pre>
-  $ touch <i>/path/to/module.so</i>
   $ make
   $ make install
 </pre>
-<p>This will build the core dynamic library <code>libhttpd.dll</code> as
-  described in the previous scenario.</p>
+<p>All shared modules are placed into <code>libexec</code>, including the 
+       shared core DLL <code>libhttpd.dll</code>. When Apache's 
+<code>/bin/httpd</code> 
+       is started it has to dynamicly link <code>libhttpd.dll</code> while runtime. 
+       That is why you have to place the shared core DLL <code>libhttpd.dll</code> to 
+       the same direcotry where <code>httpd.exe</code> resides, i.e. 
+       <code>/usr/local/apache/bin</code>.</p>
 
-<li>Now we have to link the shared module against that library:
-<pre>
-  $ cd <i>/path/to/module</i>
-  $ gcc --shared -o <i>module</i>.dll <i>module</i>.lo <i>/path/to/libhttpd.dll</i>
-</pre>
-<p>The shared DLL module has to be placed in Apache's
-  <code>bin</code> directory, where <code>libhttpd.dll</code> also resides.</p>
 
 <li>Add configuration directives to <code>conf/httpd.conf</code> to load
 and activate shared DLL modules at runtime:
 <pre>
   # httpd.conf
   [...]
-  LoadModule foo_module   bin/mod_foo.dll
+  LoadModule foo_module   libexec/mod_foo.dll
   AddModule mod_foo.c
   [...]
 </pre>
 
 </ul>
 
-<p>The above steps have to be repeated for each shared DLL module you want
-   to build.</p>
 
 <li><strong>Using apxs to create shared DLL modules</strong>
 <p>To make the extending <code>httpd</code> with shared DLL modules
@@ -318,7 +324,7 @@
 <pre>
   $ apxs -c mod_foo.c -o mod_foo.dll
 </pre>
-   Place the resulting DLL in Apache's <code>bin</code> directory, so
+   Place the resulting DLL in Apache's <code>libexec</code> directory, so
    the <code>dlopen()</code> function within the compiled in <code>mod_so.c</code>
    module can find and load it at runtime.
 
diff -urN apache-1.3/src/Configure apache-1.3-cygwin/src/Configure
--- apache-1.3/src/Configure    Sun Jul 15 10:04:35 2001
+++ apache-1.3-cygwin/src/Configure     Wed Sep 26 00:56:20 2001
@@ -1388,16 +1388,18 @@
             ;;
        *-cygwin*)
            DEF_SHARED_CORE=yes
-           LDFLAGS_SHLIB="-g"
+           LDFLAGS_SHLIB="--export-all"
            LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
            SHLIB_SUFFIX_NAME=dll
+           SHMOD_SUFFIX_NAME=dll
            SHLIB_SUFFIX_DEPTH=0
-           DLL_IMPORT_LIB='lib$(TARGET).a'
-           DLL_IMPORT_DEF='lib$(TARGET).def'
-           LD_SHLIB='dllwrap --export-all --output-def $(DLL_IMPORT_DEF) --implib 
$(DLL_IMPORT_LIB) --driver-name $(CC)'
-           LD_SHCORE_LIBS='$(LIBS)'
+           LD_SHLIB='dllwrap'
+           LD_SHCORE_DEF=''
+           LD_SHCORE_LIBS="$LIBS"
            LIBS_SHLIB='$(EXTRA_LIBS)'
-           SHARED_CORE_EP=''
+           SHARED_CORE_EP='lib$(TARGET).ep'
+           SHCORE_IMPLIB='lib$(TARGET).dll'
+           OS_MODULE_INCLUDE='Makefile.Cygwin'
            ;;
        *)
            ##  ok, no known explict support for shared objects
@@ -1924,12 +1926,6 @@
     if [ "x$TCFLAGS_SHLIB" = "x" ]; then
        echo "CFLAGS_SHLIB=$CFLAGS_SHLIB -DSHARED_MODULE" >> Makefile.config
     fi
-    if [ "x$TDLL_IMPORT_DEF" = "x" ]; then
-       echo "DLL_IMPORT_DEF=$DLL_IMPORT_DEF" >> Makefile.config
-    fi
-    if [ "x$TDLL_IMPORT_LIB" = "x" ]; then
-       echo "DLL_IMPORT_LIB=$DLL_IMPORT_LIB" >> Makefile.config
-    fi
     if [ "x$TLD_SHLIB" = "x" ]; then
        echo "LD_SHLIB=$LD_SHLIB" >> Makefile.config
     fi
diff -urN apache-1.3/src/Makefile.tmpl apache-1.3-cygwin/src/Makefile.tmpl
--- apache-1.3/src/Makefile.tmpl        Mon Apr  2 09:22:05 2001
+++ apache-1.3-cygwin/src/Makefile.tmpl Wed Sep 26 00:54:12 2001
@@ -41,7 +41,7 @@
 target_shared: $(SHCORE_IMPLIB) $(SHARED_CORE_EP) lib$(TARGET).$(SHLIB_SUFFIX_NAME)
        $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) \
              -o $(TARGET) -DSHARED_CORE_BOOTSTRAP main/http_main.c \
-             ap/libap.a $(LIBS) $(SHCORE_IMPLIB) $(DLL_IMPORT_LIB)
+             ap/libap.a $(LIBS) $(SHCORE_IMPLIB)
 
 lib$(TARGET).ep: lib$(TARGET).$(SHLIB_SUFFIX_NAME)
        $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) \
diff -urN apache-1.3/src/main/http_main.c apache-1.3-cygwin/src/main/http_main.c
--- apache-1.3/src/main/http_main.c     Mon Sep 10 16:12:02 2001
+++ apache-1.3-cygwin/src/main/http_main.c      Tue Sep 25 15:43:07 2001
@@ -5137,6 +5137,15 @@
 extern char *optarg;
 extern int optind;
 
+/* Cygwin 1.x SHARED_CORE support needs REALMAIN to be declared as dllexport,
+ * so we can later while SHARED_CORE_BOOTSTRAP is compiled and linked see the 
+ * dllimport for it. -- Stipe Tolj <[EMAIL PROTECTED]>
+ */
+
+#if defined(CYGWIN)
+__declspec(dllexport)  
+#endif
+
 int REALMAIN(int argc, char *argv[])
 {
     int c;
@@ -7467,6 +7476,7 @@
 #if defined(CYGWIN)
 __declspec(dllimport) 
 #endif
+
 
 int ap_main(int argc, char *argv[]); /* Load time linked from libhttpd.dll */
 
diff -urN apache-1.3/src/modules/standard/Makefile.Cygwin 
apache-1.3-cygwin/src/modules/standard/Makefile.Cygwin
--- apache-1.3/src/modules/standard/Makefile.Cygwin     Thu Jan  1 00:00:00 1970
+++ apache-1.3-cygwin/src/modules/standard/Makefile.Cygwin      Wed Sep 26 00:14:31 
+2001
@@ -0,0 +1,50 @@
+#
+# Extra rule sets for making shared module DLLs for Cygwin 1.x
+# 
+# On Cygwin OS the user needs to run twice "make" if shared modules have 
+# been requested using the --enable-shared=<module> configure flag.
+# This is because when we pass the module mod_foo.c we have no import 
+# library, usually src/libhttpd.dll to link against in this case. So the
+# two "make" runs do the following:
+#
+#   1st run: builds all static modules and links everything to the 
+#            shared core DLL, which is also the import library for any
+#            further shared modules, including the apxs tool mechanism.
+#
+#   2nd run: builds *only* the shared module DLLs specified by the 
+#            --enable-shared configure switch and of course updates
+#            the buildmark.o and hence httpd's build date.
+#
+# Any suggestions in getting this done in one step are highly welcome.
+# Stipe Tolj <[EMAIL PROTECTED]>
+#
+
+# overwrite variables that are defined in previous makefile
+LD_SHLIB=$(CC)
+LDFLAGS_SHLIB=--shared
+
+define shared_dll
+       $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $*.dll $(<:%.c=%.o) $(LIBS_SHLIB) \
+        $(SRCDIR)/$(SHCORE_IMPLIB) $(LIBS1)
+endef
+
+%.lo : %.c
+       $(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $< && mv $*.o $*.lo
+
+%.dll : %.lo
+       @if [ -f "$(SRCDIR)/$(SHCORE_IMPLIB)" ]; then \
+        echo $(shared_dll); \
+               $(shared_dll); \
+       else \
+           echo "+--------------------------------------------------------+"; \
+               echo "| There is no shared core 'libhttpd.dll' available!      |"; \
+               echo "|                                                        |"; \
+               echo "| This is obviously your first 'make' run with configure |"; \
+               echo "| flag SHARED_CORE enabled and shared modules.           |"; \
+               echo "|                                                        |"; \
+               echo "| You will have to re-run 'make' after this run builds   |"; \
+               echo "| the required shared import library!                    |"; \
+           echo "+--------------------------------------------------------+"; \
+        sleep 10; \
+       fi;
+
diff -urN apache-1.3/src/os/cygwin/os.h apache-1.3-cygwin/src/os/cygwin/os.h
--- apache-1.3/src/os/cygwin/os.h       Mon Apr  2 18:56:39 2001
+++ apache-1.3-cygwin/src/os/cygwin/os.h        Tue Sep 25 22:20:58 2001
@@ -68,7 +68,14 @@
 
 #ifndef API_EXPORT
 #ifdef SHARED_CORE
-# define API_EXPORT(type)    __declspec(dllexport) type
+# ifdef SHARED_MODULE
+#  define API_VAR_EXPORT      __declspec(dllimport)
+#  define API_EXPORT(type)    __declspec(dllimport) type
+#  define MODULE_VAR_EXPORT   __declspec(dllexport)
+# else
+#  define API_VAR_EXPORT      __declspec(dllexport)
+#  define API_EXPORT(type)    __declspec(dllexport) type
+# endif /* def SHARED_MODULE */
 #endif /* def SHARED_CORE */ 
 #endif /* ndef API_EXPORT */
 

Reply via email to