Commit 1a73dfa4 authored by Christian Kastner's avatar Christian Kastner

Fix missing/wrong build flags

parent 147d2c82
From: Christian Kastner <debian@kvr.at>
Date: Mon, 11 Apr 2011 19:26:09 +0200
Subject: [PATCH] Properly build shared and static libraries, programs
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.
Forwarded: not-needed
Last-Update: 2011-04-11
Last-Update: 2014-02-21
---
Makefile | 114 ++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 62 insertions(+), 52 deletions(-)
Index: mpikmeans-1.5/Makefile
===================================================================
--- mpikmeans-1.5.orig/Makefile 2011-04-11 19:49:33.004001563 +0200
+++ mpikmeans-1.5/Makefile 2011-04-11 19:57:56.312002046 +0200
diff --git a/Makefile b/Makefile
index 69b725b..ca04913 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,33 @@
-#
-# Choose your compiler
......@@ -59,7 +62,7 @@ Index: mpikmeans-1.5/Makefile
#
# MPI KMEANS FLAGS
@@ -25,19 +42,6 @@
@@ -25,19 +42,6 @@ MATLABDIR=/agbs/share/sw/matlab
MATLAB_INCLUDE=-I$(MATLABDIR)/extern/include
#
......@@ -79,63 +82,61 @@ Index: mpikmeans-1.5/Makefile
# ARCHITECURE
#
@@ -49,34 +53,31 @@
@@ -49,34 +53,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
+all: lib standalone python
+lib: $(LIBFILE) libmpikmeans.a
+standalone: mpi_kmeans mpi_assign
+python: cython_wrapper
+
matlab: mpi_kmeans_mex.$(SUFFIX) mpi_assign_mex.$(SUFFIX)
-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
+libmpikmeans.a:
+ $(CXX) $(CFLAGS) $(LDFLAGS) -c -o libmpikmeans-static.o mpi_kmeans.cxx
+ ar cru libmpikmeans.a libmpikmeans-static.o
+
+$(LIBFILE): mpi_kmeans.cxx mpi_kmeans.h
+ $(CXX) $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared \
+ -Wl,-soname=libmpikmeans.so.$(LVER) \
+ -o $@ $(VERBOSEFLAGS) $(PRECISION) \
+ mpi_kmeans.cxx $(LIB_LIBS)
+ ln -s $@ libmpikmeans.so.$(LVER)
+ ln -s libmpikmeans.so.$(LVER) libmpikmeans.so
+all: lib standalone python
+lib: $(LIBFILE) libmpikmeans.a
+standalone: mpi_kmeans mpi_assign
+python: cython_wrapper
-libmpikmeans: mpi_kmeans.o
- ar rc libmpikmeans.a mpi_kmeans.o
- ranlib libmpikmeans.a
- $(CC) -shared -Wl,-soname=libmpikmeans.so -fPIC $(CFLAGS) -o libmpikmeans.so $(VERBOSEFLAGS) $(PRECISION) mpi_kmeans.cxx
-
+matlab: mpi_kmeans_mex.$(SUFFIX) mpi_assign_mex.$(SUFFIX)
-mpi_kmeans_main.o: mpi_kmeans_main.cxx
- $(CC) $(CFLAGS) $(BOOST_INCLUDE) -c -o mpi_kmeans_main.o mpi_kmeans_main.cxx
-
+libmpikmeans.a:
+ $(CXX) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -c -o libmpikmeans-static.o mpi_kmeans.cxx
+ ar cru libmpikmeans.a libmpikmeans-static.o
-mpi_assign_main.o: mpi_assign_main.cxx
- $(CC) $(CFLAGS) $(BOOST_INCLUDE) -c -o mpi_assign_main.o mpi_assign_main.cxx
-
+$(LIBFILE): mpi_kmeans.cxx mpi_kmeans.h
+ $(CXX) $(CPPFLAGS) $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared \
+ -Wl,-soname=libmpikmeans.so.$(LVER) \
+ -o $@ $(VERBOSEFLAGS) $(PRECISION) \
+ mpi_kmeans.cxx $(LIB_LIBS)
+ ln -s $@ libmpikmeans.so.$(LVER)
+ ln -s libmpikmeans.so.$(LVER) libmpikmeans.so
-mpi_kmeans_main: libmpikmeans mpi_kmeans_main.o
- $(CC) mpi_kmeans_main.o $(CFLAGS) -L/usr/lib/ -static -o mpi_kmeans -lm libmpikmeans.a \
- $(BOOST_LIB) $(LIBS)
-
+mpi_kmeans: mpi_kmeans_main.cxx $(LIBFILE)
+ $(CXX) $(CPPFLAGS) $(PROG_CFLAGS) $(PROG_LDFLAGS) -o $@ mpi_kmeans_main.cxx $(PROG_LIBS)
-mpi_assign_main: libmpikmeans mpi_assign_main.o
- $(CC) mpi_assign_main.o $(CFLAGS) -L/usr/lib/ -static -o mpi_assign -lm libmpikmeans.a \
- $(BOOST_LIB) $(LIBS)
+mpi_kmeans: mpi_kmeans_main.cxx $(LIBFILE)
+ $(CXX) $(PROG_CFLAGS) $(PROG_LDFLAGS) -o $@ mpi_kmeans_main.cxx $(PROG_LIBS)
+
+mpi_assign: mpi_assign_main.cxx $(LIBFILE)
+ $(CXX) $(PROG_CFLAGS) $(PROG_LDFLAGS) -o $@ mpi_assign_main.cxx $(PROG_LIBS)
+ $(CXX) $(CPPFLAGS) $(PROG_CFLAGS) $(PROG_LDFLAGS) -o $@ mpi_assign_main.cxx $(PROG_LIBS)
%_mex.o: %_mex.cxx
$(CC) $(CFLAGS) $(MATLAB_INCLUDE) $(VERBOSEFLAG) $(PRECISION) -c $^ -o $@
@@ -87,18 +88,27 @@
@@ -87,18 +88,27 @@ 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)
......@@ -148,9 +149,9 @@ Index: mpikmeans-1.5/Makefile
+# See note regarding PYVER above
+cython_wrapper: py_kmeans.c
+ mkdir -p python-build/python$(PYVER)
+ $(CXX) $(CFLAGS) -c -I/usr/include/python$(PYVER) \
+ $(CXX) $(CFLAGS) $(CPPFLAGS) -c -I/usr/include/python$(PYVER) \
+ -pthread -fPIC -o py_kmeans.o py_kmeans.c
+ $(CXX) $(CFLAGS) $(PYTHON_LDFLAGS) -pthread -shared -Wl,--as-needed \
+ $(CXX) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -pthread -shared -Wl,--as-needed \
+ -lpython$(PYVER) -L. -lmpikmeans \
+ -o python-build/python$(PYVER)/py_kmeans.so py_kmeans.o
......
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