Hi there,

[please reply directly, I'm currently not on the list]

this is yet another kind request to integrate my patch for supporting
the Cygwin 1.x platform, which is a POSIX emulation layer for Win32
systems (http://www.cygwin.com) to the official stable tree.

I'm providing the port of Apache for the cygwin platform since version
1.2.6. It's covered by the PR#2936. Unfortunatly the cygwin license
was (and still is) GPLed and hence binaries couldn't be distrbuted.

Cygwin *changed* their license by adding a very important clause to
GPL, see http://www.cygwin.com/licensing.html, which states:

[...]
In accordance with section 10 of the GPL, Cygnus permits programs
whose sources are distributed under a license that complies with the
Open Source definition to be linked with libcygwin.a without
libcygwin.a itself causing the resulting program to be covered by the
GNU GPL.

This means that you can port an Open Source(tm) application to cygwin,
and distribute that executable as if it didn't include a copy of
libcygwin.a linked into it. Note that this does not apply to the
cygwin DLL itself. If you distribute a (possibly modified) version of
the DLL you must adhere to the terms of the GPL, i.e., you must
provide sources for the cygwin DLL.

See http://www.opensource.org/osd.html for the precise Open Source
Definition referenced above.
[...]

Since Apache *is* considered to be Open Source in the above
definition, there seems to be *no* reason why the sources of the port
may be now integrated to the stable 1.3.x tree and compiled binaries
may be provided.

The main issue about supporting the Cygwin 1.x platform is, that users
may compile and run Apache -- with serveral supported modules, like
php, gzip, jserv, etc.in combination with MySQL or PostgreSQL -- on a
Win32 box as if it would be a BSD or UNIX based system. And they can
even use gcc for compiling and building. Since 1.3.9 we have been
providing the patch even with DLL support for the Win32 platforms,
which makes large installation with a lot of modules more scalable.

Have a look (and do a "nmap -O" if you like :)) to
http://kannel.dev.wapme.net/ where we run a small dedicated NT4
Workstation box running for distributing our Cygwin 1.x port of Kannel
1.0.x:

Server Version: Apache/1.3.17 (Cygwin) mod_gzip/1.3.17.2a PHP/4.0.4pl1
AuthMySQL/2.20 DAV/1.0.2 mod_ssl/2.8.0 OpenSSL/0.9.6
Server Built: Feb 28 2001 01:39:39

Ok, now about the patch itself, here is what we changed in the current
1.3.19 tree:

    * src/Configure: added cygwin specific env variable settings for
OS detection and stuff for building the DLL. Changed the "+ enabling
generation of Apache core as DSO" to reflect the DLL posibility if
building under cygwin. Added DLL_IMPORT_DEF and DLL_IMPORT_LIB flags
for Makefile.config creation.

    * src/Makefile.tmpl: added $(DLL_IMPORT_LIB) for the target
"target_shared".

    * src/helpers/GuessOS: added OS detection of the uname output for
cygwin.

    * src/include/ap_config.h: added OS specific #define block for a
couple of defines.

    * src/main/http_main.c: excluded inclusion of #include
<netinet/tcp.h>, it's not provided on cygwin. Added shared core loader
statement for ap_main() for cygwin.

    * src/os/cygwin/: directory contains cygwin specific things.
Mainly the files in here are reduced versions of the src/os/unix
directory.

    * src/os/cygwin/Makefile.tmpl: the Makefile template

    * src/os/cygwin/os-inline.c: inline definitions, almost nothing
:))

    * src/os/cygwin/os.c: nothing special here too

    * src/os/cygwin/os.h: added DLL based API_EXPORT definition and
unique PLATFORM identifier for cygwin.

    * src/support/logresolve.c: added definition of extern int h_errno
for cygwin, which breaks compilation if not set.


That's it. The patch against current stable release 1.3.19 is attached
to this mail. Hope you like it.

About 2.0:

We had successfully adopted the port to 2.0a4 which definitly *worked*
at least for the prefork MPM. Unfortunatly the same changes applied to
2.0a9 are causing segmenation faults and we are still focusing on
resolving the problem.

There may be also a change to use the pthreads MPM wihtin cygwin,
because our Kannel port uses those libraries and DLLs too and runs
very stable.


Regards,
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.19/src/Configure apache_1.3.19-cygwin/src/Configure
--- apache_1.3.19/src/Configure Mon Feb 19 13:32:54 2001
+++ apache_1.3.19-cygwin/src/Configure  Thu Mar 15 17:43:18 2001
@@ -834,6 +834,13 @@
        DEF_WANTHSREGEX=yes
        LIBS="$LIBS"
        ;;
