Skip to content

Commit

Permalink
Cleaned up build process.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencwilliams committed Jan 17, 2012
1 parent f58f23d commit 2b317ef
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 43 deletions.
24 changes: 11 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# TODO: -arch doesn't work anymore?
# TODO: -m32 needed on 64-bit machines, otherwise SWIG won't work?

CXXFLAGS = -Wall
# OUTPUT_OPTION = -o .obj/$@
swig_flags = -Wall -c++ -python -outputtuple
objects = assortativity.o \
object_dir = .obj
object_filenames = assortativity.o \
betweenness_bin.o \
betweenness_wei.o \
breadth.o \
Expand Down Expand Up @@ -80,29 +77,30 @@ objects = assortativity.o \
threshold_absolute.o \
threshold_proportional.o \
utility.o
objects = $(addprefix $(object_dir)/, $(object_filenames))

include Makefile.vars

# To make a multi-architecture library:
# Compile once for each architecture by adding -arch to CXXFLAGS and LDFLAGS during compilation
# Then execute "lipo -create <architecture-specific libraries> -output <universal library>"

.PHONY: all clean install swig uninstall

all: libbct.a

libbct.a: $(objects)
$(AR) rcs libbct.a $(objects)
$(AR) rcs libbct.a $^

swig: $(objects)
swig $(swig_flags) -o bct_gsl_wrap.cpp bct_gsl.i
swig $(swig_flags) -o bct_py_wrap.cpp bct_py.i
$(CXX) $(CXXFLAGS) -c -I$(python_dir) bct_gsl_wrap.cpp
$(CXX) $(CXXFLAGS) -c -I$(python_dir) bct_py_wrap.cpp
$(CXX) $(CXXFLAGS) -lgsl -lgslcblas $(swig_lib_flags) -o _bct_gsl.so $(objects) bct_gsl_wrap.o
$(CXX) $(CXXFLAGS) -lgsl -lgslcblas $(swig_lib_flags) -o _bct_py.so $(objects) bct_py_wrap.o
$(CXX) $(CXXFLAGS) -lgsl -lgslcblas $(swig_lib_flags) -o _bct_gsl.so $^ bct_gsl_wrap.o
$(CXX) $(CXXFLAGS) -lgsl -lgslcblas $(swig_lib_flags) -o _bct_py.so $^ bct_py_wrap.o

$(object_dir)/%.o: %.cpp bct.h matlab/matlab.h
$(CXX) $(CXXFLAGS) -c -o $@ $<

$(objects): matlab/matlab.h bct.h
$(object_dir)/matlab/%.o: matlab/%.cpp matlab/matlab.h
$(CXX) $(CXXFLAGS) -c -o $@ $<

install: libbct.a
if [ ! -d $(install_dir)/include/bct ]; then \
Expand Down
25 changes: 3 additions & 22 deletions Makefile.vars-template
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
# Arguments to be sent to the C++ compiler
# Some arguments may already be specified in Makefile
# To compile with float precision, replace "-DGSL_DOUBLE" with "-DGSL_FLOAT"
# To compile with long double precision, replace "-DGSL_DOUBLE" with "-DGSL_LONG_DOUBLE"
# WARNING: SWIG wrappers are only set up to work with double precision
# To enable parallel processing with OpenMP, add "-fopenmp"
# To build for a particular architecture, add "-arch <arch>" (e.g., "-arch i386")
# On Linux, "-fPIC" may be required?
CXXFLAGS += -DGSL_DOUBLE
# See the bct-cpp user's guide for help with this file:
# http://code.google.com/p/bct-cpp/wiki/UsersGuide

# Installation directory
CXXFLAGS += -DGSL_DOUBLE
install_dir = /usr/local

# The following variables are only needed for SWIG
# If you aren't generating Python bindings, you don't need to worry about them

# Typical values for python_dir in different environments
python_dir_apple = /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6
python_dir_linux = /usr/include/python2.6

# Python header file directory
# This is the location of the C++ header files required to build Python bindings
# You may be able to use one of the previously defined variables
# E.g., python_dir = $(python_dir_apple)
python_dir =

# Typical values for swig_lib_flags in different environments
swig_lib_flags_apple = -bundle -flat_namespace -undefined suppress
swig_lib_flags_linux = -shared

# Arguments for generating a shared library from SWIG wrappers
# You may be able to use one of the previously defined variables
# E.g., swig_lib_flags = $(swig_lib_flags_apple)
# On Linux, "-lpython2.6" may be required?
swig_lib_flags =
25 changes: 17 additions & 8 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,32 @@ filenames = assortativity_dir_cpp \
threshold_absolute_cpp \
threshold_proportional_dir_cpp \
threshold_proportional_und_cpp
objects := $(foreach f, $(filenames), $(f).o)
oct_files := $(foreach f, $(filenames), $(f).oct)
objects = $(addsuffix .o, $(filenames))
oct_files = $(addsuffix .oct, $(filenames))
m_files = bct_test.m \
bct_test_all.m
bct_test_all.m \
bct_test_centrality.m \
bct_test_clustering.m \
bct_test_degree.m \
bct_test_distance.m \
bct_test_modularity.m \
bct_test_motifs.m \
bct_test_random.m \
bct_test_setup.m \
bct_test_synthetic.m \
bct_test_teardown.m \
bct_test_utility.m

include ../Makefile.vars

.PHONY: all clean install uninstall

all: $(oct_files)

.SECONDEXPANSION:
%.oct: %.cpp bct_test.h bct_test.cpp
mkoctfile -Wall -lbct -lgsl -lgslcblas -o $@ $<

$(oct_files): bct_test.h bct_test.cpp $$(basename $$@).cpp
mkoctfile -Wall -lbct -lgsl -lgslcblas $(basename $@).cpp

install:
install: $(oct_files) $(m_files)
if [ ! -d $(install_dir)/share/bct ]; then \
mkdir $(install_dir)/share/bct; \
fi
Expand Down

0 comments on commit 2b317ef

Please sign in to comment.