Commit c29b47b7 authored by Simon Marlow's avatar Simon Marlow

add --enable-shared to configure, and $(BuildSharedLibs) to the build system

parent 8edb7668
......@@ -77,12 +77,13 @@ CONFIGURE_FLAGS_STAGE1 += --flags=-ghci
ifeq "$(GhcWithInterpreter)" "YES"
CONFIGURE_FLAGS_STAGE2 += --flags=ghci
ifeq "$(BuildSharedLibs)" "YES"
CONFIGURE_FLAGS_STAGE2 += --enable-shared
# If we are going to use dynamic libraries instead of .o files for ghci,
# we will need to always retain CAFs in the compiler.
# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor))
# function which sets the keepCAFs flag for the RTS before any Haskell
# code is run.
ifeq "$(GhcBuildDylibs)" "YES"
CONFIGURE_FLAGS_STAGE2 += --flags=dynlibs
else
CONFIGURE_FLAGS_STAGE2 += --flags=-dynlibs
......
......@@ -723,6 +723,35 @@ AC_ARG_WITH(ld,
[FP_PROG_LD()]
)
dnl ** Build shared and/or static libs?
dnl --------------------------------------------------------------
AC_ARG_ENABLE(shared,
[AC_HELP_STRING([--enable-shared],
[Build shared libraries, if available. [default=no]])],
[ if test x"$enableval" = x"yes"; then
BuildSharedLibs=YES
else
BuildSharedLibs=NO
fi
],
[BuildSharedLibs=NO]
)
AC_SUBST(BuildSharedLibs)
# ToDo later:
# AC_ARG_ENABLE(static,
# [AC_HELP_STRING([--enable-static],
# [Build static libraries. [default=yes]])],
# [ if test x"$enableval" = x"yes"; then
# BuildStaticLibs=YES
# else
# BuildStaticLibs=NO
# fi
# ],
# [BuildStaticLibs=YES]
# )
# AC_SUBST(BuildStaticLibs)
dnl ** Booting from .hc files?
dnl --------------------------------------------------------------
AC_ARG_ENABLE(hc-boot,
......
......@@ -61,6 +61,10 @@ ifeq "$(GhcThreaded)" "YES"
CONFIGURE_FLAGS_STAGE2 += --ghc-option=-threaded
endif
ifeq "$(BuildSharedLibs)" "YES"
CONFIGURE_FLAGS_STAGE2 += --ghc-option=-dynamic
endif
CONFIGURE_FLAGS_STAGE3 = $(CONFIGURE_FLAGS_STAGE2)
CONFIGURE_FLAGS_STAGE1 += $(USE_BOOT_CONFIGURE_FLAGS)
......
......@@ -33,22 +33,37 @@ PLATFORM := $(shell echo $(HOSTPLATFORM) | sed 's/i[567]86/i486/g')
LIBFFI_TARBALL := $(firstword $(wildcard libffi*.tar.gz))
LIBFFI_DIR := $(subst .tar.gz,,$(LIBFFI_TARBALL))
ifeq "$(findstring dyn, $(GhcRTSWays))" "dyn"
BUILD_SHARED=yes
BINDIST_STAMPS = stamp.ffi
INSTALL_HEADERS += ffi.h
STATIC_LIB = libffi.a
INSTALL_LIBS += $(STATIC_LIB)
# We have to add the GHC version to the name of our dynamic libs, because
# they will be residing in the system location along with dynamic libs from
# other GHC installations.
ifeq "$(BuildSharedLibs)" "YES"
ifeq "$(Windows)" "YES"
DYNAMIC_PROG = libffi.dll.a
DYNAMIC_LIBS = libffi-3.dll
RENAME_LIBS =
else
BUILD_SHARED=no
DYNAMIC_PROG =
DYNAMIC_LIBS = libffi.so libffi.so.5 libffi.so.5.0.5
endif
else
DYNAMIC_PROG =
DYNAMIC_LIBS =
endif
BINDIST_STAMPS = stamp.ffi.static
INSTALL_HEADERS += ffi.h
INSTALL_LIBS += libffi.a
ifeq "$(BUILD_SHARED)" "yes"
BINDIST_STAMPS += stamp.ffi.shared
INSTALL_LIBS += libffi.dll.a
INSTALL_PROGS += libffi-3.dll
ifeq "$(BuildSharedLibs)" "YES"
EnableShared=yes
else
EnableShared=no
endif
INSTALL_LIBS += $(DYNAMIC_LIBS)
INSTALL_PROGS += $(DYNAMIC_PROGS)
install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
# We have to fake a non-working ln for configure, so that the fallback
......@@ -56,7 +71,7 @@ install all :: $(INSTALL_HEADERS) $(INSTALL_LIBS) $(INSTALL_PROGS)
# will use cygwin symbolic linkks which cannot be read by mingw gcc.
# The same trick is played by the GMP build in ../gmp.
stamp.ffi.static:
stamp.ffi:
$(RM) -rf $(LIBFFI_DIR) build
$(TAR) -zxf $(LIBFFI_TARBALL)
mv $(LIBFFI_DIR) build
......@@ -66,42 +81,22 @@ stamp.ffi.static:
export PATH; \
cd build && \
CC=$(WhatGccIsCalled) $(SHELL) configure \
--enable-shared=no --host=$(PLATFORM) --build=$(PLATFORM)
--enable-static=yes \
--enable-shared=$(EnableShared) \
--host=$(PLATFORM) --build=$(PLATFORM)
touch $@
stamp.ffi.shared:
$(RM) -rf $(LIBFFI_DIR) build-shared
$(TAR) -zxf $(LIBFFI_TARBALL)
mv $(LIBFFI_DIR) build-shared
chmod +x ln
(set -o igncr 2>/dev/null) && set -o igncr; export SHELLOPTS; \
PATH=`pwd`:$$PATH; \
export PATH; \
cd build-shared && \
CC=$(WhatGccIsCalled) $(SHELL) configure \
--enable-shared=yes --disable-static --host=$(PLATFORM) --build=$(PLATFORM)
touch $@
ffi.h: stamp.ffi.static
ffi.h: stamp.ffi
$(CP) build/include/ffi.h .
libffi.a: stamp.ffi.static
$(STATIC_LIB) $(DYNAMIC_LIBS) $(DYNAMIC_PROG) : stamp.ffi
$(MAKE) -C build MAKEFLAGS=
$(CP) build/.libs/libffi.a .
$(RANLIB) libffi.a
libffi-3.dll: stamp.ffi.shared
$(MAKE) -C build-shared MAKEFLAGS=
$(CP) build-shared/.libs/libffi-3.dll .
libffi.dll.a: libffi-3.dll
$(CP) build-shared/.libs/libffi.dll.a .
(cd build; ./libtool --mode=install cp libffi.la $(FPTOOLS_TOP_ABS)/libffi)
clean distclean maintainer-clean ::
$(RM) -f stamp.ffi.static stamp.ffi.shared ffi.h
$(RM) -f libffi.a libffi-3.dll libffi.dll.a
$(RM) -f stamp.ffi ffi.h
$(RM) -f libffi.a libffi.la $(DYNAMIC_PROG) $(DYNAMIC_LIBS) $(ORIG_DYNAMIC_LIBS)
$(RM) -rf build
$(RM) -rf build-shared
#-----------------------------------------------------------------------------
#
......
......@@ -129,7 +129,7 @@ CONFIGURE_OPTS += --enable-library-profiling
CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-profiling
endif
ifneq "$(findstring $(space)dyn$(space), $(space)$(GhcLibWays)$(space))" ""
ifeq "$(BuildSharedLibs)" "YES"
CONFIGURE_OPTS += --enable-shared
CONFIGURE_STAMP_EXTRAS := $(CONFIGURE_STAMP_EXTRAS)-shared
endif
......
......@@ -242,6 +242,11 @@ GhcStage3HcOpts=-O2
GhcProfiled=NO
GhcDebugged=NO
# Build shared and/or static libs?
BuildSharedLibs=@BuildSharedLibs@
# ToDo later:
# BuildStaticLibs=@BuildStaticLibs@
# Build a compiler that will build *unregisterised* libraries and
# binaries by default. Unregisterised code is supposed to compile and
# run without any support for architecture-specific assembly mangling,
......@@ -362,6 +367,10 @@ else
GhcLibWays=p
endif
ifeq "$(BuildSharedLibs)" "YES"
GhcLibWays += dyn
endif
# In addition, the RTS is built in some further variations. Ways that
# make sense here:
#
......@@ -381,6 +390,10 @@ ifeq "$(BootingFromHc)" "NO"
GhcRTSWays += debug
endif
ifeq "$(BuildSharedLibs)" "YES"
GhcRTSWays += debug_dyn thr_dyn thr_debug_dyn
endif
# Want the threaded versions unless we're unregisterised
# Defer the check until later by using $(if..), because GhcUnregisterised might
# be set in build.mk, which hasn't been read yet.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment