From 4b8ca0cba45b88803f99b9d91d2a8c7ec7f9f46d Mon Sep 17 00:00:00 2001
From: rpj <rpj>
Date: Fri, 1 Apr 2005 09:13:32 +0000
Subject: ''

---
 ChangeLog         | 12 +++++++++---
 GNUmakefile       | 10 ++++++++++
 Makefile          |  9 +++++++++
 README            | 16 ++++++++++++++++
 tests/ChangeLog   |  6 ++++++
 tests/GNUmakefile | 15 ++++++++++++++-
 tests/Makefile    | 12 ++++++++++++
 tests/self1.c     |  7 +++++++
 8 files changed, 83 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4102ff6..6469ef0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-04-01  Ross Johnson  <ross at callisto.canberra.edu.au>
+
+	* GNUmakefile: Add target to build libpthreadGC1.a as a static link
+	library.
+	* Makefile: Likewise for pthreadGC1.lib.
+
 2005-04-01  Kevin Lussier <Kevin at codegreennetworks.com>
 
 	* sem_timedwait.c (sem_timedwait): Increase size of temp variables to
@@ -14,12 +20,12 @@
 
 2005-03-16  Ross Johnson  <ross at callisto.canberra.edu.au>^M
 
-        * pthread_setcancelstate.c: Undo the last change.
+	* pthread_setcancelstate.c: Undo the last change.
 
 2005-03-16  Ross Johnson  <ross at callisto.canberra.edu.au>^M
 
-        * pthread_setcancelstate.c: Don't check for an async cancel event
-        if the library is using alertable async cancel..
+	* pthread_setcancelstate.c: Don't check for an async cancel event
+	if the library is using alertable async cancel..
 
 2005-03-14  Ross Johnson  <ross at callisto.canberra.edu.au>
 
diff --git a/GNUmakefile b/GNUmakefile
index 9e6be70..00eeb8e 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -427,6 +427,7 @@ GCE_INLINED_STAMP = pthreadGCE$(DLL_VER).stamp
 GC_DLL 	= pthreadGC$(DLL_VER).dll
 GC_LIB	= libpthreadGC$(DLL_VER).a
 GC_INLINED_STAMP = pthreadGC$(DLL_VER).stamp
+GC_STATIC_STAMP = libpthreadGC$(DLL_VER).stamp
 
 PTHREAD_DEF	= pthread.def
 
@@ -436,6 +437,7 @@ help:
 	@ echo "make clean GC            (to build the GNU C dll with C cleanup code)"
 	@ echo "make clean GCE-inlined   (to build the GNU C inlined dll with C++ exception handling)"
 	@ echo "make clean GC-inlined    (to build the GNU C inlined dll with C cleanup code)"
+	@ echo "make clean GC-static     (to build the GNU C inlined static lib with C cleanup code)"
 
 all:
 	@ $(MAKE) clean GCE
@@ -453,6 +455,9 @@ GC-inlined:
 GCE-inlined:
 		$(MAKE) CC=g++ XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GCE_INLINED_STAMP)
 
+GC-static:
+		$(MAKE) CC=gcc XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_STATIC_STAMP)
+
 tests:
 	@ cd tests
 	@ $(MAKE) auto
@@ -493,6 +498,11 @@ $(GCE_INLINED_STAMP): $(DLL_INLINED_OBJS)
 	dlltool -k --dllname $(GCE_DLL) --output-lib $(GCE_LIB) --def $(PTHREAD_DEF)
 	echo touched > $(GCE_INLINED_STAMP)
 
+$(GC_STATIC_STAMP): $(DLL_INLINED_OBJS)
+	$(RM) $(GC_LIB)
+	$(AR) -rv $(GC_LIB) $(DLL_INLINED_OBJS)
+	echo touched > $(GC_STATIC_STAMP)
+
 clean:
 	-$(RM) *~
 	-$(RM) *.i
diff --git a/Makefile b/Makefile
index 3827782..cc30244 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,7 @@ LIBDEST	= $(DEVROOT)\DLL
 
 DLLS	= pthreadVCE$(DLL_VER).dll pthreadVSE$(DLL_VER).dll pthreadVC$(DLL_VER).dll
 INLINED_STAMPS	= pthreadVCE$(DLL_VER).stamp pthreadVSE$(DLL_VER).stamp pthreadVC$(DLL_VER).stamp
+STATIC_STAMPS	= pthreadVCE$(DLL_VER).static pthreadVSE$(DLL_VER).static pthreadVC$(DLL_VER).static
 
 OPTIM	= /O2 /Ob2
 #OPTIM	=
@@ -368,6 +369,7 @@ help:
 	@ echo nmake clean VCE-inlined   (to build the MSVC inlined dll with C++ exception handling)
 	@ echo nmake clean VSE-inlined   (to build the MSVC inlined dll with structured exception handling)
 	@ echo nmake clean VC-inlined    (to build the MSVC inlined dll with C cleanup code)
+	@ echo nmake clean VC-static     (to build the MSVC static lib with C cleanup code)
 
 all:
 	@ nmake clean VCE-inlined
@@ -396,6 +398,9 @@ VSE-inlined:
 VC-inlined:
 	@ nmake /nologo EHFLAGS="$(OPTIM) $(VCFLAGS) /DPTW32_BUILD_INLINED" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).stamp
 
+VC-static:
+	@ nmake /nologo EHFLAGS="$(OPTIM) $(VCFLAGS) /DPTW32_BUILD_INLINED /DPTW32_STATIC_LIB" CLEANUP=__CLEANUP_C pthreadVC$(DLL_VER).static
+
 realclean: clean
 	if exist *.dll del *.dll
 	if exist *.lib del *.lib
@@ -426,6 +431,10 @@ $(INLINED_STAMPS): $(DLL_INLINED_OBJS)
 		/link /nodefaultlib:libcmt /implib:$*.lib \
 		msvcrt.lib wsock32.lib /out:$*.dll
 
+$(STATIC_STAMPS): $(DLL_INLINED_OBJS)
+	if exist $*.lib del $*.lib
+	lib $(DLL_INLINED_OBJS) /out:$*.lib
+
 .c.obj:
 	cl $(EHFLAGS) /D$(CLEANUP) -c $<
 
diff --git a/README b/README
index bd74307..c6e8718 100644
--- a/README
+++ b/README
@@ -378,6 +378,22 @@ make clean GCX	(tests the GC version of the library with C++ (EH)
 			 applications)
 
 
+Building the library as a statically linkable library
+-----------------------------------------------------
+
+General: PTW32_STATIC_LIB must be defined for both the library build and the
+application build. The following 'make' command lines define this for the
+library build.
+
+MSVC (creates pthreadVCn.lib as a static link lib):
+nmake clean VC-static
+
+MinGW32 (creates libpthreadGCn.a as a static link lib):
+make clean GC-static
+
+Define PTW32_STATIC_LIB when building your application.
+
+
 Building the library under Cygwin
 ---------------------------------
 
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 7b03968..87cb3b0 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,9 @@
+2005-04-01  Ross Johnson  <rpj@callisto.canberra.edu.au>
+
+	* GNUmakefile: Add target to test linking static link library.
+	* Makefile: Likewise.
+	* self1.c: Run process attach/detach routines when static linked.
+
 2005-03-16  Ross Johnson  <rpj@callisto.canberra.edu.au>
 
 	* mutex5.c: Prevent optimiser from removing asserts.
diff --git a/tests/GNUmakefile b/tests/GNUmakefile
index b8b1c91..2f3cf85 100644
--- a/tests/GNUmakefile
+++ b/tests/GNUmakefile
@@ -74,7 +74,6 @@ COPYFILES	= $(HDR) $(LIB) $(DLL) $(QAPC)
 # If a test case returns a non-zero exit code to the shell, make will
 # stop.
 
-XTESTS	= once3 
 TESTS	= sizes loadfree \
 	  self1 mutex5 mutex1 mutex1e mutex1n mutex1r \
 	  semaphore1 semaphore2 semaphore3 \
@@ -108,8 +107,12 @@ TESTS	= sizes loadfree \
 BENCHTESTS = \
 	benchtest1 benchtest2 benchtest3 benchtest4 benchtest5
 
+STATICTESTS = \
+	self1
+
 PASSES		= $(TESTS:%=%.pass)
 BENCHRESULTS	= $(BENCHTESTS:%=%.bench)
+STATICRESULTS	= $(STATICTESTS:%=%.pass)
 
 help:
 	@ $(ECHO) "Run one of the following command lines:"
@@ -118,6 +121,7 @@ help:
 	@ $(ECHO) "make clean GCE   (to test using GCE dll with C++ (EH) applications)"
 	@ $(ECHO) "make clean GC-bench	  (to benchtest using GNU C dll with C cleanup code)"
 	@ $(ECHO) "make clean GCE-bench   (to benchtest using GNU C dll with C++ exception handling)"
