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
16 LIBXML_URL := ftp://xmlsoft.org/libxml2/libxml2-$(LIBXML2_VERSION).tar.gz
17 WINPTHREADS_URL := http://downloads.sourceforge.net/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2
20 LIBXML_SRCDIR := libxml2-$(LIBXML2_VERSION)
21 LIBXML_DIST := $(LIBXML_SRCDIR).tar.gz
22 SRCDIR_TARGETS += $(LIBXML_SRCDIR)
23 DIST_TARGETS += $(LIBXML_DIST)
26 $(LIBXML_SRCDIR):$(LIBXML_DIST) checksums_verified
28 cp $@/COPYING COPYING.libxml2
29 MAKE_CLEAN_FILES += $(LIBXML_SRCDIR) COPYING.libxml2
31 WINPTHREADS_DIST := mingw-w64-v$(WINPTHREADS_VERSION).tar.bz2
32 WINPTHREADS_SRCDIR := winpthreads-$(WINPTHREADS_VERSION)
33 SRCDIR_TARGETS += $(WINPTHREADS_SRCDIR)
34 DIST_TARGETS += $(WINPTHREADS_DIST)
36 wget $(WINPTHREADS_URL)
37 $(WINPTHREADS_SRCDIR):$(WINPTHREADS_DIST) checksums_verified
39 cp -aT mingw-w64-v$(WINPTHREADS_VERSION)/mingw-w64-libraries/winpthreads $@
40 cp $@/COPYING COPYING.winpthreads
41 MAKE_CLEAN_FILES += $(WINPTHREADS_SRCDIR) mingw-w64-v$(WINPTHREADS_VERSION) COPYING.winpthreads
43 checksums_verified:$(DIST_TARGETS)
44 sha256sum -c sha256sums
47 # declare_libxml_target(arch)
49 define declare_libxml_target
50 libxml_$(1):$(LIBXML_SRCDIR)
51 builddir=build_libxml_$(1); \
52 rm -rf $$$$builddir; \
55 ../$(LIBXML_SRCDIR)/configure \
56 --host=$(1)-w64-mingw32 \
59 --prefix=$$$$PWD/../sysroot_$(1) \
66 rm -f ../sysroot_$(1)/lib/libxml2.la;
68 $(1)_BUILD_TARGETS += libxml_$(1)
69 MAKE_CLEAN_FILES += build_libxml_$(1)
73 # declare_winpthreads_target(arch)
75 define declare_winpthreads_target
76 winpthreads_$(1):$(WINPTHREADS_SRCDIR)
77 builddir=build_winpthreads_$(1); \
78 rm -rf $$$$builddir; \
79 cp -r $(WINPTHREADS_SRCDIR) $$$$builddir; \
82 --host=$(1)-w64-mingw32 \
85 --prefix=$$$$PWD/../sysroot_$(1) \
88 sed -i 's/if defined DLL_EXPORT/if 0/' ../sysroot_$(1)/include/pthread.h;
90 $(1)_BUILD_TARGETS += winpthreads_$(1)
91 MAKE_CLEAN_FILES += build_winpthreads_$(1)
95 # declare_arch_targets(arch)
97 define declare_arch_targets
98 $(eval $(call declare_libxml_target,$(1)))
99 $(eval $(call declare_winpthreads_target,$(1)))
101 sysroot_$(1): $($(1)_BUILD_TARGETS)
103 ALL_SYSROOTS += sysroot_$(1)
104 MAKE_CLEAN_FILES += sysroot_$(1)
107 $(foreach arch,$(ARCHITECTURES),$(eval $(call declare_arch_targets,$(arch))))
112 rm -rf $(MAKE_CLEAN_FILES) $(DIST_TARGETS)
114 .PHONY: all clean $(SRCDIR_TARGETS) checksums_verified