summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2008-01-27 12:46:11 +0100
committerMatthias Benkard <code@mail.matthias.benkard.de>2008-01-27 12:46:11 +0100
commitd382b23ee73dd993e944bd4fad9d190bc2e6f849 (patch)
tree9cbdbf4f31d13dc2def8dec81153f74ec4580e99
parenta93c3679f769423c69fca20fab3bb4ade7207cc1 (diff)
Do not build our own libffi if we can find one installed on the system.
darcs-hash:98186d9dca2682cb70a25403ee7415dcbd28249c
-rw-r--r--GNUmakefile34
-rw-r--r--Objective-C/GNUmakefile21
-rw-r--r--Objective-C/libffi_support.h11
-rw-r--r--Objective-C/libobjcl.h10
-rw-r--r--config.make.in5
-rw-r--r--configure.ac36
-rw-r--r--objective-cl.asd4
7 files changed, 109 insertions, 12 deletions
diff --git a/GNUmakefile b/GNUmakefile
index ca8ebf2..ecba147 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -14,10 +14,16 @@
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
+include version.make
+-include config.make
--include $(GNUSTEP_MAKEFILES)/common.make
+.PHONY: all clean distclean install
-include version.make
+ifeq ($(CONFIG_MAKE_INCLUDED_P),)
+all clean install: config.make
+ @echo "Please run ./configure before running make."
+else # CONFIG_MAKE_INCLUDED_P
+-include $(GNUSTEP_MAKEFILES)/common.make
PACKAGE_NAME = Objective-CL
RPM_DISABLE_RELOCATABLE = YES
@@ -26,14 +32,30 @@ SUBPROJECTS = Objective-C
ifneq ($(COMMON_MAKE_LOADED),)
include $(GNUSTEP_MAKEFILES)/aggregate.make
+before-all before-clean before-install before-distclean:: config.make
+
+after-distclean::
+ rm -f config.make
+ rm -f config.h
else # Mac OS X
all:
- make -C Objective-C all
+ $(MAKE) -C Objective-C all
clean:
- make -C Objective-C clean
+ $(MAKE) -C Objective-C clean
+
+distclean:
+ $(MAKE) -C Objective-C distclean
+ rm -f config.make
+ rm -f config.h
install:
- make -C Objective-C install
-endif
+ $(MAKE) -C Objective-C install
+endif # Mac OS X
+endif # CONFIG_MAKE_INCLUDED_P
+
+config.make: configure config.make.in
+ sh ./configure
+configure: configure.ac
+ autoreconf
diff --git a/Objective-C/GNUmakefile b/Objective-C/GNUmakefile
index 48a1827..c69d1d7 100644
--- a/Objective-C/GNUmakefile
+++ b/Objective-C/GNUmakefile
@@ -18,7 +18,14 @@
-include $(GNUSTEP_MAKEFILES)/common.make
include ../version.make
+-include ../config.make
+.PHONY: all clean distclean install
+
+ifeq ($(CONFIG_MAKE_INCLUDED_P),)
+all clean install:
+ @echo "Please run ./configure before running make."
+else # CONFIG_MAKE_INCLUDED_P
USE_LIBFFI = 1
LIBRARY_NAME = libobjcl
@@ -29,16 +36,21 @@ ADDITIONAL_OBJCFLAGS = -Wall -g -DVERSION=\"$(VERSION)\" -I/usr/local/include
libobjcl_OBJC_FILES = libobjcl.m objc_support.m objc-runtime-apple.m objc-runtime-gnu.m
LIBRARIES_DEPEND_UPON = $(FND_LIBS) $(GUI_LIBS) $(OBJC_LIBS) $(SYSTEM_LIBS) $(CONFIG_SYSTEM_LIBS)
+ADDITIONAL_LDFLAGS = $(LIBS)
+
ifdef USE_LIBFFI
# FIXME: For now, we statically link against libffi. We are not certain
# that this is a good idea. Linking dynamically, on the other hand, is
# hard in general (that's one of the reasons libtool exists, after all).
-ADDITIONAL_LDFLAGS = ../libffi/.libs/libffi.a
-ADDITIONAL_OBJCFLAGS += -DUSE_LIBFFI -I../libffi/include
-libobjcl_OBJC_FILES += libffi_support.m
+ADDITIONAL_OBJCFLAGS += -DUSE_LIBFFI
+ifneq ($(HAVE_ANY_FFI_H),1)
+ADDITIONAL_LDFLAGS += ../libffi/.libs/libffi.a
+ADDITIONAL_OBJCFLAGS += -I../libffi/include
FFI_DEPS += ../libffi/.libs/libffi.a
FFI_CLEAN += libffi_clean
endif
+libobjcl_OBJC_FILES += libffi_support.m
+endif
ifneq ($(COMMON_MAKE_LOADED),)
-include $(GNUSTEP_MAKEFILES)/library.make
@@ -55,6 +67,8 @@ all: obj/libobjcl.dylib
clean: $(FFI_CLEAN)
rm -f obj/libobjcl.dylib obj/libobjcl.dylib.$(VERSION) $(libobjcl_OBJ_FILES)
+distclean: clean
+
obj/libobjcl.dylib: $(FFI_DEPS) obj/libobjcl.dylib.$(VERSION)
ln -s libobjcl.dylib.$(VERSION) $@
@@ -72,3 +86,4 @@ endif
libffi_clean:
-make -C ../libffi distclean
+endif # CONFIG_MAKE_INCLUDED_P
diff --git a/Objective-C/libffi_support.h b/Objective-C/libffi_support.h
index cdf71c0..ca04c6b 100644
--- a/Objective-C/libffi_support.h
+++ b/Objective-C/libffi_support.h
@@ -1,7 +1,16 @@
#ifndef PyObjC_FFI_SUPPORT_H
#define PyObjC_FFI_SUPPORT_H
-#include "ffi.h"
+#ifdef USE_LIBFFI
+#ifdef HAVE_FFI_H
+#include <ffi.h>
+#elif HAVE_FFI_FFI_H
+#include <ffi/ffi.h>
+#else
+/* We are using our own build of libffi. */
+#include <ffi.h>
+#endif
+#endif
ffi_type*
objcl_pyobjc_signature_to_ffi_return_type (const char* argtype);
diff --git a/Objective-C/libobjcl.h b/Objective-C/libobjcl.h
index 8c557a2..e5a70f1 100644
--- a/Objective-C/libobjcl.h
+++ b/Objective-C/libobjcl.h
@@ -20,10 +20,18 @@
#import "Foundation/Foundation.h"
#include <objc/objc-api.h>
+#include "../config.h"
+
#ifdef USE_LIBFFI
+#ifdef HAVE_FFI_H
+#include <ffi.h>
+#elif HAVE_FFI_FFI_H
+#include <ffi/ffi.h>
+#else
+/* We are using our own build of libffi. */
#include <ffi.h>
#endif
-
+#endif
extern NSException *objcl_oom_exception;
diff --git a/config.make.in b/config.make.in
new file mode 100644
index 0000000..c5350a3
--- /dev/null
+++ b/config.make.in
@@ -0,0 +1,5 @@
+LIBS = @LIBS@
+HAVE_ANY_FFI_H = @HAVE_ANY_FFI_H@
+HAVE_LIBFFI = @HAVE_LIBFFI@
+@SET_MAKE@
+CONFIG_MAKE_INCLUDED_P = 1
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..c79078a
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,36 @@
+## Objective-CL, an Objective-C bridge for Common Lisp.
+## Copyright (C) 2008 Matthias Andreas Benkard.
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or (at
+## your option) any later version.
+##
+## This program 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
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+AC_PREREQ(2.61)
+AC_INIT(Objective-CL, 0.0.3, objcl-bugs@matthias.benkard.de)
+AC_CONFIG_SRCDIR([Objective-C/libobjcl.h])
+
+AC_PROG_CC
+AC_PROG_OBJC
+#AC_PROG_INSTALL
+#AC_PROG_LN_S
+AC_PROG_MAKE_SET
+
+AC_SEARCH_LIBS([ffi_call], [ffi], [HAVE_LIBFFI=1; break], [HAVE_LIBFFI=0])
+
+HAVE_ANY_FFI_H=0
+AC_CHECK_HEADERS([ffi.h ffi/ffi.h], [HAVE_ANY_FFI_H=1; break])
+
+AC_SUBST(HAVE_ANY_FFI_H)
+AC_SUBST(HAVE_LIBFFI)
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_FILES([config.make])
+AC_OUTPUT
diff --git a/objective-cl.asd b/objective-cl.asd
index 474457c..17dea28 100644
--- a/objective-cl.asd
+++ b/objective-cl.asd
@@ -94,6 +94,7 @@
(directory (merge-pathnames x source-dir)))
'(#p"**/*.m" #p"**/*.h" #p"**/GNUmakefile.*"
#p"**/*.make" #p"**/GNUmakefile"
+ #p"**/*.in" #p"**/configure" #p"**/configure.ac"
#p"libffi/**/*" #p"libffi/**/*.*"))))
(output-dir
(merge-pathnames #p"../../"
@@ -121,8 +122,9 @@
(unless (or (operation-done-p o c)
(null (output-files o c)))
(zerop
+ ;; Run `make' at the top level of the directory tree.
(run-shell-command "make -C '~A'"
- (merge-pathnames #p"../"
+ (merge-pathnames #p"../../"
(directory-namestring
(first (output-files o c))))))))