+	@ $(ECHO) "make clean GC-static   (to test using GC static lib with C (no EH) applications)"
 
 all:
 	@ $(MAKE) clean GC
@@ -139,12 +143,20 @@ GC-bench:
 GCE-bench:
 	$(MAKE) TEST=GCE  CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="benchlib." all-bench
 
+GC-static:
+	$(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" DLL="" all-static
+
 all-pass: $(PASSES)
 	@ $(ECHO) ALL TESTS PASSED! Congratulations!
 
 all-bench: $(BENCHRESULTS)
 	@ $(ECHO) BENCH TESTS COMPLETED.
 
+all-static: $(STATICRESULTS)
+	@ $(ECHO) ALL STATIC TESTS PASSED! Congratulations!
+	@ $(ECHO) Build and test the DLL to run all tests.
+	@ $(ECHO) This test only confirms that the static lib links correctly.
+
 benchtest1.bench:
 benchtest2.bench:
 benchtest3.bench:
@@ -332,4 +344,5 @@ clean:
 	- $(RM) *.exe
 	- $(RM) *.pass
 	- $(RM) *.bench
+	- $(RM) *.static
 	- $(RM) *.log
diff --git a/tests/Makefile b/tests/Makefile
index 3b75670..6e6ecf3 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -120,6 +120,9 @@ PASSES= sizes.pass  loadfree.pass \
 BENCHRESULTS = \
 	  benchtest1.bench benchtest2.bench benchtest3.bench benchtest4.bench benchtest5.bench
 
+STATICRESULTS = \
+	  self1.pass
+
 help:
 	@ $(ECHO) Run one of the following command lines:
 	@ $(ECHO) nmake clean VC    (to test using VC dll with VC (no EH) applications)
@@ -130,6 +133,7 @@ help:
 	@ $(ECHO) nmake clean VCX-bench   (to benchtest using VC dll with C++ bench app)
 	@ $(ECHO) nmake clean VCE-bench   (to benchtest using VCE dll with C++ bench app)
 	@ $(ECHO) nmake clean VSE-bench   (to benchtest using VSE dll with SEH bench app)
+	@ $(ECHO) nmake clean VC-static   (to test using VC static lib with VC (no EH) applications)
 
 all:
 	@ nmake clean VC
@@ -148,6 +152,11 @@ tests: $(CPLIB) $(CPDLL) $(CPHDR) $(QAPC) $(PASSES)
 benchtests: $(CPLIB) $(CPDLL) $(CPHDR) $(XXLIBS) $(BENCHRESULTS)
 	@ $(ECHO) ALL BENCH TESTS DONE.
 
+statictests: $(CPLIB) $(CPDLL) $(CPHDR) $(STATICRESULTS)
+	@ $(ECHO) ALL STATIC TESTS DONE.
+	@ $(ECHO) Build and test the DLL to run all tests.
+	@ $(ECHO) The static test only confirms that the .lib links correctly.
+
 sizes.pass: sizes.exe
 	@ $(ECHO) ... Running $(TEST)$(DLL_VER) test: $*.exe
 	@ .\$*.exe > SIZES.$(TEST)
@@ -191,6 +200,9 @@ VC-bench:
 VCX-bench:
 	@ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="$(VCDLL)" EHFLAGS="$(VCXFLAGS)" XXLIBS="benchlib.o" benchtests
 
+VC-static:
+	@ nmake TEST="$@" CPLIB="$(VCLIB)" CPDLL="" EHFLAGS="$(VCFLAGS) /DPTW32_STATIC_LIB" statictests
+
 .c.exe:
 	@ $(ECHO) $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< /Fe$@ /link $(LFLAGS) $(CPLIB) $(XXLIBS)
 	@ $(CC) $(EHFLAGS) $(CFLAGS) $(INCLUDES) $< /Fe$@ /link $(LFLAGS) $(CPLIB) $(XXLIBS)
diff --git a/tests/self1.c b/tests/self1.c
index 773aee1..59498d9 100644
--- a/tests/self1.c
+++ b/tests/self1.c
@@ -54,9 +54,16 @@ main(int argc, char * argv[])
 	 */
 	pthread_t self;
 
+#ifdef PTW32_STATIC_LIB
+	pthread_win32_process_attach_np();
+#endif
+
 	self = pthread_self();
 
 	assert(self.p != NULL);
 
+#ifdef PTW32_STATIC_LIB
+	pthread_win32_process_detach_np();
+#endif
 	return 0;
 }
-- 
cgit v1.2.3