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
|
OBJ = $(BUILD_DIR)/main.o
|
||||||
|
|
||||||
LIBS = -L./ -lpthread -ldl -ldw -lunwind -lunwind-x86_64 -lstdc++ -liberty
|
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
|
INCS = -I./include -I./src
|
||||||
FLAGS = -Wall -ggdb -fPIC -O3 -rdynamic -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
|
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)
|
all: $(BIN)
|
||||||
|
|
||||||
$(PST_LIBS):
|
$(LIB_STATIC):
|
||||||
@make -C ./src
|
@make -C ./src
|
||||||
|
|
||||||
clean:
|
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
|
@make clean -C ./src
|
||||||
@if [ -z "$$(ls -A $(BUILD_DIR) 2>&1)" ]; then ${RM} -r $(BUILD_DIR); fi
|
@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
|
@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
|
@if [ ! -e $(RESULT_DIR) ]; then mkdir -vp $(RESULT_DIR); fi
|
||||||
@touch $@
|
@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
|
gcc -ggdb -O3 -o $(BUILD_DIR)/simple ./tests/simple.c
|
||||||
@make -C ./src
|
@make -C ./src
|
||||||
@printf "Create %-60s" $@
|
@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" ]; \
|
if [ $$? -ne "0" ]; \
|
||||||
then echo -e "${RED}[FAILED]${NC}"; echo -e "$$OUT"; \
|
then echo -e "${RED}[FAILED]${NC}"; echo -e "$$OUT"; \
|
||||||
else \
|
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)
|
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 \
|
||||||
|
$(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 $(BUILD_DIR) 2>&1)" ]; then ${RM} -r $(BUILD_DIR); fi
|
||||||
@if [ -z "$$(ls -A $(RESULT_DIR) 2>&1)" ]; then ${RM} -r $(RESULT_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)
|
pst_reg_error pst_get_reg(pst_context* ctx, int regno, uint64_t* regval)
|
||||||
{
|
{
|
||||||
#ifdef USE_LIBUNWIND
|
#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) {
|
switch (ret) {
|
||||||
case UNW_EUNSPEC:
|
case UNW_EUNSPEC:
|
||||||
return REG_CFI_ERROR;
|
return REG_CFI_ERROR;
|
||||||
|
|||||||
+14
-14
@@ -12,12 +12,12 @@ const char * const severity_map[] = {
|
|||||||
" [ERROR] : "
|
" [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);
|
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;
|
time_t rawTime;
|
||||||
struct tm * timeinfo;
|
struct tm * timeinfo;
|
||||||
@@ -29,7 +29,7 @@ void format_prefix(pst_log* log, SC_LogSeverity severity)
|
|||||||
log->mStringLen += strlen(severity_map[(int)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) {
|
if((log->mStringLen + 2) < log->mStringSize) {
|
||||||
log->mString[log->mStringLen++] = '\n';
|
log->mString[log->mStringLen++] = '\n';
|
||||||
@@ -38,7 +38,7 @@ void format_postfix(pst_log* log)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//variable argument number logging
|
//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)
|
if (severity < log->mCurrentSeverity)
|
||||||
return;
|
return;
|
||||||
@@ -61,10 +61,10 @@ void log(pst_log* log, SC_LogSeverity severity, const char* fmt, ...)
|
|||||||
pthread_mutex_unlock(&log->mLock);
|
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
|
// methods
|
||||||
plog->log = log;
|
plog->log = log_base;
|
||||||
|
|
||||||
// fields
|
// fields
|
||||||
plog->mpSource = 0;
|
plog->mpSource = 0;
|
||||||
@@ -99,7 +99,7 @@ void pst_log_fini(pst_log* log)
|
|||||||
#define NC "\e[0m" // No Color
|
#define NC "\e[0m" // No Color
|
||||||
|
|
||||||
//actually sends message to the source
|
//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;
|
const char* color = NC;
|
||||||
switch(severity) {
|
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);
|
fprintf(stderr, "%s%s%s", color, log->mString, NC);
|
||||||
}
|
}
|
||||||
|
|
||||||
void close_console(pst_log* log) {
|
static void close_console(pst_log* log) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
bool open_console(pst_log* log) {
|
static bool open_console(pst_log* log) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_opened_console(pst_log* log) {
|
static bool is_opened_console(pst_log* log) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ typedef struct _file_spec {
|
|||||||
} file_spec;
|
} file_spec;
|
||||||
|
|
||||||
//open file for writing
|
//open file for writing
|
||||||
bool open_file(pst_log* log)
|
static bool open_file(pst_log* log)
|
||||||
{
|
{
|
||||||
file_spec* fsp = (file_spec*)log->child;
|
file_spec* fsp = (file_spec*)log->child;
|
||||||
if(!fsp) {
|
if(!fsp) {
|
||||||
@@ -187,7 +187,7 @@ bool open_file(pst_log* log)
|
|||||||
return (fsp->fd != 0);
|
return (fsp->fd != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void close_file(pst_log* log)
|
static void close_file(pst_log* log)
|
||||||
{
|
{
|
||||||
file_spec* fsp = (file_spec*)log->child;
|
file_spec* fsp = (file_spec*)log->child;
|
||||||
if(!fsp) {
|
if(!fsp) {
|
||||||
@@ -203,7 +203,7 @@ void close_file(pst_log* log)
|
|||||||
fsp->max_bytes = 0;
|
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;
|
file_spec* fsp = (file_spec*)log->child;
|
||||||
if(!fsp) {
|
if(!fsp) {
|
||||||
@@ -213,7 +213,7 @@ int is_file_opened(pst_log* log)
|
|||||||
return (fsp->fd != 0);
|
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;
|
file_spec* fsp = (file_spec*)log->child;
|
||||||
if(!fsp) {
|
if(!fsp) {
|
||||||
|
|||||||
Reference in New Issue
Block a user