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. They are automatically downloaded from the URLs
5 # declared below and verified against the checksums given in the 'sha256sums'
8 # This Makefile requires a GNU toolchain with MinGW-w64 (i686 and x86_64
12 ARCHITECTURES := i686 x86_64
13 LIBXML2_VERSION := 2.9.4
14 WINPTHREADS_VERSION := 4.0.4
15 WINICONV_VERSION := 0.0.6
17 LIBXML_URL := ftp://xmlsoft.org/libxml2/libxml2-$(LIBXML2_VERSION).tar.gz
18 WINPTHREADS_URL := http://downloads.sourceforge.net/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2
19 WINICONV_URL := https://github.com/win-iconv/win-iconv/archive/$(WINICONV_VERSION).tar.gz
22 LIBXML_SRCDIR := libxml2-$(LIBXML2_VERSION)
23 LIBXML_DIST := $(LIBXML_SRCDIR).tar.gz
24 SRCDIR_TARGETS += $(LIBXML_SRCDIR)
25 DIST_TARGETS += $(LIBXML_DIST)
28 $(LIBXML_SRCDIR):$(LIBXML_DIST) checksums_verified
30 cp $@/COPYING COPYING.libxml2
31 MAKE_CLEAN_FILES += $(LIBXML_SRCDIR) COPYING.libxml2
33 WINPTHREADS_DIST := mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2
34 WINPTHREADS_SRCDIR := winpthreads-$(WINPTHREADS_VERSION)
35 SRCDIR_TARGETS += $(WINPTHREADS_SRCDIR)
36 DIST_TARGETS += $(WINPTHREADS_DIST)
38 wget $(WINPTHREADS_URL)
39 $(WINPTHREADS_SRCDIR):$(WINPTHREADS_DIST) checksums_verified
41 cp -aT mingw-w64-v$(WINPTHREADS_VERSION)/mingw-w64-libraries/winpthreads $@
42 cp $@/COPYING COPYING.winpthreads
43 MAKE_CLEAN_FILES += $(WINPTHREADS_SRCDIR) mingw-w64-v$(WINPTHREADS_VERSION) COPYING.winpthreads
45 WINICONV_SRCDIR := win-iconv-$(WINICONV_VERSION)
46 WINICONV_DIST := $(WINICONV_VERSION).tar.gz
47 SRCDIR_TARGETS += $(WINICONV_SRCDIR)
48 DIST_TARGETS += $(WINICONV_DIST)
51 $(WINICONV_SRCDIR):$(WINICONV_DIST) checksums_verified
53 # win-iconv is public domain, so there's no license file.
54 MAKE_CLEAN_FILES += $(WINICONV_SRCDIR)
56 checksums_verified:$(DIST_TARGETS)
57 sha256sum -c sha256sums
60 # declare_libxml_target(arch)
62 define declare_libxml_target
63 libxml_$(1):$(LIBXML_SRCDIR)
64 builddir=build_libxml_$(1); \
65 rm -rf $$$$builddir; \
68 ../$(LIBXML_SRCDIR)/configure \
69 --host=$(1)-w64-mingw32 \
72 --prefix=$$$$PWD/../sysroot_$(1) \
79 rm -f ../sysroot_$(1)/lib/libxml2.la;
81 $(1)_BUILD_TARGETS += libxml_$(1)
82 MAKE_CLEAN_FILES += build_libxml_$(1)
86 # declare_winpthreads_target(arch)
88 define declare_winpthreads_target
89 winpthreads_$(1):$(WINPTHREADS_SRCDIR)
90 builddir=build_winpthreads_$(1); \
91 rm -rf $$$$builddir; \
92 cp -r $(WINPTHREADS_SRCDIR) $$$$builddir; \
95 --host=$(1)-w64-mingw32 \
98 --prefix=$$$$PWD/../sysroot_$(1) \
101 sed -i 's/if defined DLL_EXPORT/if 0/' ../sysroot_$(1)/include/pthread.h;
103 $(1)_BUILD_TARGETS += winpthreads_$(1)
104 MAKE_CLEAN_FILES += build_winpthreads_$(1)
108 # declare_winiconv_target(arch)
110 define declare_winiconv_target
111 winiconv_$(1):$(WINICONV_SRCDIR)
112 builddir=build_winiconv_$(1); \
113 rm -rf $$$$builddir; \
114 cp -r $(WINICONV_SRCDIR) $$$$builddir; \
116 $(MAKE) CC=$(1)-w64-mingw32-gcc \
117 AR=$(1)-w64-mingw32-ar \
118 RANLIB=$(1)-w64-mingw32-ranlib \
119 DLLTOOL=$(1)-w64-mingw32-dlltool \
121 prefix=$$$$PWD/../sysroot_$(1) \
123 rm -f ../sysroot_$(1)/lib/libiconv.dll.a;
125 $(1)_BUILD_TARGETS += winiconv_$(1)
126 MAKE_CLEAN_FILES += build_winiconv_$(1)
130 # declare_arch_targets(arch)
132 define declare_arch_targets
133 $(eval $(call declare_libxml_target,$(1)))
134 $(eval $(call declare_winpthreads_target,$(1)))
135 $(eval $(call declare_winiconv_target,$(1)))
137 sysroot_$(1): $($(1)_BUILD_TARGETS)
139 ALL_SYSROOTS += sysroot_$(1)
140 MAKE_CLEAN_FILES += sysroot_$(1)
143 $(foreach arch,$(ARCHITECTURES),$(eval $(call declare_arch_targets,$(arch))))
148 rm -rf $(MAKE_CLEAN_FILES) $(DIST_TARGETS)
150 .PHONY: all clean $(SRCDIR_TARGETS) checksums_verified