+    *-cygwin*)
+       OS='Cygwin'
+       OSDIR="os/cygwin"
+       CFLAGS="$CFLAGS -DCYGWIN"
+       DEF_WANTHSREGEX=yes
+       LIBS="$LIBS -lcrypt"
+       ;;
     *) # default: Catch systems we don't know about
        OS='Unknown and unsupported OS'
        echo Sorry, but we cannot grok \"$PLAT\"
@@ -1377,6 +1384,19 @@
            LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
            LDFLAGS_SHLIB_EXPORT=""
             ;;
+       *-cygwin*)
+           DEF_SHARED_CORE=yes
+           LDFLAGS_SHLIB="-g"
+           LDFLAGS_MOD_SHLIB=$LDFLAGS_SHLIB
+           SHLIB_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)'
+           LIBS_SHLIB='$(EXTRA_LIBS)'
+           SHARED_CORE_EP=''
+           ;;
        *)
            ##  ok, no known explict support for shared objects
            ##  on this platform, but we give not up immediately.
@@ -1854,7 +1874,11 @@
        RULE_SHARED_CORE=$DEF_SHARED_CORE
     fi
     if [ "x$RULE_SHARED_CORE" = "xyes" ]; then
-       echo " + enabling generation of Apache core as DSO"
+       DSO_STRING="DSO"
+       if [ "$OS" = "Cygwin" ]; then
+           DSO_STRING="DLL"
+       fi
+       echo " + enabling generation of Apache core as $DSO_STRING"
        #    shuffle compiler flags from shlib variant to standard
        CFLAGS="$CFLAGS $CFLAGS_SHLIB"
        CFLAGS_SHLIB=""
@@ -1897,6 +1921,12 @@
 if [ "x$using_shlib" = "x1" ] ; then
     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
diff -urN apache_1.3.19/src/Makefile.tmpl apache_1.3.19-cygwin/src/Makefile.tmpl
--- apache_1.3.19/src/Makefile.tmpl     Thu Jun 22 23:22:18 2000
+++ apache_1.3.19-cygwin/src/Makefile.tmpl      Thu Mar 15 17:29:22 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)
+             ap/libap.a $(LIBS) $(SHCORE_IMPLIB) $(DLL_IMPORT_LIB)
 
 lib$(TARGET).ep: lib$(TARGET).$(SHLIB_SUFFIX_NAME)
        $(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_SHLIB_EXPORT) \
diff -urN apache_1.3.19/src/helpers/GuessOS apache_1.3.19-cygwin/src/helpers/GuessOS
--- apache_1.3.19/src/helpers/GuessOS   Fri Feb 16 14:27:18 2001
+++ apache_1.3.19-cygwin/src/helpers/GuessOS    Wed Mar 14 09:30:17 2001
@@ -309,6 +309,9 @@
     OS/390:*)
         echo "${MACHINE}-IBM-OS390-${RELEASE}-${VERSION}"; exit 0;
         ;;
+    CYGWIN*:*:*:*)
+       echo "${MACHINE}-whatever-cygwin"; exit 0
+       ;;
 esac
 
 #
diff -urN apache_1.3.19/src/include/ap_config.h 
apache_1.3.19-cygwin/src/include/ap_config.h
--- apache_1.3.19/src/include/ap_config.h       Mon Feb 19 23:56:20 2001
+++ apache_1.3.19-cygwin/src/include/ap_config.h        Wed Mar 14 09:30:17 2001
@@ -1000,6 +1000,11 @@
 #define NET_SIZE_T size_t
 #define NEED_HASHBANG_EMUL
 
+#elif defined(CYGWIN)               /* Cygwin 1.x POSIX layer for Win32 */
+#define JMP_BUF jmp_buf
+#define NO_KILLPG
+#define USE_LONGJMP
+
 #else
 /* Unknown system - Edit these to match */
 #ifdef BSD
diff -urN apache_1.3.19/src/main/http_main.c apache_1.3.19-cygwin/src/main/http_main.c
--- apache_1.3.19/src/main/http_main.c  Thu Feb 22 16:07:16 2001
+++ apache_1.3.19-cygwin/src/main/http_main.c   Wed Mar 14 09:30:17 2001
@@ -117,7 +117,7 @@
 #endif
 #ifdef WIN32
 #include "../os/win32/getopt.h"
-#elif !defined(BEOS) && !defined(TPF) && !defined(NETWARE) && !defined(OS390)
+#elif !defined(BEOS) && !defined(TPF) && !defined(NETWARE) && !defined(OS390) && 
+!defined(CYGWIN)
 #include <netinet/tcp.h>
 #endif
 #ifdef HAVE_BSTRING_H
@@ -7164,8 +7164,12 @@
 #endif /* ndef SHARED_CORE_TIESTATIC */
 #else  /* ndef SHARED_CORE_BOOTSTRAP */
 
