2 # This Makefile builds the third-party libraries needed to build a standalone
3 # libwim.dll for Windows. We build these third-party libraries ourselves mainly
4 # to cut down on bloat.
6 # Among other things, this Makefile requires MinGW-w64 (i686 and x86_64
7 # versions) and a windeps.wim containing the following images:
9 # - libxml2-2.9.2 [contents of ftp://xmlsoft.org/libxml2/libxml2-2.9.2.tar.gz]
10 # - winpthreads-4.0.4 [directory mingw-w64-libraries/winpthreads from http://downloads.sourceforge.net/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v4.0.4.tar.bz2]
11 # - win-iconv-0.0.6 [contents of https://win-iconv.googlecode.com/files/win-iconv-0.0.6.tar.bz2]
13 ARCHITECTURES := i686 x86_64
14 LIBXML_VERSION := 2-2.9.2
15 WINPTHREADS_VERSION := -4.0.4
16 WINICONV_VERSION := -0.0.6
18 LIBXML_SRCDIR := libxml$(LIBXML_VERSION)
19 SOURCE_TARGETS += $(LIBXML_SRCDIR)
21 wimapply --unix-data windeps.wim $(LIBXML_SRCDIR) $(LIBXML_SRCDIR)
22 cp $(LIBXML_SRCDIR)/COPYING COPYING.libxml2
23 MAKE_CLEAN_FILES += $(LIBXML_SRCDIR) COPYING.libxml2
25 WINPTHREADS_SRCDIR := winpthreads$(WINPTHREADS_VERSION)
26 SOURCE_TARGETS += $(WINPTHREADS_SRCDIR)
27 $(WINPTHREADS_SRCDIR):
28 wimapply --unix-data windeps.wim $(WINPTHREADS_SRCDIR) $(WINPTHREADS_SRCDIR)
29 cp $(WINPTHREADS_SRCDIR)/COPYING COPYING.winpthreads
30 MAKE_CLEAN_FILES += $(WINPTHREADS_SRCDIR) COPYING.winpthreads
32 WINICONV_SRCDIR := win-iconv$(WINICONV_VERSION)
33 SOURCE_TARGETS += $(WINICONV_SRCDIR)
35 wimapply --unix-data windeps.wim $(WINICONV_SRCDIR) $(WINICONV_SRCDIR)
36 # win-iconv is public domain, so there's no license file.
37 MAKE_CLEAN_FILES += $(WINICONV_SRCDIR)
40 # declare_libxml_target(arch)
42 define declare_libxml_target
43 libxml_$(1):$(LIBXML_SRCDIR)
44 builddir=build_libxml_$(1); \
45 rm -rf $$$$builddir; \
48 ../$(LIBXML_SRCDIR)/configure \
49 --host=$(1)-w64-mingw32 \
52 --prefix=$$$$PWD/../sysroot_$(1) \
59 rm -f ../sysroot_$(1)/lib/libxml2.la;
61 $(1)_BUILD_TARGETS += libxml_$(1)
62 MAKE_CLEAN_FILES += build_libxml_$(1)
66 # declare_winpthreads_target(arch)
68 define declare_winpthreads_target
69 winpthreads_$(1):$(WINPTHREADS_SRCDIR)
70 builddir=build_winpthreads_$(1); \
71 rm -rf $$$$builddir; \
72 cp -r $(WINPTHREADS_SRCDIR) $$$$builddir; \
75 --host=$(1)-w64-mingw32 \
78 --prefix=$$$$PWD/../sysroot_$(1) \
81 sed -i 's/if defined DLL_EXPORT/if 0/' ../sysroot_$(1)/include/pthread.h;
83 $(1)_BUILD_TARGETS += winpthreads_$(1)
84 MAKE_CLEAN_FILES += build_winpthreads_$(1)
88 # declare_winiconv_target(arch)
90 define declare_winiconv_target
91 winiconv_$(1):$(WINICONV_SRCDIR)
92 builddir=build_winiconv_$(1); \
93 rm -rf $$$$builddir; \
94 cp -r $(WINICONV_SRCDIR) $$$$builddir; \
96 $(MAKE) CC=$(1)-w64-mingw32-gcc \
97 AR=$(1)-w64-mingw32-ar \
98 RANLIB=$(1)-w64-mingw32-ranlib \
99 DLLTOOL=$(1)-w64-mingw32-dlltool \
101 prefix=$$$$PWD/../sysroot_$(1) \
103 rm -f ../sysroot_$(1)/lib/libiconv.dll.a;
105 $(1)_BUILD_TARGETS += winiconv_$(1)
106 MAKE_CLEAN_FILES += build_winiconv_$(1)
110 # declare_arch_targets(arch)
112 define declare_arch_targets
113 $(eval $(call declare_libxml_target,$(1)))
114 $(eval $(call declare_winpthreads_target,$(1)))
115 $(eval $(call declare_winiconv_target,$(1)))
117 sysroot_$(1): $($(1)_BUILD_TARGETS)
119 ALL_SYSROOTS += sysroot_$(1)
120 MAKE_CLEAN_FILES += sysroot_$(1)
123 $(foreach arch,$(ARCHITECTURES),$(eval $(call declare_arch_targets,$(arch))))
128 rm -rf $(MAKE_CLEAN_FILES)
130 .PHONY: all clean $(SOURCE_TARGETS)