From bd87f99863860d25eb5ef167a31832f83ffcf31a Mon Sep 17 00:00:00 2001 From: David Hendriks <davidhendriks93@gmail.com> Date: Mon, 18 Nov 2019 18:10:18 +0000 Subject: [PATCH] removed two of the backup makefiles, changed setup to work with the dirs correctly --- Makefile | 4 ++- new_makefile.make | 65 ----------------------------------------------- old_makefile.make | 36 -------------------------- setup.py | 19 ++++++++------ 4 files changed, 14 insertions(+), 110 deletions(-) delete mode 100644 new_makefile.make delete mode 100644 old_makefile.make diff --git a/Makefile b/Makefile index 705eeab87..9605b9aa6 100644 --- a/Makefile +++ b/Makefile @@ -45,11 +45,12 @@ SO_FLAGS := -shared PY_EXEC := python3 PY_SETUP := setup.py PY_OPTIONS := build_ext --inplace +# maybe pass argument from here to the setup.py? 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) -# $(PY_EXEC) $(PY_SETUP) $(PY_OPTIONS) + $(PY_EXEC) $(PY_SETUP) $(PY_OPTIONS) test: @echo OBJECTS: $(OBJECTS) @@ -60,4 +61,5 @@ test: clean: $(RM) $(OBJ_DIR)/*.o $(TARGET_LIB_DIR)/*.so + $(RM) *.so $(RM) -r build/ \ No newline at end of file diff --git a/new_makefile.make b/new_makefile.make deleted file mode 100644 index c2b69a842..000000000 --- a/new_makefile.make +++ /dev/null @@ -1,65 +0,0 @@ -# Makefile for Rapid Binary Star Evolution program - -# you will need to set the BINARY_C variable to point -# to the root binary_c directory - -# https://stackoverflow.com/questions/30573481/path-include-and-src-directory-makefile/30602701#30602701 -ifeq ($(BINARY_C),) - $(error BINARY_C is not set) -endif - -SRC_DIR := src -OBJ_DIR := obj -INC_DIR := inc -BIN_DIR := bin -TARGET_LIB_DIR := lib - -SRC_FILES := $(wildcard $(SRC_DIR)/binary_c_python_api.c) -OBJ_FILES := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES)) -DEP_FILES := $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.d,$(SRC_FILES)) - -# https://latedev.wordpress.com/2014/12/02/generic-makefiles-with-gcc-and-gnu-make-part-2 - -# SRC = $(wildcard $(SRC_DIR)/binary_c_python_api.c) -# OBJECTS = $(C_SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) - - -# - -CC := gcc -LD := gcc -MAKE := /usr/bin/make - -PROGRAM := binary_c_python_api - -LIBS := -lbinary_c $(shell $(BINARY_C)/binary_c-config --libs) - -# C_SRC := src/binary_c_python_api.c -C_SRC = $(wildcard $(SRC_DIR)/binary_c_python_api.c) -CFLAGS := -fPIC $(shell $(BINARY_C)/binary_c-config --flags | sed s/-fvisibility=hidden// ) -I$(BINARY_C)/src/ -I$(BINARY_C)/src/API -Iinclude - -OBJECTS := $(C_SRC:.c=.o) -OBJ_FLAGS := -c - -SO_FLAGS := -shared -o -SO_NAME := libbinary_c_api.so - -# To create python shared library -PY_EXEC := python3 -PY_SETUP := setup.py -PY_OPTIONS := build_ext --inplace - -# rules -.PHONY: all clean - -# all: $(PROGRAM) -all: $(OBJECTS) - $(CC) -DBINARY_C=$(BINARY_C) $(CFLAGS) $(INCDIRS) $(C_SRC) $(OBJ_FLAGS) $(INCDIRS) $(LIBS) - - # Make shared lib - $(CC) -DBINARY_C=$(BINARY_C) $(SO_FLAGS) $(SO_NAME) $(OBJECTS) - $(PY_EXEC) $(PY_SETUP) $(PY_OPTIONS) - -clean: - $(RM) *.o *.so - $(RM) build/ diff --git a/old_makefile.make b/old_makefile.make deleted file mode 100644 index cf04166a2..000000000 --- a/old_makefile.make +++ /dev/null @@ -1,36 +0,0 @@ -# Makefile for Rapid Binary Star Evolution program - -# you will need to set the BINARY_C variable to point -# to the root binary_c directory -ifeq ($(BINARY_C),) - $(error BINARY_C is not set) -endif - - -CC := gcc -LD := gcc -PROGRAM := binary_c_python_api -MAKE := /usr/bin/make -LIBS := -lbinary_c $(shell $(BINARY_C)/binary_c-config --libs) -#`$(BINARY_C)/binary_c-config --libdirs_list` -C_SRC := binary_c_python_api.c -OBJECTS := $(C_SRC:.c=.o) -OBJ_FLAGS := -c -CFLAGS := -fPIC $(shell $(BINARY_C)/binary_c-config --flags | sed s/-fvisibility=hidden// ) -I$(BINARY_C)/src/ -I$(BINARY_C)/src/API -SO_FLAGS := -shared -o -SO_NAME := libbinary_c_api.so - -# To create python shared library -PY_EXEC := python3 -PY_SETUP := setup.py -PY_OPTIONS := build_ext --inplace - -all: $(OBJECTS) - $(CC) -DBINARY_C=$(BINARY_C) $(CFLAGS) $(INCDIRS) $(C_SRC) $(OBJ_FLAGS) $(INCDIRS) $(LIBS) - $(CC) -DBINARY_C=$(BINARY_C) $(SO_FLAGS) $(SO_NAME) $(OBJECTS) - $(PY_EXEC) $(PY_SETUP) $(PY_OPTIONS) - -clean: - rm -f *.o *.so - rm -rf build/ - diff --git a/setup.py b/setup.py index c955c7583..d6410614c 100644 --- a/setup.py +++ b/setup.py @@ -4,8 +4,10 @@ import subprocess import re import sys -# binary_c must be installed. +# TODO: write code to know exact parent directory of this file. +CWD = os.getcwd() +# binary_c must be installed. binary_c_config = os.environ["BINARY_C"] + "/binary_c-config" binary_c_incdirs = ( @@ -62,17 +64,18 @@ setup( ext_modules=[ Extension( "binary_c", - ["binary_c_python.c"], - libraries=["binary_c"] + binary_c_libs + ["binary_c_api"], + ["src/binary_c_python.c"], include_dirs=[ os.environ["BINARY_C"] + "/src", os.environ["BINARY_C"] + "/src/API", 'include', - ] - + binary_c_incdirs, - library_dirs=[os.environ["BINARY_C"] + "/src", "./"] + binary_c_libdirs, - runtime_library_dirs=[os.environ["BINARY_C"] + "/src", "./"] - + binary_c_libdirs, + ] + binary_c_incdirs, + libraries= + ["binary_c"] + binary_c_libs + ["binary_c_api"], + library_dirs= + [os.environ["BINARY_C"] + "/src", "./", os.path.join(CWD,'lib/')] + binary_c_libdirs, + runtime_library_dirs= + [os.environ["BINARY_C"] + "/src", "./", os.path.join(CWD,'lib/')] + binary_c_libdirs, define_macros=[] + binary_c_define_macros, extra_objects=[], extra_compile_args=[], -- GitLab