-#ifdef OS2
-/* Shared core loader for OS/2 */
+#if defined(OS2) || defined(CYGWIN)
+/* Shared core loader for OS/2 and Cygwin */
+
+#if defined(CYGWIN)
+__declspec(dllimport) 
+#endif
 
 int ap_main(int argc, char *argv[]); /* Load time linked from libhttpd.dll */
 
diff -urN apache_1.3.19/src/os/cygwin/Makefile.tmpl 
apache_1.3.19-cygwin/src/os/cygwin/Makefile.tmpl
--- apache_1.3.19/src/os/cygwin/Makefile.tmpl   Thu Jan  1 00:00:00 1970
+++ apache_1.3.19-cygwin/src/os/cygwin/Makefile.tmpl    Wed Mar 14 09:30:17 2001
@@ -0,0 +1,46 @@
+CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
+LIBS=$(EXTRA_LIBS) $(LIBS1)
+INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
+LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
+
+OBJS=  os.o os-inline.o
+
+LIB=   libos.a
+
+all:   $(LIB)
+
+$(LIB): $(OBJS)
+       rm -f $@
+       ar cr $@ $(OBJS)
+       $(RANLIB) $@
+
+.c.o:
+       $(CC) -c $(INCLUDES) $(CFLAGS) $<
+
+clean:
+       rm -f $(OBJS) $(LIB)
+
+distclean: clean
+       -rm -f Makefile
+
+# We really don't expect end users to use this rule.  It works only with
+# gcc, and rebuilds Makefile.tmpl.  You have to re-run Configure after
+# using it.
+depend:
+       cp Makefile.tmpl Makefile.tmpl.bak \
+           && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
+           && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
+           && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
+                  -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
+               > Makefile.tmpl \
+           && rm Makefile.new
+
+$(OBJS): Makefile
+
+# DO NOT REMOVE
+os-inline.o: os-inline.c $(INCDIR)/ap_config.h \
+ $(INCDIR)/ap_mmn.h $(INCDIR)/ap_config_auto.h \
+ $(OSDIR)/os.h $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h
+os.o: os.c $(INCDIR)/ap_config.h $(INCDIR)/ap_mmn.h \
+ $(INCDIR)/ap_config_auto.h $(OSDIR)/os.h \
+ $(INCDIR)/ap_ctype.h $(INCDIR)/hsregex.h os.h
diff -urN apache_1.3.19/src/os/cygwin/os-inline.c 
apache_1.3.19-cygwin/src/os/cygwin/os-inline.c
--- apache_1.3.19/src/os/cygwin/os-inline.c     Thu Jan  1 00:00:00 1970
+++ apache_1.3.19-cygwin/src/os/cygwin/os-inline.c      Wed Mar 14 09:30:17 2001
@@ -0,0 +1,31 @@
+/*
+ * This file contains functions which can be inlined if the compiler
+ * has an "inline" modifier. Because of this, this file is both a
+ * header file and a compilable module.
+ *
+ * Only inlineable functions should be defined in here. They must all
+ * include the INLINE modifier. 
+ *
+ * If the compiler supports inline, this file will be #included as a
+ * header file from os.h to create all the inline function
+ * definitions. INLINE will be defined to whatever is required on
+ * function definitions to make them inline declarations.
+ *
+ * If the compiler does not support inline, this file will be compiled
+ * as a normal C file into libos.a (along with os.c). In this case
+ * INLINE will _not_ be set so we can use this to test if we are
+ * compiling this source file.  
+ */
+
+#ifndef INLINE
+#define INLINE
+
+/* Anything required only when compiling */
+#include "ap_config.h"
+
+#endif
+
+INLINE int ap_os_is_path_absolute(const char *file)
+{
+  return file[0] == '/';
+}
diff -urN apache_1.3.19/src/os/cygwin/os.c apache_1.3.19-cygwin/src/os/cygwin/os.c
--- apache_1.3.19/src/os/cygwin/os.c    Thu Jan  1 00:00:00 1970
+++ apache_1.3.19-cygwin/src/os/cygwin/os.c     Wed Mar 14 09:30:17 2001
@@ -0,0 +1,46 @@
+/*
+ * This file will include OS specific functions which are not inlineable.
+ * Any inlineable functions should be defined in os-inline.c instead.
+ */
+
+#include "ap_config.h"
+#include "os.h"
+
+
+/* some linkers complain unless there's at least one function in each
+ * .o file... and extra prototype is for gcc -Wmissing-prototypes
+ */
+extern void ap_is_not_here(void);
+void ap_is_not_here(void) {}
+
+/*
+ *  Abstraction layer for loading
+ *  Apache modules under run-time via 
+ *  dynamic shared object (DSO) mechanism
+ */
+
+void ap_os_dso_init(void)
+{
+}
+
+void *ap_os_dso_load(const char *path)
+{
+    return dlopen(path, RTLD_NOW | RTLD_GLOBAL);
+}
+
+void ap_os_dso_unload(void *handle)
+{
+    dlclose(handle);
+
+    return;
+}
+
+void *ap_os_dso_sym(void *handle, const char *symname)
+{
+    return dlsym(handle, symname);
+}
+
+const char *ap_os_dso_error(void)
+{
+    return dlerror();
+}
diff -urN apache_1.3.19/src/os/cygwin/os.h apache_1.3.19-cygwin/src/os/cygwin/os.h
--- apache_1.3.19/src/os/cygwin/os.h    Thu Jan  1 00:00:00 1970
+++ apache_1.3.19-cygwin/src/os/cygwin/os.h     Thu Mar 15 17:36:45 2001
@@ -0,0 +1,157 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * Portions of this software are based upon public domain software
+ * originally written at the National Center for Supercomputing Applications,
+ * University of Illinois, Urbana-Champaign.
+ */
+
+#ifndef APACHE_OS_H
+#define APACHE_OS_H
+
+#include "ap_config.h"
+
+/*
+ * Define the API_EXPORT declaration for creating a dynamic
+ * loadable library (DLL) version of Apache on Cygwin 1.x platforms.
+ */
+
+#ifndef API_EXPORT
+#ifdef SHARED_CORE
+# define API_EXPORT(type)    __declspec(dllexport) type
+#else /* Not SHARED_CORE */
+# define API_EXPORT(type)    __declspec(dllimport) type
+#endif /* def SHARED_CORE */ 
+#endif /* ndef API_EXPORT */
+
+/*
+ * We don't consider the Cygwin 1.x support neither an Unix nor
+ * a Win32 platform. Basicly it's something between both, so that
+ * is why we introduce our own PLATFORM define.
+ */
+#ifndef PLATFORM
+#define PLATFORM "Cygwin"
+#endif
+
+/*
+ * This file in included in all Apache source code. It contains definitions
+ * of facilities available on _this_ operating system (HAVE_* macros),
+ * and prototypes of OS specific functions defined in os.c or os-inline.c
+ */
+
+#if !defined(INLINE) && defined(USE_GNU_INLINE)
+/* Compiler supports inline, so include the inlineable functions as
+ * part of the header
+ */
+#define INLINE extern ap_inline
+
+INLINE int ap_os_is_path_absolute(const char *file);
+
+/*
+ * The inline things are the same as in the os/unix branch, so include
+ * that one rather than our own copy that would be the same.
+ */
+#include "os-inline.c"
+
+#else
+
+/* Compiler does not support inline, so prototype the inlineable functions
+ * as normal
+ */
+extern int ap_os_is_path_absolute(const char *file);
+#endif
+
+/* Other ap_os_ routines not used by this platform */
+
+#define ap_os_is_filename_valid(f)          (1)
+#define ap_os_kill(pid, sig)                kill(pid, sig)
+
+/*
+ *  Abstraction layer for loading
+ *  Apache modules under run-time via 
+ *  dynamic shared object (DSO) mechanism
+ */
+
+#ifdef HAVE_DL_H
+#include <dl.h>
+#endif
+
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#else
+void *dlopen(const char *, int);
+int dlclose(void *);
+void *dlsym(void *, const char *);
+const char *dlerror(void);
+#endif
+
+/* probably on an older system that doesn't support RTLD_NOW or RTLD_LAZY.
+ * The below define is a lie since we are really doing RTLD_LAZY since the
+ * system doesn't support RTLD_NOW.
+ */
+#ifndef RTLD_NOW
+#define RTLD_NOW 1
+#endif
+
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+
+#define     ap_os_dso_handle_t  void *
+void        ap_os_dso_init(void);
+void *      ap_os_dso_load(const char *);
+void        ap_os_dso_unload(void *);
+void *      ap_os_dso_sym(void *, const char *);
+const char *ap_os_dso_error(void);
+
+#endif /* !APACHE_OS_H */
diff -urN apache_1.3.19/src/support/logresolve.c 
apache_1.3.19-cygwin/src/support/logresolve.c
--- apache_1.3.19/src/support/logresolve.c      Tue May  9 17:58:34 2000
+++ apache_1.3.19-cygwin/src/support/logresolve.c       Wed Mar 14 09:30:18 2001
@@ -101,7 +101,7 @@
  * statistics - obvious
  */
 
-#ifndef h_errno
+#if !defined(h_errno) && !defined(CYGWIN)
 extern int h_errno; /* some machines don't have this in their headers */
 #endif
 

Reply via email to