2
# --------------------------------------------------------------------------
4
# Pthreads-win32 - POSIX Threads Library for Win32
5
# Copyright(C) 1998 John E. Bossom
6
# Copyright(C) 1999,2005 Pthreads-win32 contributors
8
# Contact Email: rpj@callisto.canberra.edu.au
10
# The current list of contributors is contained
11
# in the file CONTRIBUTORS included with the source
12
# code distribution. The list can also be seen at the
13
# following World Wide Web location:
14
# http://sources.redhat.com/pthreads-win32/contributors.html
16
# This library is free software; you can redistribute it and/or
17
# modify it under the terms of the GNU Lesser General Public
18
# License as published by the Free Software Foundation; either
19
# version 2 of the License, or (at your option) any later version.
21
# This library is distributed in the hope that it will be useful,
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24
# Lesser General Public License for more details.
26
# You should have received a copy of the GNU Lesser General Public
27
# License along with this library in the file COPYING.LIB;
28
# if not, write to the Free Software Foundation, Inc.,
29
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
37
DLLDEST = $(DEVROOT)\DLL
38
LIBDEST = $(DEVROOT)\DLL
50
# For cross compiling use e.g.
51
# make CROSS=x86_64-w64-mingw32- clean GC-inlined
55
DLLTOOL = $(CROSS)dlltool
58
RANLIB = $(CROSS)ranlib
61
OPT = $(CLEANUP) -O3 # -finline-functions -findirect-inlining
64
RCFLAGS = --include-dir=.
65
# Uncomment this if config.h defines RETAIN_WSALASTERROR
68
# ----------------------------------------------------------------------
69
# The library can be built with some alternative behaviour to
70
# facilitate development of applications on Win32 that will be ported
71
# to other POSIX systems. Nothing definable here will make the library
72
# non-compliant, but applications that make assumptions that POSIX
73
# does not garrantee may fail or misbehave under some settings.
75
# PTW32_THREAD_ID_REUSE_INCREMENT
77
# POSIX says that applications should assume that thread IDs can be
78
# recycled. However, Solaris and some other systems use a [very large]
79
# sequence number as the thread ID, which provides virtual uniqueness.
80
# Pthreads-win32 provides pseudo-unique IDs when the default increment
81
# (1) is used, but pthread_t is not a scalar type like Solaris's.
84
# Set to any value in the range: 0 <= value <= 2^wordsize
87
# Set to 0 to emulate non recycle-unique behaviour like Linux or *BSD.
88
# Set to 1 for recycle-unique thread IDs (this is the default).
89
# Set to some other +ve value to emulate smaller word size types
90
# (i.e. will wrap sooner).
92
#PTW32_FLAGS = "-DPTW32_THREAD_ID_REUSE_INCREMENT=0"
94
# ----------------------------------------------------------------------
96
GC_CFLAGS = $(PTW32_FLAGS)
97
GCE_CFLAGS = $(PTW32_FLAGS) -mthreads
101
CFLAGS = $(OPT) $(XOPT) -I. -DHAVE_PTW32_CONFIG_H -Wall
107
# Agregate modules for inlinability
133
# Separate modules for minimum size statically linked images
134
SMALL_STATIC_OBJS = \
135
pthread_attr_init.o \
136
pthread_attr_destroy.o \
137
pthread_attr_getdetachstate.o \
138
pthread_attr_setdetachstate.o \
139
pthread_attr_getstackaddr.o \
140
pthread_attr_setstackaddr.o \
141
pthread_attr_getstacksize.o \
142
pthread_attr_setstacksize.o \
143
pthread_attr_getscope.o \
144
pthread_attr_setscope.o \
145
pthread_attr_setschedpolicy.o \
146
pthread_attr_getschedpolicy.o \
147
pthread_attr_setschedparam.o \
148
pthread_attr_getschedparam.o \
149
pthread_attr_setinheritsched.o \
150
pthread_attr_getinheritsched.o \
151
pthread_barrier_init.o \
152
pthread_barrier_destroy.o \
153
pthread_barrier_wait.o \
154
pthread_barrierattr_init.o \
155
pthread_barrierattr_destroy.o \
156
pthread_barrierattr_setpshared.o \
157
pthread_barrierattr_getpshared.o \
158
pthread_setcancelstate.o \
159
pthread_setcanceltype.o \
160
pthread_testcancel.o \
163
pthread_condattr_destroy.o \
164
pthread_condattr_getpshared.o \
165
pthread_condattr_init.o \
166
pthread_condattr_setpshared.o \
167
pthread_cond_destroy.o \
168
pthread_cond_init.o \
169
pthread_cond_signal.o \
170
pthread_cond_wait.o \
178
pthread_mutex_init.o \
179
pthread_mutex_destroy.o \
180
pthread_mutexattr_init.o \
181
pthread_mutexattr_destroy.o \
182
pthread_mutexattr_getpshared.o \
183
pthread_mutexattr_setpshared.o \
184
pthread_mutexattr_settype.o \
185
pthread_mutexattr_gettype.o \
186
pthread_mutexattr_setrobust.o \
187
pthread_mutexattr_getrobust.o \
188
pthread_mutex_lock.o \
189
pthread_mutex_timedlock.o \
190
pthread_mutex_unlock.o \
191
pthread_mutex_trylock.o \
192
pthread_mutex_consistent.o \
193
pthread_mutexattr_setkind_np.o \
194
pthread_mutexattr_getkind_np.o \
195
pthread_getw32threadhandle_np.o \
196
pthread_getunique_np.o \
198
pthread_num_processors_np.o \
199
pthread_win32_attach_detach_np.o \
201
pthread_getconcurrency.o \
204
pthread_setconcurrency.o \
205
pthread_rwlock_init.o \
206
pthread_rwlock_destroy.o \
207
pthread_rwlockattr_init.o \
208
pthread_rwlockattr_destroy.o \
209
pthread_rwlockattr_getpshared.o \
210
pthread_rwlockattr_setpshared.o \
211
pthread_rwlock_rdlock.o \
212
pthread_rwlock_wrlock.o \
213
pthread_rwlock_unlock.o \
214
pthread_rwlock_tryrdlock.o \
215
pthread_rwlock_trywrlock.o \
216
pthread_setschedparam.o \
217
pthread_getschedparam.o \
218
pthread_timechange_handler_np.o \
220
ptw32_cond_check_need_init.o \
222
ptw32_mutex_check_need_init.o \
223
ptw32_processInitialize.o \
224
ptw32_processTerminate.o \
225
ptw32_threadStart.o \
226
ptw32_threadDestroy.o \
227
ptw32_tkAssocCreate.o \
228
ptw32_tkAssocDestroy.o \
229
ptw32_callUserDestroyRoutines.o \
232
ptw32_getprocessors.o \
237
ptw32_relmillisecs.o \
238
ptw32_rwlock_check_need_init.o \
239
sched_get_priority_max.o \
240
sched_get_priority_min.o \
241
sched_setscheduler.o \
242
sched_getscheduler.o \
250
sem_post_multiple.o \
257
ptw32_spinlock_check_need_init.o \
258
pthread_spin_init.o \
259
pthread_spin_destroy.o \
260
pthread_spin_lock.o \
261
pthread_spin_unlock.o \
262
pthread_spin_trylock.o \
265
pthread_key_create.o \
266
pthread_key_delete.o \
267
pthread_setspecific.o \
268
pthread_getspecific.o \
269
w32_CancelableWait.o \
280
pthread_attr_init.c \
281
pthread_attr_destroy.c \
282
pthread_attr_getdetachstate.c \
283
pthread_attr_setdetachstate.c \
284
pthread_attr_getstackaddr.c \
285
pthread_attr_setstackaddr.c \
286
pthread_attr_getstacksize.c \
287
pthread_attr_setstacksize.c \
288
pthread_attr_getscope.c \
289
pthread_attr_setscope.c
292
pthread_barrier_init.c \
293
pthread_barrier_destroy.c \
294
pthread_barrier_wait.c \
295
pthread_barrierattr_init.c \
296
pthread_barrierattr_destroy.c \
297
pthread_barrierattr_setpshared.c \
298
pthread_barrierattr_getpshared.c
301
pthread_setcancelstate.c \
302
pthread_setcanceltype.c \
303
pthread_testcancel.c \
307
ptw32_cond_check_need_init.c \
308
pthread_condattr_destroy.c \
309
pthread_condattr_getpshared.c \
310
pthread_condattr_init.c \
311
pthread_condattr_setpshared.c \
312
pthread_cond_destroy.c \
313
pthread_cond_init.c \
314
pthread_cond_signal.c \
322
pthread_getconcurrency.c \
326
pthread_setconcurrency.c \
334
ptw32_mutex_check_need_init.c \
335
pthread_mutex_init.c \
336
pthread_mutex_destroy.c \
337
pthread_mutexattr_init.c \
338
pthread_mutexattr_destroy.c \
339
pthread_mutexattr_getpshared.c \
340
pthread_mutexattr_setpshared.c \
341
pthread_mutexattr_settype.c \
342
pthread_mutexattr_gettype.c \
343
pthread_mutexattr_setrobust.c \
344
pthread_mutexattr_getrobust.c \
345
pthread_mutex_lock.c \
346
pthread_mutex_timedlock.c \
347
pthread_mutex_unlock.c \
348
pthread_mutex_trylock.c \
349
pthread_mutex_consistent.c
352
pthread_mutexattr_setkind_np.c \
353
pthread_mutexattr_getkind_np.c \
354
pthread_getw32threadhandle_np.c \
355
pthread_getunique_np.c \
357
pthread_num_processors_np.c \
358
pthread_win32_attach_detach_np.c \
359
pthread_timechange_handler_np.c
363
ptw32_processInitialize.c \
364
ptw32_processTerminate.c \
365
ptw32_threadStart.c \
366
ptw32_threadDestroy.c \
367
ptw32_tkAssocCreate.c \
368
ptw32_tkAssocDestroy.c \
369
ptw32_callUserDestroyRoutines.c \
371
ptw32_relmillisecs.c \
374
ptw32_getprocessors.c
377
ptw32_rwlock_check_need_init.c \
378
ptw32_rwlock_cancelwrwait.c \
379
pthread_rwlock_init.c \
380
pthread_rwlock_destroy.c \
381
pthread_rwlockattr_init.c \
382
pthread_rwlockattr_destroy.c \
383
pthread_rwlockattr_getpshared.c \
384
pthread_rwlockattr_setpshared.c \
385
pthread_rwlock_rdlock.c \
386
pthread_rwlock_timedrdlock.c \
387
pthread_rwlock_wrlock.c \
388
pthread_rwlock_timedwrlock.c \
389
pthread_rwlock_unlock.c \
390
pthread_rwlock_tryrdlock.c \
391
pthread_rwlock_trywrlock.c
394
pthread_attr_setschedpolicy.c \
395
pthread_attr_getschedpolicy.c \
396
pthread_attr_setschedparam.c \
397
pthread_attr_getschedparam.c \
398
pthread_attr_setinheritsched.c \
399
pthread_attr_getinheritsched.c \
400
pthread_setschedparam.c \
401
pthread_getschedparam.c \
402
sched_get_priority_max.c \
403
sched_get_priority_min.c \
404
sched_setscheduler.c \
405
sched_getscheduler.c \
415
sem_post_multiple.c \
422
ptw32_spinlock_check_need_init.c \
423
pthread_spin_init.c \
424
pthread_spin_destroy.c \
425
pthread_spin_lock.c \
426
pthread_spin_unlock.c \
427
pthread_spin_trylock.c
434
pthread_key_create.c \
435
pthread_key_delete.c \
436
pthread_setspecific.c \
437
pthread_getspecific.c
440
GCE_DLL = pthreadGCE$(DLL_VER).dll
441
GCED_DLL= pthreadGCE$(DLL_VERD).dll
442
GCE_LIB = libpthreadGCE$(DLL_VER).a
443
GCED_LIB= libpthreadGCE$(DLL_VERD).a
444
GCE_INLINED_STAMP = pthreadGCE$(DLL_VER).stamp
445
GCED_INLINED_STAMP = pthreadGCE$(DLL_VERD).stamp
446
GCE_STATIC_STAMP = libpthreadGCE$(DLL_VER).stamp
447
GCED_STATIC_STAMP = libpthreadGCE$(DLL_VERD).stamp
449
GC_DLL = pthreadGC$(DLL_VER).dll
450
GCD_DLL = pthreadGC$(DLL_VERD).dll
451
GC_LIB = libpthreadGC$(DLL_VER).a
452
GCD_LIB = libpthreadGC$(DLL_VERD).a
453
GC_INLINED_STAMP = pthreadGC$(DLL_VER).stamp
454
GCD_INLINED_STAMP = pthreadGC$(DLL_VERD).stamp
455
GC_STATIC_STAMP = libpthreadGC$(DLL_VER).stamp
456
GCD_STATIC_STAMP = libpthreadGC$(DLL_VERD).stamp
458
PTHREAD_DEF = pthread.def
461
@ echo "Run one of the following command lines:"
462
@ echo "make clean GC (to build the GNU C dll with C cleanup code)"
463
@ echo "make clean GCE (to build the GNU C dll with C++ exception handling)"
464
@ echo "make clean GC-inlined (to build the GNU C inlined dll with C cleanup code)"
465
@ echo "make clean GCE-inlined (to build the GNU C inlined dll with C++ exception handling)"
466
@ echo "make clean GC-static (to build the GNU C inlined static lib with C cleanup code)"
467
@ echo "make clean GC-debug (to build the GNU C debug dll with C cleanup code)"
468
@ echo "make clean GCE-debug (to build the GNU C debug dll with C++ exception handling)"
469
@ echo "make clean GC-inlined-debug (to build the GNU C inlined debug dll with C cleanup code)"
470
@ echo "make clean GCE-inlined-debug (to build the GNU C inlined debug dll with C++ exception handling)"
471
@ echo "make clean GC-static-debug (to build the GNU C inlined static debug lib with C cleanup code)"
478
$(MAKE) CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" $(GC_DLL)
481
$(MAKE) CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_DLL)
484
$(MAKE) CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" $(GCE_DLL)
487
$(MAKE) CC=$(CXX) CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_DLL)
490
$(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_INLINED_STAMP)
493
$(MAKE) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_INLINED_STAMP)
496
$(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GCE_INLINED_STAMP)
499
$(MAKE) CC=$(CXX) XOPT="-DPTW32_BUILD_INLINED" CLEANUP=-D__CLEANUP_CXX XC_FLAGS="$(GCE_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_CXX -g -O0" $(GCED_INLINED_STAMP)
502
$(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" $(GC_STATIC_STAMP)
505
$(MAKE) XOPT="-DPTW32_BUILD_INLINED -DPTW32_STATIC_LIB" CLEANUP=-D__CLEANUP_C XC_FLAGS="$(GC_CFLAGS)" OBJ="$(DLL_INLINED_OBJS)" DLL_VER=$(DLL_VERD) OPT="-D__CLEANUP_C -g -O0" $(GCD_STATIC_STAMP)
512
$(CC) -E -o $@ $(CFLAGS) $^
515
$(CC) -c $(CFLAGS) -DPTW32_BUILD_INLINED -Wa,-ahl $^ > $@
518
$(RC) $(RCFLAGS) $(CLEANUP) -o $@ -i $<
520
.SUFFIXES: .dll .rc .c .o
522
.c.o:; $(CC) -c -o $@ $(CFLAGS) $(XC_FLAGS) $<
525
$(GC_DLL) $(GCD_DLL): $(DLL_OBJS)
526
$(CC) $(OPT) -shared -o $(GC_DLL) $(DLL_OBJS) $(LFLAGS)
527
$(DLLTOOL) -z pthread.def $(DLL_OBJS)
528
$(DLLTOOL) -k --dllname $@ --output-lib $(GC_LIB) --def $(PTHREAD_DEF)
530
$(GCE_DLL): $(DLL_OBJS)
531
$(CC) $(OPT) -mthreads -shared -o $(GCE_DLL) $(DLL_OBJS) $(LFLAGS)
532
$(DLLTOOL) -z pthread.def $(DLL_OBJS)
533
$(DLLTOOL) -k --dllname $@ --output-lib $(GCE_LIB) --def $(PTHREAD_DEF)
535
$(GC_INLINED_STAMP) $(GCD_INLINED_STAMP): $(DLL_INLINED_OBJS)
536
$(CC) $(OPT) $(XOPT) -shared -o $(GC_DLL) $(DLL_INLINED_OBJS) $(LFLAGS)
537
$(DLLTOOL) -z pthread.def $(DLL_INLINED_OBJS)
538
$(DLLTOOL) -k --dllname $(GC_DLL) --output-lib $(GC_LIB) --def $(PTHREAD_DEF)
539
echo touched > $(GC_INLINED_STAMP)
541
$(GCE_INLINED_STAMP) $(GCED_INLINED_STAMP): $(DLL_INLINED_OBJS)
542
$(CC) $(OPT) $(XOPT) -mthreads -shared -o $(GCE_DLL) $(DLL_INLINED_OBJS) $(LFLAGS)
543
$(DLLTOOL) -z pthread.def $(DLL_INLINED_OBJS)
544
$(DLLTOOL) -k --dllname $(GCE_DLL) --output-lib $(GCE_LIB) --def $(PTHREAD_DEF)
545
echo touched > $(GCE_INLINED_STAMP)
547
$(GC_STATIC_STAMP) $(GCD_STATIC_STAMP): $(DLL_INLINED_OBJS)
549
$(AR) -rv $(GC_LIB) $(DLL_INLINED_OBJS)
551
echo touched > $(GC_STATIC_STAMP)
560
-$(RM) $(PTHREAD_DEF)
567
-$(RM) $(GC_INLINED_STAMP)
568
-$(RM) $(GCE_INLINED_STAMP)
569
-$(RM) $(GC_STATIC_STAMP)
574
-$(RM) $(GCD_INLINED_STAMP)
575
-$(RM) $(GCED_INLINED_STAMP)
576
-$(RM) $(GCD_STATIC_STAMP)
578
attr.o: attr.c $(ATTR_SRCS) $(INCL)
579
barrier.o: barrier.c $(BARRIER_SRCS) $(INCL)
580
cancel.o: cancel.c $(CANCEL_SRCS) $(INCL)
581
condvar.o: condvar.c $(CONDVAR_SRCS) $(INCL)
582
exit.o: exit.c $(EXIT_SRCS) $(INCL)
583
misc.o: misc.c $(MISC_SRCS) $(INCL)
584
mutex.o: mutex.c $(MUTEX_SRCS) $(INCL)
585
nonportable.o: nonportable.c $(NONPORTABLE_SRCS) $(INCL)
586
private.o: private.c $(PRIVATE_SRCS) $(INCL)
587
rwlock.o: rwlock.c $(RWLOCK_SRCS) $(INCL)
588
sched.o: sched.c $(SCHED_SRCS) $(INCL)
589
semaphore.o: semaphore.c $(SEMAPHORE_SRCS) $(INCL)
590
spin.o: spin.c $(SPIN_SRCS) $(INCL)
591
sync.o: sync.c $(SYNC_SRCS) $(INCL)
592
tsd.o: tsd.c $(TSD_SRCS) $(INCL)
593
version.o: version.rc $(INCL)