Skip to content
Snippets Groups Projects
Commit aa4dcfe7 authored by Mark Winter's avatar Mark Winter
Browse files

Linux initial makefile for hydra image processor.

parent 8bdbcbb4
No related branches found
No related tags found
No related merge requests found
#########################################
# Set these for MATLAB/Python versions
#########################################
MATALAB_DIR = /usr/local/MATLAB/R2017b
# NOTE: Currently only builds against python3
PYTHON_VER = python3.5
PYTHON3_INC = /usr/include/$(PYTHON_VER)/
NUMPY3_INC = /usr/include/$(PYTHON_VER)/
PYTHON_LIB = /usr/lib/$(PYTHON_VER)/config-3.5m-x86_64-linux-gnu
#########################################
# Default files and include dirs
#########################################
CU_FILES := $(wildcard Cuda/*.cu)
CUPP_FILES := $(wildcard Cuda/*.cpp)
MEX_CPP_FILES := $(wildcard Mex/*.cpp)
PY_CPP_FILES := $(wildcard Python/*.cpp)
CUDA_OBJ = $(notdir $(CU_FILES:.cu=.o))
CUDA_CPP_OBJ = $(notdir $(CUPP_FILES:.cpp=.o))
MEX_CPP_OBJ = $(notdir $(MEX_CPP_FILES:.cpp=.o))
PY_CPP_OBJ = $(notdir $(PY_CPP_FILES:.cpp=.o))
CUDA_INC = -I./Cuda
MEX_INC = -I./WrapCmds -I./Mex -I$(MATALAB_DIR)/extern/include
PY_INC = -I./WrapCmds -I./Python -I./Python/py3c -I$(PYTHON3_INC) -I$(NUMPY3_INC)
MEX_LIB = -L$(MATALAB_DIR)/bin/glnxa64/libmx.so -L$(MATALAB_DIR)/bin/glnxa64/libmex.so
PY_LIB = -L$(PYTHON_LIB) -l$(PYTHON_VER)
#########################################
# Common parameters
#########################################
COMPILE_FLAGS = -std=c++11
#########################################
# Nvidia nvcc parameters
#########################################
NVCC_PATH = nvcc
NVCC_FLAGS = $(COMPILE_FLAGS)
SMODEL = -arch=sm_30
NVCC_INC = -I/usr/include
#C_COMPILER = g++
#OMP_LIB = -lgomp
C_COMPILER = clang++
OMP_LIB = -liomp5
#########################################
# gcc/g++/clang parameters
#########################################
GCC_FLAGS = $(COMPILE_FLAGS) -fopenmp -fPIC
GCC_LIBS = $(OMP_LIB)
#########################################
# all projects to build
#########################################
all: matlab python
@echo Finished compiling
python: HIP.so
@echo Finished compiling python wrappers
matlab: Mex.mexa64
@echo Fhinished compiling matlab wrappers
#########################################
# link it all together
#########################################
HIP.so: $(CUDA_OBJ) $(PY_CPP_OBJ) $(CUDA_CPP_OBJ)
$(NVCC_PATH) $(GCC_LIBS) $(PY_LIB) -shared $^ -o HIP.so $(SMODEL) --linker-options '--no-undefined'
Mex.mexa64: $(CUDA_OBJ) $(MEX_CPP_OBJ) $(CUDA_CPP_OBJ)
$(NVCC_PATH) $(GCC_LIB) $(MEX_LIB) -shared $^ -o Mex.mexa64 $(SMODEL) --linker-options '--no-undefined'
#########################################
# compile the cuda library files
#########################################
%.o: Cuda/%.cu
$(NVCC_PATH) $(NVCC_FLAGS) $(SMODEL) --compiler-options '$(GCC_FLAGS)' -c $< -o $@ $(NVCC_INC) -dc
%.o: Cuda/%.cpp
$(C_COMPILER) $(GCC_FLAGS) $(CUDA_INC) -c $< -o $@
#########################################
# compile the mex/python wrappers
#########################################
%.o: Mex/%.cpp
$(C_COMPILER) $(GCC_FLAGS) $(MEX_INC) -c $< -o $@
%.o: Python/%.cpp
$(C_COMPILER) $(GCC_FLAGS) $(PY_INC) -c $< -o $@
#########################################
# files to clean up
#########################################
clean:
@echo Cleaning
rm -f *.o Mex.mexa64 HIP.so
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