feat: add pthreads target

This commit is contained in:
Nemo D'ACREMONT 2025-03-14 19:05:49 +01:00
parent b3afab289b
commit 77a7730e09
No known key found for this signature in database
GPG Key ID: 85F245EC3BB1E022
2 changed files with 20 additions and 4 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
/install
/tags
/.vscode
/.lastpthread
/compile_flags.txt
# Local History for Visual Studio Code

View File

@ -26,14 +26,28 @@ install_bins_targets=$(addprefix ${install_dir}/bin/,${bins})
src_dirs=$(sort $(dir $(wildcard ${src_dir}/**/)))
includes=$(patsubst %,-I%,${src_dirs})
CFLAGS+=-g -O0 -std=c99 ${includes} -lpthread
CFLAGS+=-g -O0 -std=c99 ${includes}
LDFLAGS+=
ifdef _USE_PTHREAD
LDFLAGS+=-lpthread
endif
# Tests if the last compilation was with pthread
ifeq ("$(wildcard .lastpthread)","")
all_targets:=build
pthread_targets:=clean build
else
pthread_targets:=build
all_targets:=clean build
endif
srcs+=$(wildcard ${src_dir}/*.c ${src_dir}/**/*.c)
objs+=$(patsubst %.c,${build_dir}/%.o,${srcs})
.PHONY: all
all: build
all: ${all_targets}
${RM} .lastpthread # Set that the last build was without pthread
.PHONY: install
install: build ${install_bins_targets}
@ -55,7 +69,8 @@ build: ${bins_target}
.PHONY: pthreads
pthreads:
true
$(MAKE) _USE_PTHREAD=. ${pthread_targets}
touch .lastpthread
.PHONY: check
check:
@ -74,4 +89,4 @@ compile_flags.txt:
.PHONY: clean
clean:
${RM} -rf build main
${RM} -r build