From f3cf660cc15dd2e7fc1308798acab9de4f7c0b60 Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Mon, 18 Nov 2019 17:50:40 +0000 Subject: [PATCH] cleaning up the makefile --- Makefile | 55 ++++++++++++++++++++++++++++++++---------------------- src/test.c | 0 2 files changed, 33 insertions(+), 22 deletions(-) delete mode 100644 src/test.c diff --git a/Makefile b/Makefile index 9bf56800e..d6f8e8030 100644 --- a/Makefile +++ b/Makefile @@ -6,49 +6,58 @@ ifeq ($(BINARY_C),) $(error BINARY_C is not set) endif +# TODO: Create the directories if they dont exist. + + # Name of program -PROGRAM := binary_c_python_api +PROGRAM := binary_c_python_api -SRC_DIR := src -OBJ_DIR := obj -INC_DIR := include +# Some directories +SRC_DIR := src +INC_DIR := include +OBJ_DIR := obj +TARGET_LIB_DIR := lib # some commands -CC := gcc -LD := gcc -MAKE := /usr/bin/make +CC := gcc +LD := gcc +MAKE := /usr/bin/make # Libraries -LIBS := -lbinary_c $(shell $(BINARY_C)/binary_c-config --libs) +LIBS := -lbinary_c $(shell $(BINARY_C)/binary_c-config --libs) # Source files and cflags -C_SRC := binary_c_python_api.c -CFLAGS := -fPIC $(shell $(BINARY_C)/binary_c-config --flags | sed s/-fvisibility=hidden// ) -C_SRC_NEW := src/binary_c_python_api.c +# C_SRC := binary_c_python_api.c +C_SRC := $(SRC_DIR)/binary_c_python_api.c +CFLAGS := -fPIC $(shell $(BINARY_C)/binary_c-config --flags | sed s/-fvisibility=hidden// ) +# C_SRC_NEW := $(SRC_DIR)/binary_c_python_api.c # SRC = $(wildcard $(SRC_DIR)/binary_c_python_api.c) # Incdirs -INCDIRS := -I$(BINARY_C)/src/ -I$(BINARY_C)/src/API -I$(INC_DIR)/ +INCDIRS := -I$(BINARY_C)/src/ -I$(BINARY_C)/src/API -I$(INC_DIR)/ # Object files and flags -OBJECTS := $(C_SRC:.c=.o) -OBJ_FLAGS := -c -OBJ_NEW := $(C_SRC_NEW:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) +# OBJECTS := $(C_SRC:.c=.o) +OBJECTS := $(C_SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) +OBJ_FLAGS := -c +# OBJ_NEW := $(C_SRC_NEW:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) # Shared lib files and flags -SO_NAME := libbinary_c_api.so -SO_FLAGS := -shared +SO_NAME := $(TARGET_LIB_DIR)/libbinary_c_api.so +SO_FLAGS := -shared # To create python shared library -PY_EXEC := python3 -PY_SETUP := setup.py -PY_OPTIONS := build_ext --inplace +PY_EXEC := python3 +PY_SETUP := setup.py +PY_OPTIONS := build_ext --inplace all: +# $(CC) -DBINARY_C=$(BINARY_C) $(CFLAGS) $(INCDIRS) $(C_SRC) -o $(OBJECTS) $(OBJ_FLAGS) $(LIBS) +# $(CC) -DBINARY_C=$(BINARY_C) $(SO_FLAGS) -o $(SO_NAME) $(OBJECTS) + $(CC) -DBINARY_C=$(BINARY_C) $(CFLAGS) $(INCDIRS) $(C_SRC) -o $(OBJECTS) $(OBJ_FLAGS) $(LIBS) $(CC) -DBINARY_C=$(BINARY_C) $(SO_FLAGS) -o $(SO_NAME) $(OBJECTS) # $(PY_EXEC) $(PY_SETUP) $(PY_OPTIONS) - test: @echo Objects: $(OBJECTS) @echo Libs: $(LIBS) @@ -56,7 +65,9 @@ test: @echo CFLAGS: $(CFLAGS) @echo INCDIRS: $(INCDIRS) @echo OBJS_NEW: $(OBJ_NEW) + @echo SRC_NEW: $(C_SRC_NEW) + clean: - $(RM) -f *.o *.so + $(RM) obj/*.o *.so $(RM) -r build/ \ No newline at end of file diff --git a/src/test.c b/src/test.c deleted file mode 100644 index e69de29bb..000000000 -- GitLab