Rewritten MinGW DLL support

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@20817 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Nicola Pero 2005-03-01 04:54:48 +00:00
parent 5e6d1fcf43
commit eb3712b97b
4 changed files with 123 additions and 33 deletions

View file

@ -1,3 +1,30 @@
2005-03-01 Nicola Pero <n.pero@mi.flashnet.it>
* target.make (WITH_DLL): Variable removed.
(OLD_DLL_SUPPORT): New variable which is set to yes for cygwin,
but to no for mingw.
(DLLTOOL): Do not define for mingw.
(DLLWRAP): Do not define for mingw.
(SHARED_LIB_LINK_CMD): New variable for mingw.
(AFTER_INSTALL_SHARED_LIB_CMD): The same.
(AFTER_INSTALL_SHARED_LIB_CHOWN): The same.
(SHARED_LIBEXT): Do not define to be .a on mingw; that is only
confusing; use LIBEXT instead.
(LIBEXT): Define to be .a on mingw.
(TARGET_SYSTEM_LIBS): Define using =, not :=.
* rules.make (ALL_CPPFLAGS): Check BUILD_DLL instead of WITH_DLL
when adding -DGNUSTEP_WITH_DLL.
* Instance/library.make (LIBRARY_NAME_WITHOUT_LIB): New variable.
(LIBRARY_FILE_EXT): Unused variable removed.
(CLEAN_library_NAME): Generate using make functions rather than
firing external shell scripts to increase building speed.
Execute existing DLL code when OLD_DLL_SUPPORT is set to yes. For
BUILD_DLL but not OLD_DLL_SUPPORT, added brand new code which uses
the new target.make mingw variables and takes advantage of the new
DLL support in GCC and mingw.
2005-02-19 Adam Fedor <fedor@gnu.org>
* Documentation/README.MinGW: Minor edit.

View file

