From 7d78e8ae1963f5fb71fe43ebd5544397aa861e5c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] Added flexdll. --- .hgignore | 1 + flexdll/flexlink.exe | 4 + flexdll/mingw32-flexdll-0.11-mingw-cross.patch | 51 +++++++++++ flexdll/mingw32-flexdll.spec | 122 +++++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100755 flexdll/flexlink.exe create mode 100644 flexdll/mingw32-flexdll-0.11-mingw-cross.patch create mode 100644 flexdll/mingw32-flexdll.spec diff --git a/.hgignore b/.hgignore index add1d0e..9eeb858 100644 --- a/.hgignore +++ b/.hgignore @@ -20,6 +20,7 @@ curl/curl-7.18.2.tar.bz2 curl/test1 curl/*.exe expat/expat-2.0.1.tar.gz +flexdll/flexdll-0.11.tar.gz fontconfig/fontconfig-2.6.0.tar.gz freetype/freetype-2.3.7.tar.bz2 freetype/freetype-doc-2.3.7.tar.bz2 diff --git a/flexdll/flexlink.exe b/flexdll/flexlink.exe new file mode 100755 index 0000000..41724cd --- /dev/null +++ b/flexdll/flexlink.exe @@ -0,0 +1,4 @@ +#!/bin/sh - + +FLEXDIR=@libdir@/flexdll +@libdir@/flexdll/flexlink.exe \ No newline at end of file diff --git a/flexdll/mingw32-flexdll-0.11-mingw-cross.patch b/flexdll/mingw32-flexdll-0.11-mingw-cross.patch new file mode 100644 index 0000000..cfbcc7a --- /dev/null +++ b/flexdll/mingw32-flexdll-0.11-mingw-cross.patch @@ -0,0 +1,51 @@ +--- flexdll/reloc.ml 2008-11-06 12:54:58.000000000 +0000 ++++ flexdll.mingw/reloc.ml 2008-11-14 10:44:01.000000000 +0000 +@@ -106,7 +106,7 @@ + | `MINGW -> "-mno-cygwin " + | _ -> "" + in +- Filename.dirname (get_output1 (Printf.sprintf "gcc %s-print-libgcc-file-name" extra)) ++ Filename.dirname (get_output1 (Printf.sprintf "i686-pc-mingw32-gcc %s-print-libgcc-file-name" extra)) + + let file_exists fn = + if Sys.file_exists fn then Some fn +@@ -788,7 +788,7 @@ + extra_args + | `MINGW -> + Printf.sprintf +- "gcc -mno-cygwin %s%s -L. %s %s -o %s %s %s %s %s" ++ "i686-pc-mingw32-gcc %s%s -L. %s %s -o %s %s %s %s %s" + (if link_exe = `EXE then "" else "-shared ") + (if main_pgm then "" else if !noentry then "-Wl,-e0 " else "-Wl,-e_FlexDLLiniter@12 ") + (mk_dirs_opt "-I") +@@ -860,9 +860,7 @@ + | `MINGW -> + search_path := + !dirs @ +- [ "/lib"; +- "/lib/mingw"; +- "/lib/w32api"; ++ [ "/usr/i686-pc-mingw32/sys-root/mingw/lib"; + gcclib () ]; + default_libs := + ["-lmingw32"; "-lgcc"; "-lmoldname"; "-lmingwex"; "-lmsvcrt"; +@@ -891,7 +889,7 @@ + file + | `MINGW -> + Printf.sprintf +- "gcc -mno-cygwin -c -o %s %s %s" ++ "i686-pc-mingw32-gcc -c -o %s %s %s" + (Filename.quote tmp_obj) + (mk_dirs_opt "-I") + file +--- flexdll/Makefile 2008-11-10 13:26:25.000000000 +0000 ++++ flexdll.mingw/Makefile 2008-11-14 10:57:15.000000000 +0000 +@@ -113,7 +113,7 @@ + upload_bin_64: + PACKAGE_BIN_SUFFIX=-amd64 $(MAKE) upload_bin + +-include $(shell cygpath -ad "$(shell ocamlopt -where)/Makefile.config") ++#include $(shell cygpath -ad "$(shell ocamlopt -where)/Makefile.config") + + show_toolchain: + @echo Toolchain for the visible ocamlopt: $(TOOLCHAIN) diff --git a/flexdll/mingw32-flexdll.spec b/flexdll/mingw32-flexdll.spec new file mode 100644 index 0000000..c828c9d --- /dev/null +++ b/flexdll/mingw32-flexdll.spec @@ -0,0 +1,122 @@ +%define __strip %{_mingw32_strip} +%define __objdump %{_mingw32_objdump} +%define _use_internal_dependency_generator 0 +%define __find_requires %{_mingw32_findrequires} +%define __find_provides %{_mingw32_findprovides} + +%define debug_package %{nil} + +Name: mingw32-flexdll +Version: 0.11 +Release: 1%{?dist} +Summary: FlexDLL Windows DLL plugin API which is like dlopen + +License: zlib +Group: Development/Libraries + +URL: http://alain.frisch.fr/flexdll.html +Source0: http://alain.frisch.fr/flexdll/flexdll-%{version}.tar.gz +Source1: flexlink.exe + +# Patches for MinGW: +Patch1000: mingw32-flexdll-0.11-mingw-cross.patch + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: mingw32-filesystem >= 35 +BuildRequires: mingw32-gcc +BuildRequires: mingw32-binutils +BuildRequires: ocaml + + +%description +Under Windows, DLL (Dynamically-Linked Libraries) are generally used +to improve code modularity and sharing. A DLL can be loaded +automatically when the program is loaded (if it requires the DLL). The +program can also explicitly request Windows to load a DLL at any +moment during runtime, using the LoadLibrary function from the Win32 +API. + +This naturally suggests to use DLLs as a plugin mechanism. For +instance, a web server could load extensions modules stored in DLLs at +runtime. But Windows does not really make it easy to implement plugins +that way. The reason is that when you try to create a DLL from a set +of object files, the linker needs to resolve all the symbols, which +leads to the very problem solved by FlexDLL: + +Windows DLL cannot refer to symbols defined in the main application or +in previously loaded DLLs. + +Some usual solutions exist, but they are not very flexible. A notable +exception is the edll library (its homepage also describes the usual +solutions), which follows a rather drastic approach; indeed, edll +implements a new dynamic linker which can directly load object files +(without creating a Windows DLL). + +FlexDLL is another solution to the same problem. Contrary to edll, it +relies on the native static and dynamic linkers. Also, it works both +with the Microsoft environment (MS linker, Visual Studio compilers) +and with Cygwin (GNU linker and compilers, in Cygwin or MinGW +mode). Actually, FlexDLL implements mostly the usual dlopen POSIX API, +without trying to be fully conformant though (e.g. it does not respect +the official priority ordering for symbol resolution). This should +make it easy to port applications developed for Unix. + + +%prep +%setup -q -n flexdll + +%patch1000 -p1 + +for f in CHANGES LICENSE README; do + chmod -x $f + dos2unix $f +done + + +%build +make TOOLCHAIN=mingw MINCC=%{_mingw32_cc} CC=%{_mingw32_cc} \ + flexlink.exe build_mingw + +strip flexlink.exe + + +%check +make -C test CC=%{_mingw32_cc} O=o CHAIN=mingw + + +%install +rm -rf $RPM_BUILD_ROOT + +mkdir -p $RPM_BUILD_ROOT%{_bindir} +mkdir -p $RPM_BUILD_ROOT%{_libdir}/flexdll + +# Install everything in a libdir directory. Some of the files +# have execute permissions which we can remove. +install -m 0644 \ + flexdll.h flexdll.c flexdll_initer.c default.manifest flexdll_*.o \ + $RPM_BUILD_ROOT%{_libdir}/flexdll +install -m 0755 flexlink.exe \ + $RPM_BUILD_ROOT%{_libdir}/flexdll + +# Provide a wrapper script which sets FLEXDIR to point to the +# libdir directory. +sed 's,@libdir@,%{_libdir},g' \ + < %{SOURCE1} > $RPM_BUILD_ROOT%{_bindir}/flexlink.exe +chmod 0755 $RPM_BUILD_ROOT%{_bindir}/flexlink.exe + + +%clean +rm -rf $RPM_BUILD_ROOT + + +%files +%defattr(-,root,root) +%doc LICENSE README CHANGES +%{_bindir}/flexlink.exe +%{_libdir}/flexdll + + +%changelog +* Fri Nov 14 2008 Richard W.M. Jones - 0.11-1 +- Initial RPM release. -- 1.8.3.1