Skip to content
Snippets Groups Projects
Commit bd87f998 authored by David Hendriks's avatar David Hendriks
Browse files

removed two of the backup makefiles, changed setup to work with the dirs correctly

parent 4e81dc49
No related branches found
No related tags found
No related merge requests found
......@@ -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
# 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/
# 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/
......@@ -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=[],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment