tools/windeps/Makefile: update sources list
[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.
5 #
6 # Among other things, this Makefile requires MinGW-w64 (i686 and x86_64
7 # versions) and a windeps.wim containing the following images:
8 #
9 #       - libxml2-2.9.2 [contents of ftp://xmlsoft.org/libxml2/libxml2-2.9.2.tar.gz]
10 #       - winpthreads-3.3.0 [directory mingw-w64-libraries/winpthreads from http://downloads.sourceforge.net/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v3.3.0.tar.bz2]
11 #       - win-iconv-0.0.6 [contents of https://win-iconv.googlecode.com/files/win-iconv-0.0.6.tar.bz2]
12
13 ARCHITECTURES           := i686 x86_64
14 LIBXML_VERSION          := 2-2.9.2
15 WINPTHREADS_VERSION     := -3.3.0
16 WINICONV_VERSION        := -0.0.6
17
18 LIBXML_SRCDIR           := libxml$(LIBXML_VERSION)
19 SOURCE_TARGETS          += $(LIBXML_SRCDIR)
20 $(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
24
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
31
32 WINICONV_SRCDIR         := win-iconv$(WINICONV_VERSION)
33 SOURCE_TARGETS          += $(WINICONV_SRCDIR)
34 $(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)
38
39 #
40 # declare_libxml_target(arch)
41 #
42 define declare_libxml_target
43 libxml_$(1):$(LIBXML_SRCDIR)
44         builddir=build_libxml_$(1);                             \
45         rm -rf $$$$builddir;                                    \
46         mkdir $$$$builddir;                                     \
47         cd $$$$builddir;                                        \
48         ../$(LIBXML_SRCDIR)/configure                           \
49                 --host=$(1)-w64-mingw32                         \
50                 --enable-static                                 \
51                 --disable-shared                                \
52                 --prefix=$$$$PWD/../sysroot_$(1)                \
53                 CFLAGS=-Os                                      \
54                 --with-minimum                                  \
55                 --without-lzma                                  \
56                 --with-writer;                                  \
57         $(MAKE) install;                                        \
58         rm -f ../sysroot_$(1)/lib/libxml2.la;
59
60 $(1)_BUILD_TARGETS += libxml_$(1)
61 MAKE_CLEAN_FILES += build_libxml_$(1)
62 endef
63
64 #
65 # declare_winpthreads_target(arch)
66 #
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;               \
72         cd $$$$builddir;                                        \
73         ./configure                                             \
74                 --host=$(1)-w64-mingw32                         \
75                 --enable-static                                 \
76                 --disable-shared                                \
77                 --prefix=$$$$PWD/../sysroot_$(1)                \
78                 CFLAGS=-O2;                                     \
79         $(MAKE) install;                                        \
80         sed -i 's/if defined DLL_EXPORT/if 0/' ../sysroot_$(1)/include/pthread.h;
81
82 $(1)_BUILD_TARGETS += winpthreads_$(1)
83 MAKE_CLEAN_FILES += build_winpthreads_$(1)
84 endef
85
86 #
87 # declare_winiconv_target(arch)
88 #
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;                  \
94         cd $$$$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                \
99                 CFLAGS=-O2                                      \
100                 prefix=$$$$PWD/../sysroot_$(1)                  \
101                 install;                                        \
102         rm -f ../sysroot_$(1)/lib/libiconv.dll.a;
103
104 $(1)_BUILD_TARGETS += winiconv_$(1)
105 MAKE_CLEAN_FILES += build_winiconv_$(1)
106 endef
107
108 #
109 # declare_arch_targets(arch)
110 #
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)))
115
116 sysroot_$(1): $($(1)_BUILD_TARGETS)
117
118 ALL_SYSROOTS += sysroot_$(1)
119 MAKE_CLEAN_FILES += sysroot_$(1)
120 endef
121
122 $(foreach arch,$(ARCHITECTURES),$(eval $(call declare_arch_targets,$(arch))))
123
124 all: $(ALL_SYSROOTS)
125
126 clean:
127         rm -rf $(MAKE_CLEAN_FILES)
128
129 .PHONY: all clean $(SOURCE_TARGETS)
130
131 .DEFAULT_GOAL = all