feat: add base bin targets
This commit is contained in:
parent
7173c09cb6
commit
91d6d55a74
52
Makefile
52
Makefile
@ -1,26 +1,64 @@
|
|||||||
build_dir?=build
|
build_dir?=build
|
||||||
src_dir?=src
|
src_dir?=src
|
||||||
|
tst_dir?=tst
|
||||||
|
install_dir?=install
|
||||||
|
|
||||||
|
bins?= \
|
||||||
|
01-main \
|
||||||
|
02-switch \
|
||||||
|
03-equity \
|
||||||
|
11-join \
|
||||||
|
12-join-main \
|
||||||
|
21-create-many \
|
||||||
|
22-create-many-recursive \
|
||||||
|
23-create-many-once \
|
||||||
|
31-switch-many \
|
||||||
|
32-switch-many-join \
|
||||||
|
33-switch-many-cascade \
|
||||||
|
51-fibonacci \
|
||||||
|
61-mutex \
|
||||||
|
62-mutex \
|
||||||
|
71-preemption \
|
||||||
|
81-deadlock
|
||||||
|
|
||||||
|
bins_target=$(addprefix ${build_dir}/,${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}
|
CFLAGS+=-g -O0 -std=c99 ${includes} -lpthread
|
||||||
LDFLAGS+=
|
LDFLAGS+=
|
||||||
|
|
||||||
srcs+=$(wildcard ${src_dir}/*.c ${src_dir}/**/*.c)
|
srcs+=$(wildcard ${src_dir}/*.c ${src_dir}/**/*.c)
|
||||||
objs+=$(patsubst ${src_dir}/%.c,${build_dir}/%.o,${srcs})
|
objs+=$(patsubst %.c,${build_dir}/%.o,${srcs})
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: build
|
all: build
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: install
|
||||||
build: main
|
install: build
|
||||||
|
true
|
||||||
|
|
||||||
main: ${objs}
|
.PHONY: graphs
|
||||||
|
graphs:
|
||||||
|
true
|
||||||
|
|
||||||
|
.PHONY: valgrind
|
||||||
|
valgrind: build
|
||||||
|
valgrind --leak-check=full --show-reachable=yes --track-origins=yes
|
||||||
|
|
||||||
|
.PHONY: build
|
||||||
|
build: ${bins_target}
|
||||||
|
|
||||||
|
.PHONY: check
|
||||||
|
check:
|
||||||
|
true
|
||||||
|
|
||||||
|
${bins_target}: ${build_dir}/%: ${objs} ${build_dir}/${tst_dir}/%.o
|
||||||
${CC} -o $@ $^ ${CFLAGS} ${LDFLAGS}
|
${CC} -o $@ $^ ${CFLAGS} ${LDFLAGS}
|
||||||
|
|
||||||
${build_dir}/%.o: ${src_dir}/%.c
|
${build_dir}/%.o: %.c
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
${CC} -c -o $@ $^ ${CFLAGS}
|
${CC} -o $@ -c $^ ${CFLAGS}
|
||||||
|
|
||||||
.PHONY: compile_flags.txt
|
.PHONY: compile_flags.txt
|
||||||
compile_flags.txt:
|
compile_flags.txt:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user