@ -37,7 +37,6 @@ include $(GNUSTEP_MAKEFILES)/Instance/Shared/headers.make
# The directory where the header files are located is xxx_HEADER_FILES_DIR
# The directory where to install the header files inside the library
# installation directory is xxx_HEADER_FILES_INSTALL_DIR
# The DLL export file is in xxx_DLL_DEF
#
# Where xxx is the name of the library
#
@ -98,8 +97,10 @@ endif
#
ifneq ($(filter lib%,$(GNUSTEP_INSTANCE)),)
LIBRARY_NAME_WITH_LIB = $(GNUSTEP_INSTANCE)
LIBRARY_NAME_WITHOUT_LIB = $(patsubst lib%,%,$(GNUSTEP_INSTANCE))
else
LIBRARY_NAME_WITH_LIB = lib$(GNUSTEP_INSTANCE)
LIBRARY_NAME_WITHOUT_LIB = $(GNUSTEP_INSTANCE)
endif
INTERNAL_LIBRARIES_DEPEND_UPON = \
@ -114,7 +115,6 @@ ifeq ($(shared), yes)
ifneq ($(BUILD_DLL),yes)
LIBRARY_FILE = $(LIBRARY_NAME_WITH_LIB)$(LIBRARY_NAME_SUFFIX)$(SHARED_LIBEXT)
LIBRARY_FILE_EXT = $(SHARED_LIBEXT)
VERSION_LIBRARY_FILE = $(LIBRARY_FILE).$(VERSION)
# Allow the user GNUmakefile to define xxx_INTERFACE_VERSION to
@ -174,22 +174,50 @@ SONAME_LIBRARY_FILE = $(LIBRARY_FILE).$(INTERFACE_VERSION)
else # BUILD_DLL
LIBRARY_FILE = $(LIBRARY_NAME_WITH_LIB)$(LIBRARY_NAME_SUFFIX)$(DLL_LIBEXT)
LIBRARY_FILE_EXT = $(DLL_LIBEXT)
DLL_NAME = $(shell echo $(LIBRARY_FILE)|cut -b 4-)
DLL_EXP_LIB = $(LIBRARY_NAME_WITH_LIB)$(LIBRARY_NAME_SUFFIX)$(SHARED_LIBEXT)
DLL_EXP_DEF = $(LIBRARY_NAME_WITH_LIB)$(LIBRARY_NAME_SUFFIX).def
# When you build a DLL, you have to install it in a directory which is
# in your PATH.
ifeq ($(DLL_INSTALLATION_DIR),)
DLL_INSTALLATION_DIR = $(GNUSTEP_TOOLS)/$(GNUSTEP_TARGET_LDIR)
endif
# When we build a DLL, we also pass -DBUILD_lib{library_name}_DLL=1 to
# the preprocessor. With the new DLL support, this is usually not
# needed; but in some cases some symbols are difficult and have to be
# exported/imported manually. For these cases, the library header
# files can use this preprocessor define to know that they are
# included during compilation of the library itself, or are being
# imported by external code. Typically with the new DLL support if a
# symbol can't be imported you have to mark it with
# __declspec(dllimport) when the library is not being compiled.
# __declspec(dllexport) is not particularly useful instead.
CLEAN_library_NAME = $(subst -,_,$(LIBRARY_NAME_WITH_LIB))
SHARED_CFLAGS += -DBUILD_$(CLEAN_library_NAME)_DLL=1
# OLD_DLL_SUPPORT should really be deprecated and dropped.
ifeq ($(OLD_DLL_SUPPORT),yes)
LIBRARY_FILE = $(LIBRARY_NAME_WITH_LIB)$(LIBRARY_NAME_SUFFIX)$(DLL_LIBEXT)
DLL_NAME = $(shell echo $(LIBRARY_FILE)|cut -b 4-)
DLL_EXP_LIB = $(LIBRARY_NAME_WITH_LIB)$(LIBRARY_NAME_SUFFIX)$(SHARED_LIBEXT)
DLL_EXP_DEF = $(LIBRARY_NAME_WITH_LIB)$(LIBRARY_NAME_SUFFIX).def
else
# BUILD_DLL, but new DLL support.
# LIBRARY_FILE is the import library, libgnustep-base.dll.a
LIBRARY_FILE = $(LIBRARY_NAME_WITH_LIB)$(LIBRARY_NAME_SUFFIX)$(DLL_LIBEXT)$(LIBEXT)
VERSION_LIBRARY_FILE = $(LIBRARY_FILE)
SONAME_LIBRARY_FILE = $(LIBRARY_FILE)
# LIB_LINK_DLL_FILE is the DLL library, gnustep-base.dll
LIB_LINK_DLL_FILE = $(LIBRARY_NAME_WITHOUT_LIB)$(LIBRARY_NAME_SUFFIX)$(DLL_LIBEXT)
endif # OLD_DLL_SUPPORT
endif # BUILD_DLL
else # shared
else # following code for static libs
LIBRARY_FILE = $(LIBRARY_NAME_WITH_LIB)$(LIBRARY_NAME_SUFFIX)$(LIBEXT)
LIBRARY_FILE_EXT = $(LIBEXT)
VERSION_LIBRARY_FILE = $(LIBRARY_FILE)
SONAME_LIBRARY_FILE = $(LIBRARY_FILE)
@ -214,7 +242,7 @@ LIB_LINK_INSTALL_DIR = $(FINAL_LIBRARY_INSTALL_DIR)
# Compilation targets
#
ifeq ($(BUILD_DLL),yes)
ifeq ($(OLD_DLL_SUPPORT),yes)
DLL_DEF = $($(GNUSTEP_INSTANCE)_DLL_DEF)
DLL_DEF_FILES = $(SUBPROJECT_DEF_FILES) $(DLL_DEF)
@ -228,13 +256,6 @@ $(DLL_DEF_INP): $(DLL_DEF_FILES)
DLL_DEF_FLAG = --input-def $(DLL_DEF_INP)
endif
# Pass -DBUILD_lib{library_name}_DLL=1 to the preprocessor. The
# library header files can use this preprocessor define to know that
# they are included during compilation of the library itself, and can
# then use __declspec(dllexport) to export symbols
CLEAN_library_NAME = $(shell echo $(LIBRARY_NAME_WITH_LIB)|tr '-' '_')
SHARED_CFLAGS += -DBUILD_$(CLEAN_library_NAME)_DLL=1
internal-library-all_:: \
$(GNUSTEP_OBJ_DIR) \
$(DERIVED_SOURCES_DIR) \
@ -265,7 +286,7 @@ $(GNUSTEP_OBJ_DIR)/$(DLL_NAME): $(OBJ_FILES_TO_LINK) \
$(INTERNAL_LIBRARIES_DEPEND_UPON) $(TARGET_SYSTEM_LIBS) \
$(SHARED_LD_POSTFLAGS)$(END_ECHO)
else # BUILD_DLL
else # following code for anything but OLD_DLL_SUPPORt
internal-library-all_:: $(GNUSTEP_OBJ_DIR) \
$(GNUSTEP_OBJ_DIR)/$(VERSION_LIBRARY_FILE)
@ -294,7 +315,7 @@ $(FINAL_LIBRARY_INSTALL_DIR):
$(DLL_INSTALLATION_DIR):
$(ECHO_CREATING)$(MKINSTALLDIRS) $@$(END_ECHO)
ifeq ($(BUILD_DLL),yes)
ifeq ($(OLD_DLL_SUPPORT),yes)
internal-install-lib::
$(ECHO_INSTALLING)if [ -f $(GNUSTEP_OBJ_DIR)/$(DLL_NAME) ]; then \
@ -315,9 +336,17 @@ internal-install-lib::
$(AFTER_INSTALL_LIBRARY_CMD) \
fi$(END_ECHO)
ifeq ($(BUILD_DLL),yes)
# For new-style DLLs, also install the DLL file.
internal-install-lib::
$(ECHO_INSTALLING)if [ -f $(GNUSTEP_OBJ_DIR)/$(LIB_LINK_DLL_FILE) ]; then \
$(INSTALL_PROGRAM) $(GNUSTEP_OBJ_DIR)/$(LIB_LINK_DLL_FILE) \
$(DLL_INSTALLATION_DIR) ; \
fi$(END_ECHO)
endif
endif
ifeq ($(BUILD_DLL),yes)
ifeq ($(OLD_DLL_SUPPORT),yes)
internal-library-uninstall_:: shared-instance-headers-uninstall
$(ECHO_UNINSTALLING)rm -f $(DLL_INSTALLATION_DIR)/$(DLL_NAME) \
@ -329,6 +358,12 @@ internal-library-uninstall_:: shared-instance-headers-uninstall
$(ECHO_UNINSTALLING)rm -f $(FINAL_LIBRARY_INSTALL_DIR)/$(VERSION_LIBRARY_FILE) \
$(FINAL_LIBRARY_INSTALL_DIR)/$(LIBRARY_FILE) \
$(FINAL_LIBRARY_INSTALL_DIR)/$(SONAME_LIBRARY_FILE)$(END_ECHO)
ifeq ($(BUILD_DLL),yes)
# For new-style DLLs, also remove the DLL file.
internal-library-uninstall_::
$(ECHO_UNINSTALLING)rm -f $(DLL_INSTALLATION_DIR)/$(LINK_LIBRARY_DLL_FILE)$(END_ECHO)
endif
endif
#

