Permalink
Switch branches/tags
version-14_01_1 version-14_01 version-13_05_2 version-13_05_1 version-13_05 version-12_08-branchpoint version-12_08-GIT version-11_07_2 version-11_07_1 version-11_07 version-11_07-branchpoint version-11_01 version-11_01-branchpoint version-10_04_2 version-10_04_1 version-10_04 version-10_04-branchpoint version-0_13_1 version-0_13-branchpoint version-0_12_2 version-0_12_1 version-0_12-branchpoint version-0_11_0 version-0_11-branchpoint version-0_10 version-0_9_1 version-0_9 version-0_9_x-snapshot version-0_9_x-snapshot-19991220 unstable-version-0_13_1-x86_64-unknown-linux-gnu-libc2_3 unstable-version-0_13_1-i686-pc-linux-libc2_3-gnu-O5-intermod unstable-version-0_13-branch-x86_64-unknown-linux-gnu-libc2_3 unstable-version-0_13-branch-i686-pc-linux-libc2_3-gnu-O5-intermod unstable-version-0_12_2-i686-pc-linux-libc2_2-gnu-O5-intermod unstable-version-0_12_2-i386-pc-solaris2_8 unstable-version-0_12_1-i686-pc-linux-libc2_3-gnu-O4-intermod unstable-version-0_12_1-i686-pc-linux-libc2_3-gnu-O2 unstable-version-0_12_1-i686-pc-linux-libc2_2-gnu-O5-intermod unstable-version-0_12_1-i386-pc-solaris2_8 unstable-version-0_12-branch-i686-pc-linux-libc2_3-gnu-O5 unstable-version-0_12-branch-i686-pc-linux-libc2_3-gnu-O4-intermod unstable-version-0_12-branch-i686-pc-linux-libc2_3-gnu-O4-hlc unstable-version-0_12-branch-i686-pc-linux-libc2_3-gnu-O2 unstable-version-0_12-branch-i686-pc-linux-libc2_2-gnu-O5 unstable-version-0_12-branch-i686-pc-linux-libc2_2-gnu-O5-intermod unstable-version-0_12-branch-i686-pc-linux-libc2_2-gnu-O3 unstable-version-0_12-branch-i386-pc-solaris2_8 unstable-version-0_11_0-sparc-sun-solaris2_7 unstable-version-0_11_0-i686-pc-linux-libc2_3-gnu-O5-intermod unstable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5 unstable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5-lcc unstable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5-hlc unstable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O4 unstable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O4-asm unstable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O3 unstable-version-0_11_0-i386-pc-solaris2_8 unstable-version-0_11-branch-i686-pc-linux-libc2_3-gnu-O5-intermod unstable-version-0_11-branch-i686-pc-linux-libc2_2-gnu-O5-intermod unstable-version-0_11-branch-i686-pc-linux-libc2_2-gnu-O5-hlc unstable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5 unstable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-lcc unstable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-intermod unstable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-hlc unstable-version-0_11-branch-alpha-dec-osf5_1 unstable-version-0_10_y-sparc-sun-solaris2_7 unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O5 unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O5-lcc unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O5-intermod unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O5-hlc unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O4 unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O4-hlc unstable-version-0_10_y-i686-pc-linux-libc2_1-gnu-O2 unstable-version-0_10_y-i586-pc-linux-libc2_1-gnu-O0 unstable-version-0_10_y-alpha-dec-osf5_1 unstable-version-0_10_y-alpha-dec-osf3_2 unstable-version-0_10_x-sparc-sun-solaris2_7 unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O5 unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O5-lcc unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O4 unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O4-hlc unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O3 unstable-version-0_10_x-i686-pc-linux-libc2_1-gnu-O2 unstable-version-0_10_x-i586-pc-linux-libc2_1-gnu-O0 unstable-version-0_10_x-alpha-dec-osf3_2 termination2_trunk stable-version-0_11_0-i686-pc-linux-libc2_3-gnu-O5-intermod stable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5 stable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5-lcc stable-version-0_11_0-i686-pc-linux-libc2_2-gnu-O5-hlc stable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O4 stable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O4-asm stable-version-0_11_0-i686-pc-linux-libc2_1-gnu-O3 stable-version-0_11-branch-i686-pc-linux-libc2_3-gnu-O5-intermod stable-version-0_11-branch-i686-pc-linux-libc2_2-gnu-O5-lcc stable-version-0_11-branch-i686-pc-linux-libc2_2-gnu-O5-intermod stable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5 stable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-lcc stable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-intermod stable-version-0_11-branch-i686-pc-linux-libc2_1-gnu-O5-hlc stable-version-0_11-branch-alpha-dec-osf5_1
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
198 lines (170 sloc) 7.2 KB
#-----------------------------------------------------------------------------#
# Copyright (C) 1997-1998 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
# Makefile.DLLs, version 0.5b.
# This Makefile contains rules for creating DLLs on Windows using gnu-win32.
#-----------------------------------------------------------------------------#
# The SYM_PREFIX is used as a prefix for the symbols in the files
# that this makefile automatically generates.
#
# The default SYM_PREFIX for libfoo.dll is `libfoo'.
# But you can override this by setting `SYM_PREFIX-libfoo = blah'.
SYM_PREFIX = $(firstword $(SYM_PREFIX-$*) $*)
GUARD_MACRO = $(SYM_PREFIX)_GLOBALS_H
DEFINE_DLL_MACRO = $(SYM_PREFIX)_DEFINE_DLL
USE_DLL_MACRO = $(SYM_PREFIX)_USE_DLL
IMP_MACRO = $(SYM_PREFIX)_IMP
GLOBAL_MACRO = $(SYM_PREFIX)_GLOBAL
IMPURE_PTR = $(SYM_PREFIX)_impure_ptr
# You should change your rule for creating `foo.a' to instead
# create `foo$(DLL_DEF_LIB).a'. Then this makefile will create
# `foo.a' from `foo_def.a'.
DLL_DEF_LIB = _def
# This rule creates a `.def' file, which lists the symbols that are exported
# from the DLL. We use `nm' to get a list of all the exported text (`T')
# symbols and data symbols -- including uninitialized data (`B'),
# initialized data (`D'), read-only data (`R'), and common blocks (`C').
# We also export `_impure_ptr', suitably renamed, so that the
# main program can do the necessary initialization of the DLL's _impure_ptr.
# (Since there can be more than one DLL, we must rename _impure_ptr as
# $(SYM_PREFIX)_impure_ptr to prevent name collisions.)
%.def: %_def.a
echo EXPORTS > $@
echo $(IMPURE_PTR) = _impure_ptr >> $@
nm $< | sed -n '/^........ [BCDRT] _/s/[^_]*_//p' >> $@
# We need to use macros to access global data:
# the user of the DLL must refer to `bar' as `(*__imp_bar)'.
# This rule creates a pair of files `foo_dll.h' and `foo_globals.h'
# which contains macros for doing this.
#
# The DLL may also contain some references to _impure_ptr
# (e.g. stdin is defined as a macro which expands to _impure_ptr.stdin).
# We need to provide a definition for this (otherwise it will link in
# the definition in libccrt.o, which causes lots of problems,
# eventually leading to undefined symbol `WinMain').
# The main program needs to initialize all the _impure_ptr variables
# for the DLLs with its _impure_ptr.
%_dll.h:
echo "/* automatically generated by Makefile.DLLs */" > $@
echo "#ifndef $(GUARD_MACRO)" >> $@
echo "#define $(GUARD_MACRO)" >> $@
echo "" >> $@
echo "#if defined(__GNUC__) && defined(__CYGWIN32__)" >> $@
echo " #if !defined($(DEFINE_DLL_MACRO))" >> $@
echo " #define $(IMP_MACRO)(name) __imp_##name" >> $@
echo " #define $(GLOBAL_MACRO)(name) (*$(IMP_MACRO)(name))" >> $@
echo " #include \"$*_globals.h\"" >> $@
echo " #endif /* $(DEFINE_DLL_MACRO) */" >> $@
echo "#endif /* __GNUC__ && __CYGWIN32__ */" >> $@
echo "" >> $@
echo "#endif /* $(GUARD_MACRO) */" >> $@
%_globals.h: %_def.a
echo "/* automatically generated by Makefile.DLLs */" > $@
for sym in $(IMPURE_PTR) \
`nm $< | grep '^........ [BCDR] _' | sed 's/[^_]*_//'`; \
do \
echo "#define $$sym $(GLOBAL_MACRO)($$sym)" >> $@; \
done
%_dll.c:
echo "/* automatically generated by Makefile.DLLs */" > $@
echo "void *_impure_ptr;" >> $@
# This rule creates the export object file (`foo.exp') which contains the
# jump table array; this export object file becomes part of the DLL.
# This rule also creates the import library (`foo.a') which contains small
# stubs for all the functions exported by the DLL which jump to them via the
# jump table. Executables that will use the DLL must be linked against this
# stub library.
%.exp %.a : %.def
dlltool $(DLLTOOLFLAGS) $(DLLTOOLFLAGS-$*) \
--def $< \
--dllname $*.dll \
--output-exp $*.exp \
--output-lib $*.a
# The `sed' commands below are to convert DOS-style `C:\foo\bar'
# pathnames into Unix-style `//c/foo/bar' pathnames.
CYGWIN32_LIBS = $(shell echo \
-L`dirname \`gcc -print-file-name=libgcc.a | \
sed -e 's@^\\\\([A-Za-z]\\\\):@//\\\\1@g' -e 's@\\\\\\\\@/@g' \` ` \
-L`dirname \`gcc -print-file-name=libcygwin.a | \
sed -e 's@^\\\\([A-Za-z]\\\\):@//\\\\1@g' -e 's@\\\\\\\\@/@g' \` ` \
-L`dirname \`gcc -print-file-name=libkernel32.a | \
sed -e 's@^\\\\([A-Za-z]\\\\):@//\\\\1@g' -e 's@\\\\\\\\@/@g' \` ` \
-lgcc -lcygwin -lkernel32 -lgcc)
# Making relocatable DLLs doesn't seem to work.
# Note quite sure why. The --image-base values below
# where chosen at random, the first two at least seem to work on my machine.
RELOCATABLE=no
LDFLAGS-libgc += --image-base=0x2345000
LDFLAGS-libmer_rt += --image-base=0x1234000
LDFLAGS-libmer_std += --image-base=0x3456000
LDFLAGS-libmer_trace += --image-base=0x4567000
LDFLAGS-libmer_browser += --image-base=0x5678000
ifeq "$(strip $(RELOCATABLE))" "yes"
# to create relocatable DLLs, we need to do two passes
# (warning: this is untested)
%.dll: %.exp %_def.a %_dll.o dll_init.o dll_fixup.o
$(LD) $(LDFLAGS) $(LDFLAGS-$*) --dll -o $*.base \
-e _dll_entry@12 \
$*.exp $*_def.a $*_dll.o \
dll_init.o dll_fixup.o \
$(LDLIBS) $(LDLIBS-$*) \
$(CYGWIN32_LIBS)
# untested
dlltool $(DLLTOOLFLAGS) $(DLLTOOLFLAGS-$*) \
--def $*.def \
--dllname $*.dll \
--base-file $*.base \
--output-exp $*.exp
$(LD) $(LDFLAGS) $(LDFLAGS-$*) --dll -o $*.base \
-e _dll_entry@12 \
$*.exp $*_def.a $*_dll.o \
dll_init.o dll_fixup.o \
$(LDLIBS) $(LDLIBS-$*) \
$(CYGWIN32_LIBS)
dlltool $(DLLTOOLFLAGS) $(DLLTOOLFLAGS-$*) \
--def $*.def \
--dllname $*.dll \
--base-file $*.base \
--output-exp $*.exp
# end untested stuff
$(LD) $(LDFLAGS) $(LDFLAGS-$*) --dll --base-file $*.base -o $@ \
-e _dll_entry@12 \
$*.exp $*_def.a $*_dll.o \
dll_init.o dll_fixup.o \
$(LDLIBS) $(LDLIBS-$*) \
$(CYGWIN32_LIBS)
rm -f $*.base
else
%.dll: %.exp %_def.a %_dll.o dll_fixup.o dll_init.o
$(LD) $(LDFLAGS) $(LDFLAGS-$*) --dll -o $@ \
-e _dll_entry@12 \
$*.exp $*_def.a $*_dll.o \
dll_init.o dll_fixup.o \
$(LDLIBS) $(LDLIBS-$*) \
$(CYGWIN32_LIBS)
endif
# This black magic piece of assembler needs to be linked in in order to
# properly terminate the list of imported DLLs.
dll_fixup.s:
echo '.section .idata$$3' > dll_fixup.s
echo '.long 0,0,0,0, 0,0,0,0' >> dll_fixup.s
dll_fixup.o: dll_fixup.s
$(AS) $(ASFLAGS) -o dll_fixup.o dll_fixup.s
# Windows requires each DLL to have an initialization function
# that is called at certain points (thread/process attach/detach).
# This one just doesn't do anything.
dll_init.c:
echo '__attribute__((stdcall))' > dll_init.c
echo 'int dll_entry(int handle, int reason, void *ptr)' >> dll_init.c
echo '{ return 1; }' >> dll_init.c
# The following rule is just there to convince gcc
# to keep otherwise unused intermediate targets around.
dont_throw_away: dll_fixup.o dll_init.o
.PHONY: clean
clean: clean_dll
.PHONY: clean_dll
clean_dll:
-rm -f dll_init.c dll_init.o dll_fixup.s dll_fixup.o
#-----------------------------------------------------------------------------#