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) \
58 rm -f ../sysroot_$(1)/lib/libxml2.la;
60 $(1)_BUILD_TARGETS += libxml_$(1)
61 MAKE_CLEAN_FILES += build_libxml_$(1)
65 # declare_winpthreads_target(arch)
67 define declare_winpthreads_target
68 winpthreads_$(1):$(WINPTHREADS_SRCDIR)
69 builddir=build_winpthreads_$(1); \
70 rm -rf $$$$builddir; \
71 cp -r $(WINPTHREADS_SRCDIR) $$$$builddir; \
74 --host=$(1)-w64-mingw32 \
77 --prefix=$$$$PWD/../sysroot_$(1) \
80 sed -i 's/if defined DLL_EXPORT/if 0/' ../sysroot_$(1)/include/pthread.h;
82 $(1)_BUILD_TARGETS += winpthreads_$(1)
83 MAKE_CLEAN_FILES += build_winpthreads_$(1)
87 # declare_winiconv_target(arch)
89 define declare_winiconv_target
90 winiconv_$(1):$(WINICONV_SRCDIR)
91 builddir=build_winiconv_$(1); \
92 rm -rf $$$$builddir; \
93 cp -r $(WINICONV_SRCDIR) $$$$builddir; \
95 $(MAKE) CC=$(1)-w64-mingw32-gcc \
96 AR=$(1)-w64-mingw32-ar \
97 RANLIB=$(1)-w64-mingw32-ranlib \
98 DLLTOOL=$(1)-w64-mingw32-dlltool \
100 prefix=$$$$PWD/../sysroot_$(1) \
102 rm -f ../sysroot_$(1)/lib/libiconv.dll.a;
104 $(1)_BUILD_TARGETS += winiconv_$(1)
105 MAKE_CLEAN_FILES += build_winiconv_$(1)
109 # declare_arch_targets(arch)
111 define declare_arch_targets
112 $(eval $(call declare_libxml_target,$(1)))
113 $(eval $(call declare_winpthreads_target,$(1)))
114 $(eval $(call declare_winiconv_target,$(1)))
116 sysroot_$(1): $($(1)_BUILD_TARGETS)
118 ALL_SYSROOTS += sysroot_$(1)
119 MAKE_CLEAN_FILES += sysroot_$(1)
122 $(foreach arch,$(ARCHITECTURES),$(eval $(call declare_arch_targets,$(arch))))
127 rm -rf $(MAKE_CLEAN_FILES)
129 .PHONY: all clean $(SOURCE_TARGETS)