4 include $(TOP)/mk/boilerplate.mk
6 # -----------------------------------------------------------------------------
7 # This Makefile is copied from the one we use for GMP in ../gmp.
9 # We use libffi's own configuration stuff.
11 PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
15 # is not a valid command on non-Cygwin-systems.
16 # Let it fail silently instead of aborting the build.
20 # set -o igncr; export SHELLOPTS
21 # here as otherwise checking the size of limbs
22 # makes the build fall over on Cygwin. See the thread
23 # http://www.cygwin.com/ml/cygwin/2006-12/msg00011.html
29 # isn't sufficient to stop cygwin using symlinks the mingw gcc can't
30 # follow, as it isn't used consistently. Instead we put an ln.bat in
31 # path that always fails.
33 LIBFFI_TARBALL := $(firstword $(wildcard libffi*.tar.gz))
34 LIBFFI_DIR := $(subst .tar.gz,,$(LIBFFI_TARBALL))
36 BINDIST_STAMPS = stamp.ffi
37 INSTALL_HEADERS += ffi.h
39 INSTALL_LIBS += $(STATIC_LIB)
41 # We have to add the GHC version to the name of our dynamic libs, because
42 # they will be residing in the system location along with dynamic libs from
43 # other GHC installations.
44 ifeq "$(Windows)" "YES"
45 DYNAMIC_PROG = libffi.dll.a
46 DYNAMIC_LIBS = libffi-3.dll
50 DYNAMIC_LIBS = libffi.so libffi.so.5 libffi.so.5.0.5
53 ifeq "$(BuildSharedLibs)" "YES"
59 ifeq "$(BuildSharedLibs)" "YES"
60 INSTALL_LIBS += $(DYNAMIC_LIBS)
61 INSTALL_PROGS += $(DYNAMIC_PROGS)
64 install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
66 # We have to fake a non-working ln for configure, so that the fallback
67 # option (cp -p) gets used instead. Otherwise the libffi build system
68 # will use cygwin symbolic linkks which cannot be read by mingw gcc.
69 # The same trick is played by the GMP build in ../gmp.
72 $(RM) -rf $(LIBFFI_DIR) build
73 $(TAR) -zxf $(LIBFFI_TARBALL)
74 mv $(LIBFFI_DIR) build
76 (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
80 CC=$(WhatGccIsCalled) $(SHELL) configure \
82 --enable-shared=$(EnableShared) \
83 --host=$(PLATFORM) --build=$(PLATFORM)
87 $(CP) build/include/ffi.h .
89 $(STATIC_LIB) $(DYNAMIC_LIBS) $(DYNAMIC_PROG) : stamp.ffi
90 $(MAKE) -C build MAKEFLAGS=
91 (cd build; ./libtool --mode=install cp libffi.la $(FPTOOLS_TOP_ABS)/libffi)
93 clean distclean maintainer-clean ::
94 $(RM) -f stamp.ffi ffi.h
95 $(RM) -f libffi.a libffi.la $(DYNAMIC_PROG) $(DYNAMIC_LIBS) $(ORIG_DYNAMIC_LIBS)
98 #-----------------------------------------------------------------------------
102 include $(TOP)/mk/target.mk
104 BINDIST_EXTRAS += $(BINDIST_STAMPS)
105 BINDIST_EXTRAS += $(INSTALL_PROGS)
106 BINDIST_EXTRAS += $(INSTALL_LIBS)
107 BINDIST_EXTRAS += $(INSTALL_HEADERS)
108 include $(TOP)/mk/bindist.mk