Fix how we put libffi into bindists
[ghc-hetmet.git] / libffi / Makefile
1
2 TOP=..
3
4 include $(TOP)/mk/boilerplate.mk
5
6 # -----------------------------------------------------------------------------
7 # This Makefile is copied from the one we use for GMP in ../gmp.
8 #
9 # We use libffi's own configuration stuff.
10
11 PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
12
13 # 2007-09-26
14 #     set -o igncr 
15 # is not a valid command on non-Cygwin-systems.
16 # Let it fail silently instead of aborting the build.
17 #
18 # 2007-07-05
19 # We do
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
24 # for more details.
25
26 # 2007-07-05
27 # Passing
28 #     as_ln_s='cp -p'
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.
32
33 LIBFFI_TARBALL := $(firstword $(wildcard libffi*.tar.gz))
34 LIBFFI_DIR := $(subst .tar.gz,,$(LIBFFI_TARBALL))
35
36 BINDIST_STAMPS = stamp.ffi
37 INSTALL_HEADERS += ffi.h
38 STATIC_LIB = libffi.a
39 INSTALL_LIBS += $(STATIC_LIB)
40
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
48 RENAME_LIBS  =
49 else
50 DYNAMIC_PROG =
51 DYNAMIC_LIBS = libffi.so libffi.so.5 libffi.so.5.0.5
52 endif
53 else
54 DYNAMIC_PROG =
55 DYNAMIC_LIBS =
56 endif
57
58 ifeq "$(BuildSharedLibs)" "YES"
59 EnableShared=yes
60 else
61 EnableShared=no
62 endif
63
64 INSTALL_LIBS  += $(DYNAMIC_LIBS)
65 INSTALL_PROGS += $(DYNAMIC_PROGS)
66
67 install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
68
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.
73
74 stamp.ffi:
75         $(RM) -rf $(LIBFFI_DIR) build
76         $(TAR) -zxf $(LIBFFI_TARBALL)
77         mv $(LIBFFI_DIR) build
78         chmod +x ln
79         (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
80             PATH=`pwd`:$$PATH; \
81             export PATH; \
82             cd build && \
83             CC=$(WhatGccIsCalled) $(SHELL) configure \
84                   --enable-static=yes \
85                   --enable-shared=$(EnableShared) \
86                   --host=$(PLATFORM) --build=$(PLATFORM)
87         touch $@
88
89 ffi.h: stamp.ffi
90         $(CP) build/include/ffi.h .
91
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)
95
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)
99         $(RM) -rf build
100
101 #-----------------------------------------------------------------------------
102 #
103 # binary-dist
104
105 include $(TOP)/mk/target.mk
106
107 BINDIST_EXTRAS += $(BINDIST_STAMPS)
108 BINDIST_EXTRAS += $(INSTALL_PROGS)
109 BINDIST_EXTRAS += $(INSTALL_LIBS)
110 BINDIST_EXTRAS += $(INSTALL_HEADERS)
111 include $(TOP)/mk/bindist.mk
112