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 "$(BuildSharedLibs)" "YES"
45 ifeq "$(Windows)" "YES"
46 DYNAMIC_PROG = libffi.dll.a
47 DYNAMIC_LIBS = libffi-3.dll
51 DYNAMIC_LIBS = libffi.so libffi.so.5 libffi.so.5.0.5
58 ifeq "$(BuildSharedLibs)" "YES"
64 INSTALL_LIBS += $(DYNAMIC_LIBS)
65 INSTALL_PROGS += $(DYNAMIC_PROGS)
67 install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
69 # We have to fake a non-working ln for configure, so that the fallback
70 # option (cp -p) gets used instead. Otherwise the libffi build system
71 # will use cygwin symbolic linkks which cannot be read by mingw gcc.
72 # The same trick is played by the GMP build in ../gmp.
75 $(RM) -rf $(LIBFFI_DIR) build
76 $(TAR) -zxf $(LIBFFI_TARBALL)
77 mv $(LIBFFI_DIR) build
79 (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
83 CC=$(WhatGccIsCalled) $(SHELL) configure \
85 --enable-shared=$(EnableShared) \
86 --host=$(PLATFORM) --build=$(PLATFORM)
90 $(CP) build/include/ffi.h .
92 $(STATIC_LIB) $(DYNAMIC_LIBS) $(DYNAMIC_PROG) : stamp.ffi
93 $(MAKE) -C build MAKEFLAGS=
94 (cd build; ./libtool --mode=install cp libffi.la $(FPTOOLS_TOP_ABS)/libffi)
96 clean distclean maintainer-clean ::
97 $(RM) -f stamp.ffi ffi.h
98 $(RM) -f libffi.a libffi.la $(DYNAMIC_PROG) $(DYNAMIC_LIBS) $(ORIG_DYNAMIC_LIBS)
101 #-----------------------------------------------------------------------------
105 include $(TOP)/mk/target.mk
108 $(INSTALL_DIR) $(BIN_DIST_DIR)/libffi
109 $(INSTALL_DATA) Makefile $(BIN_DIST_DIR)/libffi/
110 ifneq "$(HaveLibFFI)" "YES"
111 $(INSTALL_DATA) $(BINDIST_STAMPS) $(BIN_DIST_DIR)/libffi/
112 ifneq "$(INSTALL_PROGS)" ""
113 $(INSTALL_DATA) $(INSTALL_PROGS) $(BIN_DIST_DIR)/libffi/
115 ifneq "$(INSTALL_LIBS)" ""
116 $(INSTALL_DATA) $(INSTALL_LIBS) $(BIN_DIST_DIR)/libffi/
118 ifneq "$(INSTALL_HEADERS)" ""
119 $(INSTALL_HEADER) $(INSTALL_HEADERS) $(BIN_DIST_DIR)/libffi/