--- /dev/null
+--- 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 "\r
+ | _ -> ""\r
+ in\r
+- Filename.dirname (get_output1 (Printf.sprintf "gcc %s-print-libgcc-file-name" extra))\r
++ Filename.dirname (get_output1 (Printf.sprintf "i686-pc-mingw32-gcc %s-print-libgcc-file-name" extra))\r
+ \r
+ let file_exists fn =\r
+ if Sys.file_exists fn then Some fn\r
+@@ -788,7 +788,7 @@
+ extra_args\r
+ | `MINGW ->\r
+ Printf.sprintf\r
+- "gcc -mno-cygwin %s%s -L. %s %s -o %s %s %s %s %s"\r
++ "i686-pc-mingw32-gcc %s%s -L. %s %s -o %s %s %s %s %s"\r
+ (if link_exe = `EXE then "" else "-shared ")\r
+ (if main_pgm then "" else if !noentry then "-Wl,-e0 " else "-Wl,-e_FlexDLLiniter@12 ")\r
+ (mk_dirs_opt "-I")\r
+@@ -860,9 +860,7 @@
+ | `MINGW ->\r
+ search_path :=\r
+ !dirs @\r
+- [ "/lib";\r
+- "/lib/mingw";\r
+- "/lib/w32api";\r
++ [ "/usr/i686-pc-mingw32/sys-root/mingw/lib";\r
+ gcclib () ];\r
+ default_libs :=\r
+ ["-lmingw32"; "-lgcc"; "-lmoldname"; "-lmingwex"; "-lmsvcrt";\r
+@@ -891,7 +889,7 @@
+ file\r
+ | `MINGW ->\r
+ Printf.sprintf\r
+- "gcc -mno-cygwin -c -o %s %s %s"\r
++ "i686-pc-mingw32-gcc -c -o %s %s %s"\r
+ (Filename.quote tmp_obj)\r
+ (mk_dirs_opt "-I")\r
+ file\r
+--- 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:\r
+ PACKAGE_BIN_SUFFIX=-amd64 $(MAKE) upload_bin\r
+ \r
+-include $(shell cygpath -ad "$(shell ocamlopt -where)/Makefile.config")\r
++#include $(shell cygpath -ad "$(shell ocamlopt -where)/Makefile.config")\r
+ \r
+ show_toolchain:\r
+ @echo Toolchain for the visible ocamlopt: $(TOOLCHAIN)\r
--- /dev/null
+%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 <rjones@redhat.com> - 0.11-1
+- Initial RPM release.