View file

@ -307,7 +307,13 @@ ALL_CPLISTFLAGS += $(ADDITIONAL_CPLISTFLAGS) $(AUXILIARY_CPLISTFLAGS)
# case use __declspec(dllimport) to mark symbols as needing to be put
# into the import table for the executable/library/whatever that is
# being compiled.
ifeq ($(WITH_DLL),yes)
#
# In the new DLL support, this is usually no longer needed. The
# compiler does it all automatically. But in some cases, some symbols
# can not be automatically imported and you might want to declare them
# specially. For those symbols, this define is handy.
#
ifeq ($(BUILD_DLL),yes)
ALL_CPPFLAGS += -DGNUSTEP_WITH_DLL
endif

View file

@ -45,18 +45,18 @@ endif
endif
ifeq ($(findstring mingw32, $(GNUSTEP_TARGET_OS)), mingw32)
TARGET_SYSTEM_LIBS := $(CONFIG_SYSTEM_LIBS) \
TARGET_SYSTEM_LIBS = $(CONFIG_SYSTEM_LIBS) \
-lws2_32 -ladvapi32 -lcomctl32 -luser32 -lcomdlg32 \
-lmpr -lnetapi32 -lm -I. # the -I is a dummy to avoid -lm^M
endif
ifeq ($(findstring cygwin, $(GNUSTEP_TARGET_OS)), cygwin)
TARGET_SYSTEM_LIBS := $(CONFIG_SYSTEM_LIBS) -lm -I.
TARGET_SYSTEM_LIBS = $(CONFIG_SYSTEM_LIBS) -lm -I.
endif
ifeq ($(findstring solaris, $(GNUSTEP_TARGET_OS)), solaris)
TARGET_SYSTEM_LIBS := $(CONFIG_SYSTEM_LIBS) -lsocket -lnsl -lm
TARGET_SYSTEM_LIBS = $(CONFIG_SYSTEM_LIBS) -lsocket -lnsl -lm
endif
ifeq ($(findstring sysv4.2, $(GNUSTEP_TARGET_OS)), sysv4.2)
TARGET_SYSTEM_LIBS := $(CONFIG_SYSTEM_LIBS) -lsocket -lnsl -lm
TARGET_SYSTEM_LIBS = $(CONFIG_SYSTEM_LIBS) -lsocket -lnsl -lm
endif
#
@ -85,7 +85,14 @@ endif
# for frameworks.
# LIB_LINK_VERSION_FILE: the final file to create, having full
# version information: typically `libgnustep-base.so.1.5.3' for shared
# libraries, and `libgnustep-base.a' for static libraries.
# libraries, and `libgnustep-base.a' for static libraries. For DLL
# libraries, this is the import library libgnustep-base.dll.a. The
# reason we use the import library is because that is the code which
# needs to be installed in the library path. So by setting
# LIB_LINK_VERSION_FILE to the import library, the standard code to
# install it in the library path will work for Windows. The DLL
# library instead needs to be installed in the PATH, so we have separate
# code for that one.
# LIB_LINK_SONAME_FILE: this is only used for shared libraries; it
# should be passed in the -Wl,-soname argument of most linkers when
# building the LIB_LINK_VERSION_FILE. Typically `libgnustep-base.so.1'
@ -102,7 +109,13 @@ endif
# LIB_LINK_INSTALL_NAME: on some platforms, when a shared library is
# linked, a default install name of the library is hardcoded into
# the library. This is that name.
#
# LIB_LINK_DLL_FILE: on Windows, this is the DLL that gets created
# and installed in the Tools/ directory (eg, gnustep-base.dll).
# Please note that while this is the main file you need to use the
# library at runtime, on Windows we treat this as a side-effect of
# the compilation; the compilation target for make is
# LIB_LINK_VERSION_FILE, which is the import library.
# AFTER_INSTALL_SHARED_LIB_CMD provides commands to be executed after
# installation (at least for libraries, not for frameworks at the
# moment), and is supposed to setup symlinks properly in the
@ -853,12 +866,21 @@ endif
ifeq ($(findstring mingw32, $(GNUSTEP_TARGET_OS)), mingw32)
shared = yes
HAVE_SHARED_LIBS = yes
# This command links the library, generates automatically the list of
# symbols to export, creates the DLL (eg, obj/gnustep-base.dll) and
# the import library (eg, obj/libgnustep-base.dll.a).
SHARED_LIB_LINK_CMD = \
$(CC) $(SHARED_LD_PREFLAGS) -shared -Wl,--out-implib,$(LIB_LINK_OBJ_DIR)/$(LIB_LINK_VERSION_FILE) \
$(ALL_LDFLAGS) -o $(LIB_LINK_OBJ_DIR)/$(LIB_LINK_DLL_FILE) $^ \
$(INTERNAL_LIBRARIES_DEPEND_UPON) \
$(SHARED_LD_POSTFLAGS)
AFTER_INSTALL_SHARED_LIB_CMD =
AFTER_INSTALL_SHARED_LIB_CHOWN =
BUILD_DLL = yes
WITH_DLL = yes
SHARED_LIBEXT = .a
LIBEXT = .a
DLL_LIBEXT = .dll
DLLTOOL = dlltool
DLLWRAP = dllwrap
#SHARED_CFLAGS +=
OBJ_MERGE_CMD = \
@ -881,7 +903,7 @@ ifeq ($(findstring cygwin, $(GNUSTEP_TARGET_OS)), cygwin)
shared = yes
HAVE_SHARED_LIBS = yes
BUILD_DLL = yes
WITH_DLL = yes
OLD_DLL_SUPPORT = yes
SHARED_LIBEXT = .a
DLL_LIBEXT = .dll
DLLTOOL = dlltool