aboutsummaryrefslogtreecommitdiffstats
path: root/community/ruby-mathematical/fix-extconf.patch
blob: a73b39989b6f37f6a9e28fbd92caa276409f8ee9 (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
55
56
57
58
59
60
From 7ff0cd468ae877eb3de3bff0931b768560849d6f Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Sat, 25 Mar 2017 01:14:41 +0100
Subject: [PATCH] Do not add -llasem and -lmtex2MML to $LIBS when pkg_config is used

pkg-config provides correct arguments to the linker.

It seems that the lasem library is named differently on various
systems. Unmodified lasem 0.5.0 installs library named
liblasm-0.6.so.5.0.0 (and symlink liblasm.so), so linker fails when
 -llasm is passed.

Upstream-Issue: https://github.com/gjtorikian/mathematical/pull/71
---
 ext/mathematical/extconf.rb | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/ext/mathematical/extconf.rb b/ext/mathematical/extconf.rb
index 04993aa..b6cf5bf 100644
--- a/ext/mathematical/extconf.rb
+++ b/ext/mathematical/extconf.rb
@@ -69,8 +69,14 @@ if !using_system_mtex2mml?
   end
   FileUtils.mkdir_p(MTEX2MML_LIB_DIR)
   FileUtils.cp_r(File.join(MTEX2MML_BUILD_DIR, 'libmtex2MML.a'), MTEX2MML_LIB_DIR)
+  $LIBS << ' -lmtex2MML'
 else
-  dir_config('mtex2MML').any? || pkg_config('libmtex2MML') || system('dpkg -s libmtex2MML >/dev/null')
+  if dir_config('mtex2MML').any? || system('dpkg -s libmtex2MML >/dev/null')
+    $LIBS << ' -lmtex2MML'
+  else
+    # NOTE: pkg_config implicitly adds right -l argument for the linker.
+    pkg_config('libmtex2MML') || pkg_config('mtex2MML')
+  end
 end
 
 if !using_system_lasem?
@@ -82,8 +88,14 @@ if !using_system_lasem?
   end
   FileUtils.mkdir_p(LASEM_LIB_DIR)
   FileUtils.cp_r(File.join(LASEM_BUILD_DIR, "liblasem.#{SHARED_EXT}"), LASEM_LIB_DIR)
+  $LIBS << '-llasem'
 else
-  dir_config('lasem').any? || pkg_config('liblasem') || system('dpkg -s liblasem >/dev/null')
+  if dir_config('lasem').any? || system('dpkg -s liblasem >/dev/null')
+    $LIBS << '-llasem'
+  else
+    # NOTE: pkg_config implicitly adds right -l argument for the linker.
+    pkg_config('liblasem') || pkg_config('lasem')
+  end
 end
 
 LIB_DIRS = [MTEX2MML_LIB_DIR, LASEM_LIB_DIR]
@@ -96,6 +108,5 @@ find_header('mtex2MML.h', MTEX2MML_SRC_DIR)
 flag = ENV['TRAVIS'] ? '-O0' : '-O2'
 $LDFLAGS << " #{`pkg-config --static --libs glib-2.0 gdk-pixbuf-2.0 cairo pango`.chomp}"
 $CFLAGS << " #{flag} #{`pkg-config --cflags glib-2.0 gdk-pixbuf-2.0 cairo pango`.chomp}"
-$LIBS << ' -lmtex2MML -llasem'
 
 create_makefile('mathematical/mathematical')