From 7ff0cd468ae877eb3de3bff0931b768560849d6f Mon Sep 17 00:00:00 2001 From: Jakub Jirutka 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')