From 064951f4c84dc9116a749ace4c3fa2c8c272a883 Mon Sep 17 00:00:00 2001 From: Nikolai Nosov Date: Wed, 5 Feb 2020 12:23:47 +0400 Subject: [PATCH] build shared version of the library --- include/libpst.h | 10 ++++++---- src/Makefile | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/include/libpst.h b/include/libpst.h index 00a7850..f53eb55 100644 --- a/include/libpst.h +++ b/include/libpst.h @@ -1,12 +1,14 @@ /* - * sysutils.h + * libpst.h + * + * External interface to libpst * * Created on: Dec 28, 2019 * Author: nnosov */ -#ifndef PST_HANDLER_H_ -#define PST_HANDLER_H_ +#ifndef __LIBPST_EXTERNAL_H_ +#define __LIBPST_EXTERNAL_H_ //system #include @@ -45,4 +47,4 @@ int pst_unwind_pretty(pst_handler* h, FILE* fd); // save stack trace information to provided buffer in RAM int pst_unwind_pretty(pst_handler* h, char* buff, uint32_t buff_size); -#endif /* PST_HANDLER_H_ */ +#endif /* __LIBPST_EXTERNAL_H_ */ diff --git a/src/Makefile b/src/Makefile index 9366dd5..6b95495 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,6 +24,7 @@ AR = ar rvs BUILD_DIR = ./build RESULT_DIR = ../build LIB_STATIC = $(RESULT_DIR)/libpst.a +LIB_SHARED = $(RESULT_DIR)/libpst.so #Software LABEL, BUILD number, and DATE of build $(shell mkdir -p ${BUILD_DIR}) @@ -41,7 +42,7 @@ FLAGS = -Wall -ggdb -fPIC -O3 -rdynamic -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_M .PHONY: all clean -all: $(LIB_STATIC) +all: $(LIB_STATIC) $(LIB_SHARED) clean: ${RM} $(BUILD_DIR)/*.o $(BUILD_DIR)/*.dep $(BIN) $(LIB_STATIC) $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(BUILD_DIR)/version.h @@ -72,7 +73,7 @@ $(BUILD_DIR)/%.o: %.cpp #create dependencies @$(CXX) -MM -MT '$@' -c $< > $@.dep $(FLAGS) $(INCS) -#create library +#create static library $(LIB_STATIC): $(RESULT_DIR)/prepare.res $(BUILD_DIR)/prepare.bld $(OBJ) @rm -fv $@ @printf "Create %-60s" $@ @@ -83,6 +84,17 @@ $(LIB_STATIC): $(RESULT_DIR)/prepare.res $(BUILD_DIR)/prepare.bld $(OBJ) echo -e "${GREEN}[DONE]${NC}"; \ fi +#create shared library +$(LIB_SHARED): $(RESULT_DIR)/prepare.res $(BUILD_DIR)/prepare.bld $(OBJ) + @rm -fv $@ + @printf "Create %-60s" $@ + @OUT=$$($(CC) -shared $(OBJ) -o $@ 2>&1); \ + if [ $$? -ne "0" ]; \ + then echo -e "${RED}[FAILED]${NC}"; echo -e "$$OUT"; \ + else \ + echo -e "${GREEN}[DONE]${NC}"; \ + fi + #include dependencies for track changes in sourcecode and related header files DEPEND := $(OBJ:.o=.o.dep) -include $(DEPEND)