]> wimlib.net Git - wimlib/blob - tools/windeps/Makefile
Update libxml to 2.9.8 for Windows binaries
[wimlib] / tools / windeps / Makefile
1 #
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'
6 # file.
7 #
8 # This Makefile requires a GNU toolchain with MinGW-w64 (i686 and x86_64
9 # versions).
10 #
11
12 ARCHITECTURES           := i686 x86_64
13 LIBXML2_VERSION         := 2.9.8
14 WINPTHREADS_VERSION     := 5.0.3
15
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
18
19
20 LIBXML_SRCDIR           := libxml2-$(LIBXML2_VERSION)
21 LIBXML_DIST             := $(LIBXML_SRCDIR).tar.gz
22 SRCDIR_TARGETS          += $(LIBXML_SRCDIR)
23 DIST_TARGETS            += $(LIBXML_DIST)
24 $(LIBXML_DIST):
25         wget $(LIBXML_URL)
26 $(LIBXML_SRCDIR):$(LIBXML_DIST) checksums_verified
27         tar xvf $<
28         cp $@/COPYING COPYING.libxml2
29 MAKE_CLEAN_FILES += $(LIBXML_SRCDIR) COPYING.libxml2
30
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)
35 $(WINPTHREADS_DIST):
36         wget $(WINPTHREADS_URL)
37 $(WINPTHREADS_SRCDIR):$(WINPTHREADS_DIST) checksums_verified
38         tar xvf $<
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
42
43 checksums_verified:$(DIST_TARGETS)
44         sha256sum -c sha256sums
45
46 #
47 # declare_libxml_target(arch)
48 #
49 define declare_libxml_target
50 libxml_$(1):$(LIBXML_SRCDIR)
51         builddir=build_libxml_$(1);                             \
52         rm -rf $$$$builddir;                                    \
53         mkdir $$$$builddir;                                     \
54         cd $$$$builddir;                                        \
55         ../$(LIBXML_SRCDIR)/configure                           \
56                 --host=$(1)-w64-mingw32                         \
57                 --enable-static                                 \
58                 --disable-shared                                \
59                 --prefix=$$$$PWD/../sysroot_$(1)                \
60                 CFLAGS=-Os                                      \
61                 --with-minimum                                  \
62                 --without-lzma                                  \
63                 --with-tree                                     \
64                 --with-writer;                                  \
65         $(MAKE) install;                                        \
66         rm -f ../sysroot_$(1)/lib/libxml2.la;
67
68 $(1)_BUILD_TARGETS += libxml_$(1)
69 MAKE_CLEAN_FILES += build_libxml_$(1)
70 endef
71
72 #
73 # declare_winpthreads_target(arch)
74 #
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;               \
80         cd $$$$builddir;                                        \
81         ./configure                                             \
82                 --host=$(1)-w64-mingw32                         \
83                 --enable-static                                 \
84                 --disable-shared                                \
85                 --prefix=$$$$PWD/../sysroot_$(1)                \
86                 CFLAGS=-O2;                                     \
87         $(MAKE) install;                                        \
88         sed -i -e 's/if defined DLL_EXPORT/if 0/'               \
89                -e 's/pthread_getevent ()/pthread_getevent (void)/'\
90                 ../sysroot_$(1)/include/pthread.h;
91
92 $(1)_BUILD_TARGETS += winpthreads_$(1)
93 MAKE_CLEAN_FILES += build_winpthreads_$(1)
94 endef
95
96 #
97 # declare_arch_targets(arch)
98 #
99 define declare_arch_targets
100 $(eval $(call declare_libxml_target,$(1)))
101 $(eval $(call declare_winpthreads_target,$(1)))
102
103 sysroot_$(1): $($(1)_BUILD_TARGETS)
104
105 ALL_SYSROOTS += sysroot_$(1)
106 MAKE_CLEAN_FILES += sysroot_$(1)
107 endef
108
109 $(foreach arch,$(ARCHITECTURES),$(eval $(call declare_arch_targets,$(arch))))
110
111 all: $(ALL_SYSROOTS)
112
113 clean:
114         rm -rf $(MAKE_CLEAN_FILES) $(DIST_TARGETS)
115
116 .PHONY: all clean $(SRCDIR_TARGETS) checksums_verified
117
118 .DEFAULT_GOAL = all