feat: add lib compilation to makefile
This commit is contained in:
parent
e61a82c617
commit
eba22fb721
20
Makefile
20
Makefile
@ -32,7 +32,7 @@ check_targets=$(addprefix check_,${bins})
|
||||
src_dirs=$(sort $(dir $(wildcard ${src_dir}/**/)))
|
||||
includes=$(patsubst %,-I%,${src_dirs})
|
||||
|
||||
CFLAGS+=-g -O0 -std=c99 ${includes}
|
||||
CFLAGS+=-g -O0 ${includes} -fPIC
|
||||
LDFLAGS+=
|
||||
ifdef _USE_PTHREAD
|
||||
LDFLAGS+=-lpthread
|
||||
@ -55,7 +55,15 @@ all: ${all_targets}
|
||||
${RM} .lastpthread # Set that the last build was without pthread
|
||||
|
||||
.PHONY: install
|
||||
install: build ${install_bins_targets}
|
||||
install: build ${install_bins_targets} ${install_dir}/lib/libthread.so ${install_dir}/lib/libthread.a
|
||||
|
||||
${install_dir}/lib/libthread.so: ${build_dir}/libthread.so
|
||||
@mkdir -p $(dir $@)
|
||||
cp $^ $@
|
||||
|
||||
${install_dir}/lib/libthread.a: ${build_dir}/libthread.a
|
||||
@mkdir -p $(dir $@)
|
||||
cp $^ $@
|
||||
|
||||
${install_bins_targets}: ${install_dir}/bin/%: ${build_dir}/%
|
||||
@mkdir -p $(dir $@)
|
||||
@ -73,7 +81,7 @@ ${valgrind_targets}: valgrind_%: ${build_dir}/%
|
||||
valgrind $^ --leak-check=full --show-reachable=yes --track-origins=yes
|
||||
|
||||
.PHONY: build
|
||||
build: ${bins_target}
|
||||
build: ${bins_target} ${build_dir}/libthread.so ${build_dir}/libthread.a
|
||||
|
||||
.PHONY: pthreads
|
||||
pthreads:
|
||||
@ -90,6 +98,12 @@ ${check_targets}: check_%: ${build_dir}/%
|
||||
${bins_target}: ${build_dir}/%: ${objs} ${build_dir}/${tst_dir}/%.o
|
||||
${CC} -o $@ $^ ${CFLAGS} ${LDFLAGS}
|
||||
|
||||
${build_dir}/libthread.so: ${objs}
|
||||
${CC} -o $@ -shared $^ ${CFLAGS} ${LDFLAGS}
|
||||
|
||||
${build_dir}/libthread.a: ${objs}
|
||||
ar rcs $@ $^
|
||||
|
||||
${build_dir}/%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
${CC} -o $@ -c $^ ${CFLAGS}
|
||||
|
Loading…
x
Reference in New Issue
Block a user