f76c16d17cbf1df33d15eb9937fe12ac82a45ebf
[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 "$(Windows)" "YES"
45 DYNAMIC_PROG = libffi.dll.a
46 DYNAMIC_LIBS = libffi-3.dll
47 RENAME_LIBS  =
48 else
49 DYNAMIC_PROG =
50 DYNAMIC_LIBS = libffi.so libffi.so.5 libffi.so.5.0.5
51 endif
52
53 ifeq "$(BuildSharedLibs)" "YES"
54 EnableShared=yes
55 else
56 EnableShared=no
57 endif
58
59 ifeq "$(BuildSharedLibs)" "YES"
60 INSTALL_LIBS  += $(DYNAMIC_LIBS)
61 INSTALL_PROGS += $(DYNAMIC_PROGS)
62 endif
63
64 install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
65
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.
70
71 stamp.ffi:
72         $(RM) -rf $(LIBFFI_DIR) build
73         $(TAR) -zxf $(LIBFFI_TARBALL)
74         mv $(LIBFFI_DIR) build
75         chmod +x ln
76         (set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
77             PATH=`pwd`:$$PATH; \
78             export PATH; \
79             cd build && \
80             CC=$(WhatGccIsCalled) $(SHELL) configure \
81                   --enable-static=yes \
82                   --enable-shared=$(EnableShared) \
83                   --host=$(PLATFORM) --build=$(PLATFORM)
84         touch $@
85
86 ffi.h: stamp.ffi
87         $(CP) build/include/ffi.h .
88
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)
92
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)
96         $(RM) -rf build
97
98 #-----------------------------------------------------------------------------
99 #
100 # binary-dist
101
102 include $(TOP)/mk/target.mk
103
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
109