feat: add pthreads target
This commit is contained in:
parent
b3afab289b
commit
77a7730e09
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,6 +3,7 @@
|
|||||||
/install
|
/install
|
||||||
/tags
|
/tags
|
||||||
/.vscode
|
/.vscode
|
||||||
|
/.lastpthread
|
||||||
/compile_flags.txt
|
/compile_flags.txt
|
||||||
|
|
||||||
# Local History for Visual Studio Code
|
# Local History for Visual Studio Code
|
||||||
|
23
Makefile
23
Makefile
@ -26,14 +26,28 @@ install_bins_targets=$(addprefix ${install_dir}/bin/,${bins})
|
|||||||
|
|
||||||
src_dirs=$(sort $(dir $(wildcard ${src_dir}/**/)))
|
src_dirs=$(sort $(dir $(wildcard ${src_dir}/**/)))
|
||||||
includes=$(patsubst %,-I%,${src_dirs})
|
includes=$(patsubst %,-I%,${src_dirs})
|
||||||
CFLAGS+=-g -O0 -std=c99 ${includes} -lpthread
|
|
||||||
|
CFLAGS+=-g -O0 -std=c99 ${includes}
|
||||||
LDFLAGS+=
|
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)
|
srcs+=$(wildcard ${src_dir}/*.c ${src_dir}/**/*.c)
|
||||||
objs+=$(patsubst %.c,${build_dir}/%.o,${srcs})
|
objs+=$(patsubst %.c,${build_dir}/%.o,${srcs})
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: build
|
all: ${all_targets}
|
||||||
|
${RM} .lastpthread # Set that the last build was without pthread
|
||||||
|
|
||||||
.PHONY: install
|
.PHONY: install
|
||||||
install: build ${install_bins_targets}
|
install: build ${install_bins_targets}
|
||||||
@ -55,7 +69,8 @@ build: ${bins_target}
|
|||||||
|
|
||||||
.PHONY: pthreads
|
.PHONY: pthreads
|
||||||
pthreads:
|
pthreads:
|
||||||
true
|
$(MAKE) _USE_PTHREAD=. ${pthread_targets}
|
||||||
|
touch .lastpthread
|
||||||
|
|
||||||
.PHONY: check
|
.PHONY: check
|
||||||
check:
|
check:
|
||||||
@ -74,4 +89,4 @@ compile_flags.txt:
|
|||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
${RM} -rf build main
|
${RM} -r build
|
||||||
|
Loading…
x
Reference in New Issue
Block a user