fix Makefile clean, fix compilation warnings
This commit is contained in:
@@ -50,7 +50,8 @@ SRC = $(shell find . -name '*.c')
|
||||
OBJ = $(BUILD_DIR)/main.o
|
||||
|
||||
LIBS = -L./ -lpthread -ldl -ldw -lunwind -lunwind-x86_64 -lstdc++ -liberty
|
||||
PST_LIBS = ./build/libpst.a
|
||||
LIB_STATIC = $(RESULT_DIR)/libpst.a
|
||||
LIB_DYNAMIC = $(RESULT_DIR)/libpst.so
|
||||
|
||||
INCS = -I./include -I./src
|
||||
FLAGS = -Wall -ggdb -fPIC -O3 -rdynamic -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
|
||||
@@ -60,11 +61,12 @@ FLAGS = -Wall -ggdb -fPIC -O3 -rdynamic -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_M
|
||||
|
||||
all: $(BIN)
|
||||
|
||||
$(PST_LIBS):
|
||||
$(LIB_STATIC):
|
||||
@make -C ./src
|
||||
|
||||
clean:
|
||||
${RM} $(BUILD_DIR)/*.o $(BUILD_DIR)/*.dep $(BIN) $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(BUILD_DIR)/version.h
|
||||
${RM} $(BUILD_DIR)/*.o $(BUILD_DIR)/*.dep $(BIN) $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(BUILD_DIR)/version.h \
|
||||
$(LIB_STATIC) $(LIB_DYNAMIC)
|
||||
@make clean -C ./src
|
||||
@if [ -z "$$(ls -A $(BUILD_DIR) 2>&1)" ]; then ${RM} -r $(BUILD_DIR); fi
|
||||
@if [ -z "$$(ls -A $(RESULT_DIR) 2>&1)" ]; then ${RM} -r $(RESULT_DIR); fi
|
||||
@@ -77,11 +79,11 @@ $(RESULT_DIR)/prepare.res:
|
||||
@if [ ! -e $(RESULT_DIR) ]; then mkdir -vp $(RESULT_DIR); fi
|
||||
@touch $@
|
||||
|
||||
$(BIN): $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(OBJ) $(PST_LIBS)
|
||||
$(BIN): $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(OBJ) $(LIB_STATIC)
|
||||
gcc -ggdb -O3 -o $(BUILD_DIR)/simple ./tests/simple.c
|
||||
@make -C ./src
|
||||
@printf "Create %-60s" $@
|
||||
@OUT=$$($(CXX) $(COLOR) -o $@ $(OBJ) $(PST_LIBS) $(LIBS) 2>&1); \
|
||||
@OUT=$$($(CXX) $(COLOR) -o $@ $(OBJ) $(LIB_STATIC) $(LIBS) 2>&1); \
|
||||
if [ $$? -ne "0" ]; \
|
||||
then echo -e "${RED}[FAILED]${NC}"; echo -e "$$OUT"; \
|
||||
else \
|
||||
|
||||
+2
-1
@@ -45,7 +45,8 @@ FLAGS = -Wall -ggdb -fPIC -O3 -rdynamic -D_GNU_SOURCE -D__STDC_FORMAT_MACROS -D
|
||||
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
|
||||
${RM} $(BUILD_DIR)/*.o $(BUILD_DIR)/*.dep $(BIN) $(LIB_STATIC) $(BUILD_DIR)/prepare.bld $(RESULT_DIR)/prepare.res $(BUILD_DIR)/version.h \
|
||||
$(LIB_STATIC) $(LIB_DYNAMIC) $(RESULT_DIR)/simple
|
||||
@if [ -z "$$(ls -A $(BUILD_DIR) 2>&1)" ]; then ${RM} -r $(BUILD_DIR); fi
|
||||
@if [ -z "$$(ls -A $(RESULT_DIR) 2>&1)" ]; then ${RM} -r $(RESULT_DIR); fi
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ int find_regnum(uint32_t op)
|
||||
pst_reg_error pst_get_reg(pst_context* ctx, int regno, uint64_t* regval)
|
||||
{
|
||||
#ifdef USE_LIBUNWIND
|
||||
int ret = unw_get_reg(ctx->curr_frame, regno, ®val);
|
||||
int ret = unw_get_reg(ctx->curr_frame, regno, regval);
|
||||
switch (ret) {
|
||||
case UNW_EUNSPEC:
|
||||
return REG_CFI_ERROR;
|
||||
|
||||
+14
-14
@@ -12,12 +12,12 @@ const char * const severity_map[] = {
|
||||
" [ERROR] : "
|
||||
};
|
||||
|
||||
void format_string(pst_log* log, const char* fmt, va_list args)
|
||||
static void format_string(pst_log* log, const char* fmt, va_list args)
|
||||
{
|
||||
log->mStringLen += vsnprintf(log->mString + log->mStringLen, log->mStringSize - log->mStringLen, fmt, args);
|
||||
}
|
||||
|
||||
void format_prefix(pst_log* log, SC_LogSeverity severity)
|
||||
static void format_prefix(pst_log* log, SC_LogSeverity severity)
|
||||
{
|
||||
time_t rawTime;
|
||||
struct tm * timeinfo;
|
||||
@@ -29,7 +29,7 @@ void format_prefix(pst_log* log, SC_LogSeverity severity)
|
||||
log->mStringLen += strlen(severity_map[(int)severity]);
|
||||
}
|
||||
|
||||
void format_postfix(pst_log* log)
|
||||
static void format_postfix(pst_log* log)
|
||||
{
|
||||
if((log->mStringLen + 2) < log->mStringSize) {
|
||||
log->mString[log->mStringLen++] = '\n';
|
||||
@@ -38,7 +38,7 @@ void format_postfix(pst_log* log)
|
||||
}
|
||||
|
||||
//variable argument number logging
|
||||
void log(pst_log* log, SC_LogSeverity severity, const char* fmt, ...)
|
||||
static void log_base(pst_log* log, SC_LogSeverity severity, const char* fmt, ...)
|
||||
{
|
||||
if (severity < log->mCurrentSeverity)
|
||||
return;
|
||||
@@ -61,10 +61,10 @@ void log(pst_log* log, SC_LogSeverity severity, const char* fmt, ...)
|
||||
pthread_mutex_unlock(&log->mLock);
|
||||
}
|
||||
|
||||
void log_init_base(pst_log* plog, const char* source)
|
||||
static void log_init_base(pst_log* plog, const char* source)
|
||||
{
|
||||
// methods
|
||||
plog->log = log;
|
||||
plog->log = log_base;
|
||||
|
||||
// fields
|
||||
plog->mpSource = 0;
|
||||
@@ -99,7 +99,7 @@ void pst_log_fini(pst_log* log)
|
||||
#define NC "\e[0m" // No Color
|
||||
|
||||
//actually sends message to the source
|
||||
void send_msg_console(pst_log* log, SC_LogSeverity severity)
|
||||
static void send_msg_console(pst_log* log, SC_LogSeverity severity)
|
||||
{
|
||||
const char* color = NC;
|
||||
switch(severity) {
|
||||
@@ -123,15 +123,15 @@ void send_msg_console(pst_log* log, SC_LogSeverity severity)
|
||||
fprintf(stderr, "%s%s%s", color, log->mString, NC);
|
||||
}
|
||||
|
||||
void close_console(pst_log* log) {
|
||||
static void close_console(pst_log* log) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
bool open_console(pst_log* log) {
|
||||
static bool open_console(pst_log* log) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool is_opened_console(pst_log* log) {
|
||||
static bool is_opened_console(pst_log* log) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ typedef struct _file_spec {
|
||||
} file_spec;
|
||||
|
||||
//open file for writing
|
||||
bool open_file(pst_log* log)
|
||||
static bool open_file(pst_log* log)
|
||||
{
|
||||
file_spec* fsp = (file_spec*)log->child;
|
||||
if(!fsp) {
|
||||
@@ -187,7 +187,7 @@ bool open_file(pst_log* log)
|
||||
return (fsp->fd != 0);
|
||||
}
|
||||
|
||||
void close_file(pst_log* log)
|
||||
static void close_file(pst_log* log)
|
||||
{
|
||||
file_spec* fsp = (file_spec*)log->child;
|
||||
if(!fsp) {
|
||||
@@ -203,7 +203,7 @@ void close_file(pst_log* log)
|
||||
fsp->max_bytes = 0;
|
||||
}
|
||||
|
||||
int is_file_opened(pst_log* log)
|
||||
static bool is_file_opened(pst_log* log)
|
||||
{
|
||||
file_spec* fsp = (file_spec*)log->child;
|
||||
if(!fsp) {
|
||||
@@ -213,7 +213,7 @@ int is_file_opened(pst_log* log)
|
||||
return (fsp->fd != 0);
|
||||
}
|
||||
|
||||
void send_msg_file(pst_log* log, SC_LogSeverity severity)
|
||||
static void send_msg_file(pst_log* log, SC_LogSeverity severity)
|
||||
{
|
||||
file_spec* fsp = (file_spec*)log->child;
|
||||
if(!fsp) {
|
||||
|
||||
Reference in New Issue
Block a user