fix: correctly compile with pthreads

This commit is contained in:
Alessandre Laguierce 2025-03-20 16:15:39 +01:00
parent 76336c307b
commit 1417cb8973
2 changed files with 6 additions and 3 deletions

View File

@ -34,8 +34,9 @@ includes=$(patsubst %,-I%,${src_dirs})
CFLAGS+=-g -O0 ${includes} -fPIC
LDFLAGS+=
ifdef _USE_PTHREAD
ifdef USE_PTHREAD
LDFLAGS+=-lpthread
CFLAGS+=-DUSE_PTHREAD
endif
# Tests if the last compilation was with pthread
@ -85,7 +86,7 @@ build: ${bins_target} ${build_dir}/libthread.so ${build_dir}/libthread.a
.PHONY: pthreads
pthreads:
$(MAKE) _USE_PTHREAD=. ${pthread_targets}
$(MAKE) USE_PTHREAD=. ${pthread_targets}
touch .lastpthread
.PHONY: check

View File

@ -1,3 +1,5 @@
#ifndef USE_PTHREAD
#include "thread.h"
#include "debug.h"
#include "pthread.h"
@ -42,4 +44,4 @@ int thread_mutex_unlock(thread_mutex_t *mutex) {
return pthread_mutex_unlock((pthread_mutex_t *)mutex);
}
#endif