apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Mark Vandenberg <jay...@gmail.com>
Subject [patch 02/17] Windows library dependencies
Date Sat, 15 Apr 2006 01:41:20 GMT
Windows symbols may a suffix of @<arg count>.

A new macro AX_CHECK_DLL_FUNC looks for a @ sign in the function name; when
present it will verify a symbol exists with the correct argument count.
Otherwise, AX_CHECK_DLL_FUNC falls back to emulating AC_CHECK_LIB.

Enables native threads, locking, DSO loading and shared memory. 

Index: build/apr_win32.m4
===================================================================
--- /dev/null
+++ build/apr_win32.m4
@@ -0,0 +1,33 @@
+
+dnl if $2 contains '@dd', links against mingw symbols
+dnl otherwise calls AC_CHECK_LIB
+AC_DEFUN([AX_CHECK_DLL_FUNC],[
+m4_define($1_function_name,m4_substr($2,0,m4_index($2,[@])))
+m4_define($1_function_arglength,m4_substr($2,m4_incr(m4_index($2,[@]))))
+m4_define($1_[function_name]_arglength,m4_substr($2,m4_incr(m4_index($2,[@]))))
+dnl m4_define(ax_check_dll_id,$1_m4_defn($1_function_name))
+
+AC_CACHE_CHECK([for $2 in $1],[ac_cv_lib_$1_]$1_function_name,[
+
+ac_func_search_save_LIBS=$LIBS
+LIBS="$LIBS -l$1"
+
+AC_TRY_LINK([
+#pragma pack(1)
+struct x {
+]m4_for([byte_id], 1, m4_defn([$1_function_name_arglength]), 1,[[ char c]]byte_id;
+)[};
+__stdcall ]$1_function_name[(]struct x[);],[
+struct x s = {0};
+]$1_function_name[(s)],
+[ac_cv_lib_$1_]$1_function_name[=yes],[ac_cv_lib_$1_]$1_function_name[=no])
+LIBS=$ac_func_search_save_LIBS
+])dnl AC_CACHE_CHECK
+
+AS_IF([test $ac_cv_lib_$1_]$1_function_name[ = yes],
+      [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1),,Enable if this library
is available)
+  LIBS="-l$1 $LIBS"
+])],
+    [$4])dnl
+])
+
Index: configure.in
===================================================================
--- configure.in.orig
+++ configure.in
@@ -14,6 +14,7 @@ dnl 
 dnl Include our own M4 macros along with those for libtool
 dnl 
 sinclude(build/apr_common.m4)
+sinclude(build/apr_win32.m4)
 sinclude(build/apr_network.m4)
 sinclude(build/apr_threads.m4)
 sinclude(build/apr_hints.m4)
@@ -319,6 +320,7 @@ AC_ARG_ENABLE(pool-debug,
     fi
   ])
 
+dnl Electric Fence malloc checker.
 if test "$host" = "i586-pc-beos"; then
   AC_ARG_ENABLE(malloc-debug,[  --enable-malloc-debug   Switch on malloc_debug for BeOS],
     APR_REMOVEFROM(CFLAGS, -O2)
@@ -347,6 +349,9 @@ case "$host:$CC" in
 	APR_SETVAR(CC,mwcc)
 	APR_SETVAR(AR,ar)
 	;;
+    *-mingw*:gcc )
+       APR_ADDTO(LDFLAGS,[-Wl,--enable-auto-import,--subsystem,console])
+       ;;
 esac
 
 dnl Check the depend program we can use
@@ -404,6 +409,12 @@ case $host in
        OSDIR="as400"
        eolstr="\\n"
        ;;
+   *mingw*)
+       OSDIR="win32"
+       enable_threads="system_threads"
+       eolstr="\\n"
+       OBJECTS_PLATFORM='$(OBJECTS_win32)'
+       ;;
    *cygwin*)
        OSDIR="unix"
        APR_ADDTO(CPPFLAGS,-DCYGWIN)
@@ -520,12 +531,25 @@ dnl Note: Autoconf will always append LI
 dnl It should check for LIBS being empty and set LIBS equal to the new value 
 dnl without the extra " " in that case, but they didn't do that.  So, we
 dnl end up LIBS="-lm -lcrypt -lnsl  -ldl" which is an annoyance.
-AC_SEARCH_LIBS(gethostbyname, nsl)
-AC_SEARCH_LIBS(gethostname, nsl)
-AC_SEARCH_LIBS(socket, socket)
-AC_SEARCH_LIBS(crypt, crypt ufc)
-AC_CHECK_LIB(truerand, main)
-AC_SEARCH_LIBS(modf, m)
+case $host in
+   *mingw*)
+      dnl APR_ADDTO(LIBS,[-lmsvcrt --lshell32 -ladvapi32 -lws2_32])
+
+      AC_CHECK_LIB(msvcrt,getpid)
+      AX_CHECK_DLL_FUNC(kernel32,SetErrorMode@4)
+      AX_CHECK_DLL_FUNC(advapi32,GetSecurityInfo@32)
+      AX_CHECK_DLL_FUNC(ws2_32,gethostbyname@4)
+      AX_CHECK_DLL_FUNC(shell32,CommandLineToArgvW@8)
+      ;;
+   *)
+      AC_SEARCH_LIBS(gethostbyname, nsl)
+      AC_SEARCH_LIBS(gethostname, nsl)
+      AC_SEARCH_LIBS(socket, socket)
+      AC_SEARCH_LIBS(crypt, crypt ufc)
+      AC_CHECK_LIB(truerand, main)
+      AC_SEARCH_LIBS(modf, m)
+       ;;
+esac
 
 dnl ----------------------------- Checking for Threads
 echo "${nl}Checking for Threads..."
