From aacd628cdd3903226a5822b3feed212741dbde04 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 19 Jan 2017 04:18:36 +0100 Subject: Better findability for epoll extension. * fibers/config.scm.in: New file. * Makefile.am: Wire up new file. * env.in: Define FIBERS_BUILD_DIR. * fibers/epoll.scm: Use (fibers config) to get dir for epoll extension. --- Makefile.am | 8 ++++++++ env.in | 3 +++ fibers/config.scm.in | 30 ++++++++++++++++++++++++++++++ fibers/epoll.scm | 4 +++- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 fibers/config.scm.in diff --git a/Makefile.am b/Makefile.am index 9596356..bc0616b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,6 +27,7 @@ info_TEXINFOS=fibers.texi SOURCES = \ fibers.scm \ fibers/channels.scm \ + fibers/config.scm \ fibers/deque.scm \ fibers/epoll.scm \ fibers/internal.scm \ @@ -48,6 +49,12 @@ epoll_la_CFLAGS = $(AM_CFLAGS) $(GUILE_CFLAGS) epoll_la_LIBADD = $(GUILE_LIBS) epoll_la_LDFLAGS = -export-dynamic -module +fibers/config.scm: Makefile fibers/config.scm.in + sed -e "s|@extlibdir\@|$(extlibdir)|" \ + $(srcdir)/fibers/config.scm.in > fibers/config.scm + +CLEANFILES += fibers/config.scm + TESTS = \ tests/basic.scm \ tests/channels.scm \ @@ -59,6 +66,7 @@ TESTS_ENVIRONMENT=top_srcdir="$(abs_top_srcdir)" ./env $(GUILE) -s EXTRA_DIST += \ env.in \ + fibers/config.scm.in \ HACKING \ COPYING.LESSER \ README.md \ diff --git a/env.in b/env.in index 54d837d..c064c44 100644 --- a/env.in +++ b/env.in @@ -45,9 +45,12 @@ else PATH="@abs_top_srcdir@/bin":$PATH fi +FIBERS_BUILD_DIR=@abs_top_builddir@ + export GUILE_LOAD_PATH export GUILE_LOAD_COMPILED_PATH export LTDL_LIBRARY_PATH export PATH +export FIBERS_BUILD_DIR exec "$@" diff --git a/fibers/config.scm.in b/fibers/config.scm.in new file mode 100644 index 0000000..a330339 --- /dev/null +++ b/fibers/config.scm.in @@ -0,0 +1,30 @@ +;; fibers + +;;;; Copyright (C) 2017 Andy Wingo +;;;; +;;;; This library is free software; you can redistribute it and/or +;;;; modify it under the terms of the GNU Lesser General Public +;;;; License as published by the Free Software Foundation; either +;;;; version 3 of the License, or (at your option) any later version. +;;;; +;;;; This library is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;;;; Lesser General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU Lesser General Public +;;;; License along with this library; if not, write to the Free Software +;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;;;; + +(define-module (fibers config) + #:export (extension-library)) + +(define *extlibdir* + (cond + ((getenv "FIBERS_BUILD_DIR") + => (lambda (builddir) (in-vicinity builddir ".libs"))) + (else "@extlibdir@"))) + +(define (extension-library lib) + (in-vicinity *extlibdir* lib)) diff --git a/fibers/epoll.scm b/fibers/epoll.scm index 83a0a63..20d92ae 100644 --- a/fibers/epoll.scm +++ b/fibers/epoll.scm @@ -25,6 +25,7 @@ #:use-module (srfi srfi-9) #:use-module (srfi srfi-9 gnu) #:use-module (rnrs bytevectors) + #:use-module (fibers config) #:export (epoll-create epoll-destroy epoll? @@ -37,7 +38,8 @@ EPOLLIN EPOLLOUT EPOLLPRO EPOLLERR EPOLLHUP EPOLLET)) (eval-when (eval load compile) - (load-extension "epoll" "init_fibers_epoll")) + (dynamic-call "init_fibers_epoll" + (dynamic-link (extension-library "epoll")))) (when (defined? 'EPOLLRDHUP) (export EPOLLRDHUP)) -- cgit v1.3