summaryrefslogtreecommitdiff
path: root/math/liblinear/patches/patch-Makefile
blob: 0e6e938e4104aa4e8f4c7e8cd7e56b5701318c60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$NetBSD: patch-Makefile,v 1.4 2020/10/28 19:32:33 adam Exp $

Use LIBTOOL.
Add support for LDFLAGS.

--- Makefile.orig	2020-07-29 09:11:00.000000000 +0000
+++ Makefile
@@ -1,34 +1,29 @@
 CXX ?= g++
 CC ?= gcc
-CFLAGS = -Wall -Wconversion -O3 -fPIC
-LIBS = blas/blas.a
+LIBS = blas/libblas.la
 SHVER = 4
-OS = $(shell uname)
 #LIBS = -lblas
 
 all: train predict
 
-lib: linear.o newton.o blas/blas.a
-	if [ "$(OS)" = "Darwin" ]; then \
-		SHARED_LIB_FLAG="-dynamiclib -Wl,-install_name,liblinear.so.$(SHVER)"; \
-	else \
-		SHARED_LIB_FLAG="-shared -Wl,-soname,liblinear.so.$(SHVER)"; \
-	fi; \
-	$(CXX) $${SHARED_LIB_FLAG} linear.o newton.o blas/blas.a -o liblinear.so.$(SHVER)
+lib: linear.lo newton.lo $(LIBS)
+	${LIBTOOL} --mode=link $(CXX) -o liblinear.la $(LDFLAGS) $> -rpath ${PREFIX}/lib -version-info ${SHVER}:0
 
-train: newton.o linear.o train.c blas/blas.a
-	$(CXX) $(CFLAGS) -o train train.c newton.o linear.o $(LIBS)
+train: newton.lo linear.lo train.c $(LIBS)
+	${LIBTOOL} --mode=link $(CXX) $(CFLAGS) -o train $(LDFLAGS) $>
 
-predict: newton.o linear.o predict.c blas/blas.a
-	$(CXX) $(CFLAGS) -o predict predict.c newton.o linear.o $(LIBS)
+predict: newton.lo linear.lo predict.c $(LIBS)
+	${LIBTOOL} --mode=link $(CXX) $(CFLAGS) -o predict $(LDFLAGS) $>
 
-newton.o: newton.cpp newton.h
+newton.lo: newton.cpp newton.h
+	${LIBTOOL} --mode=compile \
 	$(CXX) $(CFLAGS) -c -o newton.o newton.cpp
 
-linear.o: linear.cpp linear.h
+linear.lo: linear.cpp linear.h
+	${LIBTOOL} --mode=compile \
 	$(CXX) $(CFLAGS) -c -o linear.o linear.cpp
 
-blas/blas.a: blas/*.c blas/*.h
+$(LIBS): blas/*.c blas/*.h
 	make -C blas OPTFLAGS='$(CFLAGS)' CC='$(CC)';
 
 clean: