build shared version of the library

This commit is contained in:
2020-02-05 12:23:47 +04:00
parent 24efc4580b
commit 064951f4c8
2 changed files with 20 additions and 6 deletions
+6 -4
View File
@@ -1,12 +1,14 @@
/* /*
* sysutils.h * libpst.h
*
* External interface to libpst
* *
* Created on: Dec 28, 2019 * Created on: Dec 28, 2019
* Author: nnosov * Author: nnosov
*/ */
#ifndef PST_HANDLER_H_ #ifndef __LIBPST_EXTERNAL_H_
#define PST_HANDLER_H_ #define __LIBPST_EXTERNAL_H_
//system //system
#include <ucontext.h> #include <ucontext.h>
@@ -45,4 +47,4 @@ int pst_unwind_pretty(pst_handler* h, FILE* fd);
// save stack trace information to provided buffer in RAM // save stack trace information to provided buffer in RAM
int pst_unwind_pretty(pst_handler* h, char* buff, uint32_t buff_size); int pst_unwind_pretty(pst_handler* h, char* buff, uint32_t buff_size);
#endif /* PST_HANDLER_H_ */ #endif /* __LIBPST_EXTERNAL_H_ */
+14 -2
View File
@@ -24,6 +24,7 @@ AR = ar rvs
BUILD_DIR = ./build BUILD_DIR = ./build
RESULT_DIR = ../build RESULT_DIR = ../build
LIB_STATIC = $(RESULT_DIR)/libpst.a LIB_STATIC = $(RESULT_DIR)/libpst.a
LIB_SHARED = $(RESULT_DIR)/libpst.so
#Software LABEL, BUILD number, and DATE of build #Software LABEL, BUILD number, and DATE of build
$(shell mkdir -p ${BUILD_DIR}) $(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 .PHONY: all clean
all: $(LIB_STATIC) all: $(LIB_STATIC) $(LIB_SHARED)
clean: clean:
${RM} $(BUILD_DIR)/*.o $(BUILD_DIR)/*.dep $(BIN) $(LIB_STATIC) $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(BUILD_DIR)/version.h ${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 #create dependencies
@$(CXX) -MM -MT '$@' -c $< > $@.dep $(FLAGS) $(INCS) @$(CXX) -MM -MT '$@' -c $< > $@.dep $(FLAGS) $(INCS)
#create library #create static library
$(LIB_STATIC): $(RESULT_DIR)/prepare.res $(BUILD_DIR)/prepare.bld $(OBJ) $(LIB_STATIC): $(RESULT_DIR)/prepare.res $(BUILD_DIR)/prepare.bld $(OBJ)
@rm -fv $@ @rm -fv $@
@printf "Create %-60s" $@ @printf "Create %-60s" $@
@@ -83,6 +84,17 @@ $(LIB_STATIC): $(RESULT_DIR)/prepare.res $(BUILD_DIR)/prepare.bld $(OBJ)
echo -e "${GREEN}[DONE]${NC}"; \ echo -e "${GREEN}[DONE]${NC}"; \
fi 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 #include dependencies for track changes in sourcecode and related header files
DEPEND := $(OBJ:.o=.o.dep) DEPEND := $(OBJ:.o=.o.dep)
-include $(DEPEND) -include $(DEPEND)