@@ -692,9 +716,16 @@ case $host in
 #endif";;
 esac
 
-AC_CHECK_HEADERS([sys/types.h sys/mman.h sys/ipc.h sys/mutex.h sys/shm.h sys/file.h kernel/OS.h
os2.h])
+AC_CHECK_HEADERS([sys/types.h sys/mman.h sys/ipc.h sys/mutex.h sys/shm.h sys/file.h kernel/OS.h
os2.h windows.h])
 AC_CHECK_FUNCS([mmap munmap shm_open shm_unlink shmget shmat shmdt shmctl \
                 create_area])
+case $host in
+  *mingw*)
+    AX_CHECK_DLL_FUNC(kernel32,[CreateFileMappingA@24],
+		 [ac_cv_func_CreateFileMapping=$ac_cv_lib_kernel32_CreateFileMappingA])
+    ;;
+esac
+
 APR_CHECK_DEFINE(MAP_ANON, sys/mman.h)
 APR_CHECK_FILE(/dev/zero)
 
@@ -754,6 +785,10 @@ APR_IFALLYES(header:kernel/OS.h func:cre
              [havebeosshm="1"
               APR_DECIDE(USE_SHMEM_BEOS_ANON,
                          [BeOS areas])])
+APR_IFALLYES(header:windows.h func:CreateFileMapping,
+             [havewin32shm="1"
+              APR_DECIDE(USE_SHMEM_WIN32_ANON,
+                         [Windows CreateFileMapping()])])
 case $host in
     *linux* ) 
         # Linux has problems with MM_SHMT_MMANON even though it reports
@@ -800,6 +835,7 @@ havemmapshm="0"
 haveshmget="0"
 havebeosarea="0"
 haveos2shm="0"
+havewin32shm="0"
 APR_BEGIN_DECISION([namebased memory allocation method])
 APR_IFALLYES(header:sys/mman.h func:mmap func:munmap,
              [havemmaptmp="1"
@@ -820,6 +856,9 @@ APR_IFALLYES(header:kernel/OS.h func:cre
 APR_IFALLYES(header:os2.h,
              [haveos2shm="1"
               APR_DECIDE(USE_SHMEM_OS2, [OS/2 DosAllocSharedMem()])])
+APR_IFALLYES(header:windows.h,
+             [havewin32shm="1"
+              APR_DECIDE(USE_SHMEM_WIN32, [Windows shared memory])])
 case $host in
     *linux* ) 
         # Linux has problems with MM_SHMT_MMANON even though it reports
@@ -840,6 +879,7 @@ usemmapshm="0"
 useshmget="0"
 usebeosarea="0"
 useos2shm="0"
+usewin32shm="0"
 
 case $ac_decision in
     USE_SHMEM_MMAP_TMP )
@@ -857,10 +897,13 @@ case $ac_decision in
     USE_SHMEM_OS2 )
         useos2shm="1"
         ;;
+    USE_SHMEM_WIN32 )
+        usewin32shm="1"
+        ;;
 esac
 
 # Do we have any shared memory support?
-if test "$usemmaptmp$usemmapshm$usemmapzero$useshmget$usemmapanon$usebeosarea$useos2shm"
= "0000000"; then
+if test "$usemmaptmp$usemmapshm$usemmapzero$useshmget$usemmapanon$usebeosarea$useos2shm$usewin32shm"
= "00000000"; then
   sharedmem="0"
 else
   sharedmem="1"
@@ -871,11 +914,13 @@ AC_SUBST(usemmapshm)
 AC_SUBST(useshmget)
 AC_SUBST(usebeosarea)
 AC_SUBST(useos2shm)
+AC_SUBST(usewin32shm)
 AC_SUBST(havemmaptmp)
 AC_SUBST(havemmapshm)
 AC_SUBST(haveshmget)
 AC_SUBST(havebeosarea)
 AC_SUBST(haveos2shm)
+AC_SUBST(havewin32shm)
 AC_SUBST(sharedmem)
 
 dnl ----------------------------- Checks for Any required Functions
@@ -1448,7 +1493,7 @@ if test "$dsotype" = "any"; then
     # Everything else:
     if test "$dsotype" = "any"; then
         case $host in
-        *os390|*-os2*|*os400|*-aix*) dsotype=other ;;
+        *os390|*-os2*|*os400|*-aix*|*mingw*) dsotype=other ;;
         esac
     fi
 fi
@@ -1644,6 +1689,11 @@ APR_IFALLYES(header:OS.h func:create_sem
 if test "x$apr_lock_method" != "x"; then
     APR_DECISION_FORCE($apr_lock_method)
 fi
+case "$host" in
+    *mingw* )
+        APR_DECISION_FORCE(win32)
+        ;;
+esac
 APR_END_DECISION
 AC_DEFINE_UNQUOTED($ac_decision)
 

--

Mime
View raw message