1# Makefile for the pthreads test suite.
2# If all of the .pass files can be created, the test suite has passed.
3#
4# --------------------------------------------------------------------------
5#
6#      Pthreads-win32 - POSIX Threads Library for Win32
7#      Copyright(C) 1998 John E. Bossom
8#      Copyright(C) 1999,2005 Pthreads-win32 contributors
9#
10#      Contact Email: rpj@callisto.canberra.edu.au
11#
12#      The current list of contributors is contained
13#      in the file CONTRIBUTORS included with the source
14#      code distribution. The list can also be seen at the
15#      following World Wide Web location:
16#      http://sources.redhat.com/pthreads-win32/contributors.html
17#
18#      This library is free software; you can redistribute it and/or
19#      modify it under the terms of the GNU Lesser General Public
20#      License as published by the Free Software Foundation; either
21#      version 2 of the License, or (at your option) any later version.
22#
23#      This library is distributed in the hope that it will be useful,
24#      but WITHOUT ANY WARRANTY; without even the implied warranty of
25#      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26#      Lesser General Public License for more details.
27#
28#      You should have received a copy of the GNU Lesser General Public
29#      License along with this library in the file COPYING.LIB;
30#      if not, write to the Free Software Foundation, Inc.,
31#      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
32#
33
34DLL_VER	= 2
35
36CP	= cp -f
37MV	= mv -f
38RM	= rm -f
39CAT	= cat
40#CP	= copy
41#MV	= rename
42#RM	= erase
43#CAT	= type
44MKDIR	= mkdir
45TOUCH	= echo Passed >
46ECHO	= @echo
47MAKE	= make
48
49#
50# Mingw32
51#
52XXCFLAGS	=
53XXLIBS	= -lws2_32
54#CFLAGS	= -O3 -UNDEBUG -Wall $(XXCFLAGS)
55CFLAGS	= -g -UNDEBUG -Wall $(XXCFLAGS)
56BUILD_DIR	= ..
57INCLUDES	= -I.
58
59
60TEST	= GC
61
62# Default lib version
63GCX	= $(TEST)$(DLL_VER)
64
65# Files we need to run the tests
66# - paths are relative to pthreads build dir.
67HDR	= pthread.h semaphore.h sched.h
68LIB	= libpthread$(GCX).a
69DLL	= pthread$(GCX).dll
70QAPC	= ../QueueUserAPCEx/User/quserex.dll
71
72COPYFILES	= $(HDR) $(LIB) $(DLL) $(QAPC)
73
74# If a test case returns a non-zero exit code to the shell, make will
75# stop.
76
77TESTS	= sizes loadfree \
78	  self1 mutex5 mutex1 mutex1e mutex1n mutex1r \
79	  semaphore1 semaphore2 semaphore3 \
80	  condvar1 condvar1_1 condvar1_2 condvar2 condvar2_1 exit1 \
81	  create1 create2 reuse1 reuse2 equal1 \
82	  kill1 valid1 valid2 \
83	  exit2 exit3 exit4 exit5 \
84	  join0 join1 detach1 join2 join3 \
85	  mutex2 mutex2r mutex2e mutex3 mutex3r mutex3e \
86	  mutex4 mutex6 mutex6n mutex6e mutex6r \
87	  mutex6s mutex6es mutex6rs \
88	  mutex7 mutex7n mutex7e mutex7r mutex8 mutex8n mutex8e mutex8r \
89	  count1 \
90	  once1 once2 once3 once4 self2 \
91	  cancel1 cancel2 \
92	  semaphore4 semaphore4t semaphore5 \
93	  barrier1 barrier2 barrier3 barrier4 barrier5 \
94	  tsd1 tsd2 delay1 delay2 eyal1 \
95	  condvar3 condvar3_1 condvar3_2 condvar3_3 \
96	  condvar4 condvar5 condvar6 condvar7 condvar8 condvar9 \
97	  errno1 \
98	  rwlock1 rwlock2 rwlock3 rwlock4 rwlock5 rwlock6 rwlock7 rwlock8 \
99	  rwlock2_t rwlock3_t rwlock4_t rwlock5_t rwlock6_t rwlock6_t2 \
100	  context1 cancel3 cancel4 cancel5 cancel6a cancel6d \
101	  cancel7 cancel8 \
102	  cleanup0 cleanup1 cleanup2 cleanup3 \
103	  priority1 priority2 inherit1 \
104	  spin1 spin2 spin3 spin4 \
105	  exception1 exception2 exception3 \
106	  cancel9 create3 stress1
107
108STRESSTESTS = \
109	stress1
110
111BENCHTESTS = \
112	benchtest1 benchtest2 benchtest3 benchtest4 benchtest5
113
114STATICTESTS = \
115	self1
116
117PASSES		= $(TESTS:%=%.pass)
118BENCHRESULTS	= $(BENCHTESTS:%=%.bench)
119STRESSRESULTS	= $(STRESSTESTS:%=%.pass)
120STATICRESULTS	= $(STATICTESTS:%=%.pass)
121
122help:
123	@ $(ECHO) "Run one of the following command lines:"
124	@ $(ECHO) "make clean GC    (to test using GC dll with C (no EH) applications)"
125	@ $(ECHO) "make clean GCX   (to test using GC dll with C++ (EH) applications)"
126	@ $(ECHO) "make clean GCE   (to test using GCE dll with C++ (EH) applications)"
127	@ $(ECHO) "make clean GC-bench	  (to benchtest using GNU C dll with C cleanup code)"
128	@ $(ECHO) "make clean GCE-bench   (to benchtest using GNU C dll with C++ exception handling)"
129	@ $(ECHO) "make clean GC-stress	  (to stresstest using GNU C dll with C cleanup code)"
130	@ $(ECHO) "make clean GCE-stress   (to stresstest using GNU C dll with C++ exception handling)"
131	@ $(ECHO) "make clean GC-static   (to test using GC static lib with C (no EH) applications)"
132
133all:
134	@ $(MAKE) clean GC
135	@ $(MAKE) clean GCX
136	@ $(MAKE) clean GCE
137
138GC:
139	$(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" all-pass
140
141GCE:
142	$(MAKE) TEST=GCE CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" all-pass
143
144GCX:
145	$(MAKE) TEST=GC CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_C" all-pass
146
147GC-bench:
148	$(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" XXLIBS="benchlib.o" all-bench
149
150GCE-bench:
151	$(MAKE) TEST=GCE  CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" XXLIBS="benchlib." all-bench
152
153GC-debug:
154	$(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" DLL_VER="$(DLL_VER)d" all-pass
155
156GC-static:
157	$(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C -DPTW32_STATIC_LIB" DLL="" all-static
158
159GC-stress:
160	$(ECHO) Stress tests can take a long time since they are trying to
161	$(ECHO) expose weaknesses that may be intermittant or statistically rare.
162	$(ECHO) A pass does not prove correctness, but may give greater confidence.
163	$(MAKE) TEST=GC CC=gcc XXCFLAGS="-D__CLEANUP_C" all-stress
164
165GCE-stress:
166	$(MAKE) TEST=GCE  CC=g++ XXCFLAGS="-mthreads -D__CLEANUP_CXX" all-stress
167
168all-pass: $(PASSES)
169	@ $(ECHO) ALL TESTS PASSED! Congratulations!
170
171all-bench: $(BENCHRESULTS)
172	@ $(ECHO) BENCH TESTS COMPLETED.
173
174all-stress: $(STRESSRESULTS)
175	@ $(ECHO) STRESS TESTS COMPLETED.
176
177all-static: $(STATICRESULTS)
178	@ $(ECHO) ALL STATIC TESTS PASSED! Congratulations!
179	@ $(ECHO) Build and test the DLL to run all tests.
180	@ $(ECHO) This test only confirms that the static lib links correctly.
181
182benchtest1.bench:
183benchtest2.bench:
184benchtest3.bench:
185benchtest4.bench:
186benchtest5.bench:
187
188barrier1.pass: semaphore4.pass
189barrier2.pass: barrier1.pass
190barrier3.pass: barrier2.pass
191barrier4.pass: barrier3.pass
192barrier5.pass: barrier4.pass
193cancel1.pass: create1.pass
194cancel2.pass: cancel1.pass
195cancel2_1.pass: cancel2.pass
196cancel3.pass: context1.pass
197cancel4.pass: cancel3.pass
198cancel5.pass: cancel3.pass
199cancel6a.pass: cancel3.pass
200cancel6d.pass: cancel3.pass
201cancel7.pass: kill1.pass
202cancel8.pass: cancel7.pass
203cancel9.pass: cancel8.pass
204cleanup0.pass: cancel5.pass
205cleanup1.pass: cleanup0.pass
206cleanup2.pass: cleanup1.pass
207cleanup3.pass: cleanup2.pass
208condvar1.pass:
209condvar1_1.pass: condvar1.pass
210condvar1_2.pass: join2.pass
211condvar2.pass: condvar1.pass
212condvar2_1.pass: condvar2.pass join2.pass
213condvar3.pass: create1.pass condvar2.pass
214condvar3_1.pass: condvar3.pass join2.pass
215condvar3_2.pass: condvar3_1.pass
216condvar3_3.pass: condvar3_2.pass
217condvar4.pass: create1.pass
218condvar5.pass: condvar4.pass
219condvar6.pass: condvar5.pass
220condvar7.pass: condvar6.pass cleanup1.pass
221condvar8.pass: condvar7.pass
222condvar9.pass: condvar8.pass
223context1.pass: cancel2.pass
224count1.pass: join1.pass
225create1.pass: mutex2.pass
226create2.pass: create1.pass
227create3.pass:
228delay1.pass: cancel2.pass
229delay2.pass: delay1.pass
230detach1.pass: join0.pass
231equal1.pass: create1.pass
232errno1.pass: mutex3.pass
233exception1.pass: cancel4.pass
234exception2.pass: exception1.pass
235exception3.pass: exception2.pass
236exit1.pass:
237exit2.pass: create1.pass
238exit3.pass: create1.pass
239exit4.pass:
240exit5.pass: exit4.pass kill1.pass
241eyal1.pass: tsd1.pass
242inherit1.pass: join1.pass priority1.pass
243join0.pass: create1.pass
244join1.pass: create1.pass
245join2.pass: create1.pass
246join3.pass: join2.pass
247kill1.pass:
248loadfree.pass: pthread.dll
249mutex1.pass: self1.pass
250mutex1n.pass: mutex1.pass
251mutex1e.pass: mutex1.pass
252mutex1r.pass: mutex1.pass
253mutex2.pass: mutex1.pass
254mutex2r.pass: mutex2.pass
255mutex2e.pass: mutex2.pass
256mutex3.pass: create1.pass
257mutex3r.pass: mutex3.pass
258mutex3e.pass: mutex3.pass
259mutex4.pass: mutex3.pass
260mutex5.pass:
261mutex6.pass: mutex4.pass
262mutex6n.pass: mutex4.pass
263mutex6e.pass: mutex4.pass
264mutex6r.pass: mutex4.pass
265mutex6s.pass: mutex6.pass
266mutex6rs.pass: mutex6r.pass
267mutex6es.pass: mutex6e.pass
268mutex7.pass: mutex6.pass
269mutex7n.pass: mutex6n.pass
270mutex7e.pass: mutex6e.pass
271mutex7r.pass: mutex6r.pass
272mutex8.pass: mutex7.pass
273mutex8n.pass: mutex7n.pass
274mutex8e.pass: mutex7e.pass
275mutex8r.pass: mutex7r.pass
276once1.pass: create1.pass
277once2.pass: once1.pass
278once3.pass: once2.pass
279once4.pass: once3.pass
280priority1.pass: join1.pass
281priority2.pass: priority1.pass barrier3.pass
282reuse1.pass: create2.pass
283reuse2.pass: reuse1.pass
284rwlock1.pass: condvar6.pass
285rwlock2.pass: rwlock1.pass
286rwlock3.pass: rwlock2.pass
287rwlock4.pass: rwlock3.pass
288rwlock5.pass: rwlock4.pass
289rwlock6.pass: rwlock5.pass
290rwlock7.pass: rwlock6.pass
291rwlock8.pass: rwlock7.pass
292rwlock2_t.pass: rwlock2.pass
293rwlock3_t.pass: rwlock2_t.pass
294rwlock4_t.pass: rwlock3_t.pass
295rwlock5_t.pass: rwlock4_t.pass
296rwlock6_t.pass: rwlock5_t.pass
297rwlock6_t2.pass: rwlock6_t.pass
298self1.pass:
299self2.pass: create1.pass
300semaphore1.pass:
301semaphore2.pass:
302semaphore3.pass: semaphore2.pass
303semaphore4.pass: semaphore3.pass cancel1.pass
304semaphore4t.pass: semaphore4.pass
305semaphore5.pass: semaphore4.pass
306sizes.pass:
307spin1.pass:
308spin2.pass: spin1.pass
309spin3.pass: spin2.pass
310spin4.pass: spin3.pass
311stress1.pass:
312tsd1.pass: barrier5.pass join1.pass
313tsd2.pass: tsd1.pass
314valid1.pass: join1.pass
315valid2.pass: valid1.pass
316
317sizes.pass: sizes.exe
318	@ $(ECHO) Running $*
319	$< > SIZES.$(TEST)
320	@ $(CAT) SIZES.$(TEST)
321	@ $(ECHO) Passed
322	@ $(TOUCH) $@
323
324%.pass: %.exe
325	@ $(ECHO) Running $*
326	$*
327	@ $(ECHO) Passed
328	@ $(TOUCH) $@
329
330%.bench: $(LIB) $(DLL) $(HDR) $(QAPC) $(XXLIBS) %.exe
331	@ $(ECHO) Running $*
332	$*
333	@ $(ECHO) Done
334	@ $(TOUCH) $@
335
336%.exe: %.c $(LIB) $(DLL) $(HDR) $(QAPC)
337	@ $(ECHO) Compiling $@
338	@ $(ECHO) $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS)
339	@ $(CC) $(CFLAGS) -o $@ $< $(INCLUDES) -L. -lpthread$(GCX) -lsupc++ $(XXLIBS)
340
341%.pre: %.c $(HDR)
342	@ $(CC) -E $(CFLAGS) -o $@ $< $(INCLUDES)
343
344%.s: %.c $(HDR)
345	@ $(CC) -S $(CFLAGS) -o $@ $< $(INCLUDES)
346
347$(COPYFILES):
348	@ $(ECHO) Copying $@
349	@ $(CP) $(BUILD_DIR)/$@ .
350
351benchlib.o: benchlib.c
352	@ $(ECHO) Compiling $@
353	@ $(ECHO) $(CC) -c $(CFLAGS) $< $(INCLUDES)
354	@ $(CC) -c $(CFLAGS) $< $(INCLUDES)
355
356pthread.dll: $(DLL)
357	@ $(CP) $(DLL) $@
358
359clean:
360	- $(RM) *.dll
361	- $(RM) *.lib
362	- $(RM) pthread.h
363	- $(RM) semaphore.h
364	- $(RM) sched.h
365	- $(RM) *.a
366	- $(RM) *.e
367	- $(RM) *.i
368	- $(RM) *.o
369	- $(RM) *.obj
370	- $(RM) *.pdb
371	- $(RM) *.exe
372	- $(RM) *.pass
373	- $(RM) *.bench
374	- $(RM) *.static
375	- $(RM) *.log
376