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 ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
42 BINDIST_STAMPS = stamp.ffi.static
43 INSTALL_HEADERS += ffi.h
44 INSTALL_LIBS += libffi.a
46 ifeq "$(BUILD_SHARED)" "yes"
47 BINDIST_STAMPS += stamp.ffi.shared
48 INSTALL_LIBS += libffi.dll.a
49 INSTALL_PROGS += libffi-3.dll
52 install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
54 # We have to fake a non-working ln for configure, so that the fallback
55 # option (cp -p) gets used instead. Otherwise the libffi build system
56 # will use cygwin symbolic linkks which cannot be read by mingw gcc.
57 # The same trick is played by the GMP build in ../gmp.
60 $(RM) -rf $(LIBFFI_DIR) build
61 $(TAR) -zxf $(LIBFFI_TARBALL)
62 mv $(LIBFFI_DIR) build
64 (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
68 CC=$(WhatGccIsCalled) $(SHELL) configure \
69 --enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
73 $(RM) -rf $(LIBFFI_DIR) build-shared
74 $(TAR) -zxf $(LIBFFI_TARBALL)
75 mv $(LIBFFI_DIR) build-shared
77 (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
81 CC=$(WhatGccIsCalled) $(SHELL) configure \
82 --enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
85 ffi.h: stamp.ffi.static
86 $(CP) build/include/ffi.h .
88 libffi.a: stamp.ffi.static
89 $(MAKE) -C build MAKEFLAGS=
90 $(CP) build/.libs/libffi.a .
93 libffi-3.dll: stamp.ffi.shared
94 $(MAKE) -C build-shared MAKEFLAGS=
95 $(CP) build-shared/.libs/libffi-3.dll .
97 libffi.dll.a: libffi-3.dll
98 $(CP) build-shared/.libs/libffi.dll.a .
100 clean distclean maintainer-clean ::
101 $(RM) -f stamp.ffi.static stamp.ffi.shared ffi.h
102 $(RM) -f libffi.a libffi-3.dll libffi.dll.a
104 $(RM) -rf build-shared
106 #-----------------------------------------------------------------------------
110 include $(TOP)/mk/target.mk
113 $(INSTALL_DIR) $(BIN_DIST_DIR)/libffi
114 $(INSTALL_DATA) Makefile $(BIN_DIST_DIR)/libffi/
115 ifneq "$(HaveLibFFI)" "YES"
116 $(INSTALL_DATA) $(BINDIST_STAMPS) $(BIN_DIST_DIR)/libffi/
117 ifneq "$(INSTALL_PROGS)" ""
118 $(INSTALL_DATA) $(INSTALL_PROGS) $(BIN_DIST_DIR)/libffi/
120 ifneq "$(INSTALL_LIBS)" ""
121 $(INSTALL_DATA) $(INSTALL_LIBS) $(BIN_DIST_DIR)/libffi/
123 ifneq "$(INSTALL_HEADERS)" ""
124 $(INSTALL_HEADER) $(INSTALL_HEADERS) $(BIN_DIST_DIR)/libffi/