--- /dev/null
+--- makefile.in
++++ makefile.in
+@@ -1,14 +1,17 @@
+ BLD = build$(QUADSUFFIX)
+
+-LIBDIR = $(PREFIX)/lib$(LIBDIRSUFFIX)
+-INCLUDEDIR = $(PREFIX)/include
+-BINDIR = $(PREFIX)/bin
++LIBDIR = $(DESTDIR)/$(PREFIX)/lib$(LIBDIRSUFFIX)
++INCLUDEDIR = $(DESTDIR)/$(PREFIX)/include
++BINDIR = $(DESTDIR)/$(PREFIX)/bin
+
+ LIB = libooptools$(QUADSUFFIX).a
+ FE = lt$(QUADSUFFIX)$(EXE)
+ MFE = LoopTools$(QUADSUFFIX)$(EXE)
+ INCLUDE = $(BLD)/looptools.h $(BLD)/clooptools.h
+
++LIBRARY=libooptools.so
++REALNAME=$(LIBRARY).$(VER)
++
+ ARGS = $(PARALLEL) \
+ LIB="$(LIB)" \
+ FE="$(FE)" \
+@@ -16,12 +19,12 @@
+ EXE="$(EXE)" \
+ DEF="$(DEF)" \
+ NOUNDERSCORE="$(NOUNDERSCORE)" \
+- XFC="$(FC$(QUADSUFFIX)) $(FFLAGS) $(FFLAGS-quad) -I." \
++ XFC="$(FC$(QUADSUFFIX)) $(FFLAGS) $(FFLAGS-quad) -I. -fPIC" \
+ F90="$(F90)" \
+ CC="$(CC)" \
+- CFLAGS="$(CFLAGS) $(CFLAGS-quad)" \
++ CFLAGS="$(CFLAGS) $(CFLAGS-quad) -fPIC" \
+ CXX="$(CXX)" \
+- CXXFLAGS="$(CXXFLAGS)" \
++ CXXFLAGS="$(CXXFLAGS) -fPIC" \
+ ML="$(ML)" \
+ MCC="$(MCC)" \
+ MCFLAGS="$(MCFLAGS)" \
+@@ -31,20 +34,22 @@
+ DLLTOOL="$(DLLTOOL)" \
+ LDFLAGS="$(LDFLAGS)" \
+ LIBPATH="$(LIBPATH)" \
+- OBJS-quad="$(OBJS-quad)"
++ OBJS-quad="$(OBJS-quad)" \
++ REALNAME="$(REALNAME)"
+
+
+-default all lib frontend mma: force
++default all lib solib frontend mma: force
+ cd $(BLD) && $(MAKE) $(ARGS) $@
+
+-install: lib frontend
+- -mkdir $(PREFIX)
++install: lib solib frontend
++ -mkdir $(DESTDIR)$(PREFIX)
+ -mkdir $(LIBDIR) $(BINDIR) $(INCLUDEDIR)
+ cp -p $(BLD)/$(LIB) $(LIBDIR)
+ cp -p $(INCLUDE$(QUADSUFFIX)) $(INCLUDEDIR)
+- strip $(BLD)/$(FE)
+ cp -p $(BLD)/fcc $(BLD)/$(FE) $(BINDIR)
+- test ! -f $(BLD)/$(MFE) || { strip $(BLD)/$(MFE) ; cp -p $(BLD)/$(MFE) $(BINDIR); }
++ test ! -f $(BLD)/$(MFE) || { cp -p $(BLD)/$(MFE) $(BINDIR); }
++ cp -p $(BLD)/$(REALNAME) $(LIBDIR)
++ cd $(LIBDIR) && ln -s $(REALNAME) $(LIBRARY)
+
+ force: $(BLD)/timestamp
+
+--- src/makefile
++++ src/makefile
+@@ -1,6 +1,6 @@
+-default: frontend mma$(ML)
++default: frontend mma$(ML) solib
+
+-all: frontend mma1
++all: frontend mma1 solib
+
+ frontend: lib $(FE)
+
+@@ -8,6 +8,7 @@
+
+ mma0 lib: $(LIB) clooptools.h fcc
+
++solib: $(REALNAME) fcc
+
+ .SUFFIXES:
+
+@@ -247,6 +248,8 @@
+ $(AR) cru $(LIB) $?
+ -$(RANLIB) $(LIB)
+
++$(REALNAME): $(OBJS)
++ $(XFC) $(LDFLAGS) -shared -Wl,--soname,$(REALNAME) -o $@ $?
+
+ $(FE): lt.F $(LTINC) $(LIB)
+ $(XFC) -o $(FE) lt.F $(LIB)
--- /dev/null
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=5
+
+inherit eutils fortran-2 multilib
+
+MYP=LoopTools-${PV}
+
+DESCRIPTION="Tools for evaluation of scalar and tensor one-loop integrals"
+HOMEPAGE="http://www.feynarts.de/looptools"
+SRC_URI="http://www.feynarts.de/looptools/${MYP}.tar.gz"
+
+LICENSE="LGPL-3"
+
+SLOT="0/${PV}"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="doc static-libs"
+
+DEPEND="virtual/fortran"
+RDEPEND="${DEPEND}"
+
+S="${WORKDIR}/${MYP}"
+
+src_prepare() {
+ epatch "${FILESDIR}"/${P}-makefile.patch
+ export VER="${PV}"
+ # necessary fix for prefix
+ sed -i "s/lib\$(LIBDIRSUFFIX)/$(get_libdir)/" makefile.in || die
+}
+
+src_install() {
+ default
+ # another one of these package building archive with pic
+ # no: ooptools is not a typo
+ use static-libs || rm "${ED}"/usr/$(get_libdir)/libooptools.a
+ use doc && dodoc manual/*.pdf
+}