Commit fea082e4 authored by Christian Kastner's avatar Christian Kastner

patches: Extend 0001-Properly-build-shared-and-static-libraries-programs

parent 2a6ccd34
......@@ -4,19 +4,20 @@ Subject: Properly build shared and static libraries, programs
Modify upstream's Makefile to 1) properly build shared and static libraries,
2) link upstream's programs to the shared libraries and 3) build Python
extensions for all supported Python versions.
extensions for all supported Python versions. Furthermore, add an install
target.
Forwarded: not-needed
Last-Update: 2014-02-21
Last-Update: 2014-07-26
---
Makefile | 114 ++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 62 insertions(+), 52 deletions(-)
Makefile | 128 +++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 75 insertions(+), 53 deletions(-)
diff --git a/Makefile b/Makefile
index 69b725b..ca04913 100644
index 69b725b..df1b22d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,33 @@
@@ -1,16 +1,38 @@
-#
-# Choose your compiler
-#
......@@ -30,6 +31,10 @@ index 69b725b..ca04913 100644
+CFLAGS +=
+LDFLAGS +=
+LIBS +=
+
+LIB_CFLAGS = $(CFLAGS) -fPIC
+LIB_LDFLAGS = $(LDFLAGS)
+LIB_LIBS = $(LIBS)
-#CC = gcc-4.2
-#CPP = g++-4.2
......@@ -39,10 +44,6 @@ index 69b725b..ca04913 100644
-CFLAGS=-O3 -ffast-math -fomit-frame-pointer -fPIC -Werror
-#CC=/agbs/share/sw/icc/bin/icc
-#CFLAGS= -fast -DCOMPILE_WITH_ICC -Werror
+LIB_CFLAGS = $(CFLAGS) -fPIC
+LIB_LDFLAGS = $(LDFLAGS)
+LIB_LIBS = $(LIBS)
+
+PROG_CFLAGS = $(CFLAGS)
+PROG_LDFLAGS = $(LDFLAGS) -L. -Wl,--as-needed
+PROG_LIBS = $(LIBS) -lmpikmeans -lboost_system -lboost_program_options -lboost_filesystem
......@@ -52,6 +53,11 @@ index 69b725b..ca04913 100644
+LVER ?= 0
+LSUBVER ?= 0
+LIBFILE = libmpikmeans.so.$(LVER).$(LSUBVER)
+
+bindir ?= /usr/bin/
+libdir ?= /usr/lib/
+bindest = $(DESTDIR)$(bindir)
+libdest = $(DESTDIR)$(libdir)
+
+# Without PYVER present, use the default Python version.
+#
......@@ -62,7 +68,7 @@ index 69b725b..ca04913 100644
#
# MPI KMEANS FLAGS
@@ -25,19 +42,6 @@ MATLABDIR=/agbs/share/sw/matlab
@@ -25,19 +47,6 @@ MATLABDIR=/agbs/share/sw/matlab
MATLAB_INCLUDE=-I$(MATLABDIR)/extern/include
#
......@@ -82,24 +88,24 @@ index 69b725b..ca04913 100644
# ARCHITECURE
#
@@ -49,34 +53,31 @@ MATLAB_LIB=-L$(MATLABDIR)/bin/glnx86 -lmex
@@ -49,34 +58,31 @@ MATLAB_LIB=-L$(MATLABDIR)/bin/glnx86 -lmex
#SUFFIX=mexa64
#MATLAB_LIB=-L$(MATLABDIR)/bin/glnxa64 -lmex
-LIBS=/usr/lib/gcc/i486-linux-gnu/4.1/libstdc++.a /usr/lib/libm.a
-
-all: standalone matlab libmpikmeans python
-matlab: mpi_kmeans_mex.$(SUFFIX) mpi_assign_mex.$(SUFFIX)
-standalone: mpi_kmeans_main mpi_assign_main
-python: cython_wrapper
-mpi_kmeans.o: mpi_kmeans.cxx mpi_kmeans.h
- $(CC) $(CFLAGS) $(VERBOSEFLAG) $(PRECISION) -c -o $@ mpi_kmeans.cxx
+all: lib standalone python
+lib: $(LIBFILE) libmpikmeans.a
+standalone: mpi_kmeans mpi_assign
+python: cython_wrapper
-mpi_kmeans.o: mpi_kmeans.cxx mpi_kmeans.h
- $(CC) $(CFLAGS) $(VERBOSEFLAG) $(PRECISION) -c -o $@ mpi_kmeans.cxx
-
-libmpikmeans: mpi_kmeans.o
- ar rc libmpikmeans.a mpi_kmeans.o
- ranlib libmpikmeans.a
......@@ -136,7 +142,7 @@ index 69b725b..ca04913 100644
%_mex.o: %_mex.cxx
$(CC) $(CFLAGS) $(MATLAB_INCLUDE) $(VERBOSEFLAG) $(PRECISION) -c $^ -o $@
@@ -87,18 +88,27 @@ mpi_kmeans_mex.$(SUFFIX): libmpikmeans mpi_kmeans_mex.o
@@ -87,18 +93,34 @@ mpi_kmeans_mex.$(SUFFIX): libmpikmeans mpi_kmeans_mex.o
mpi_assign_mex.$(SUFFIX): libmpikmeans mpi_assign_mex.o
$(CC) mpi_assign_mex.o -shared -o mpi_assign_mex.$(SUFFIX) libmpikmeans.a $(MATLAB_LIB)
......@@ -159,6 +165,14 @@ index 69b725b..ca04913 100644
+matlab-test:
matlab -nojvm -r "test_code;exit"
+install: all
+ install -d $(bindest) $(libdest)
+ install mpi_kmeans mpi_assign -m 755 $(bindest)
+ install libmpikmeans.a -m 644 $(libdest)
+ install $(LIBFILE) -m 644 $(libdest)
+ cd $(libdest) && ln -s $(LIBFILE) libmpikmeans.so.$(LVER)
+ cd $(libdest) && ln -s libmpikmeans.so.$(LVER) libmpikmeans.so
+
clean:
rm -f *.o
rm -f *.mexglx
......@@ -168,4 +182,4 @@ index 69b725b..ca04913 100644
rm -f libmpikmeans.a
+ rm -rf py_kmeans.c python-build
rm -f mpi_assign mpi_kmeans
-
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment