Scripts/cross-build-win-binaries.mk : Add a 'clean' target.
[flac.git] / Scripts / cross-build-win-binaries.mk
1 #!/usr/bin/make -f
2
3 #  Copyright (C) 2014  Xiph.Org Foundation
4 #
5 #  This file is part the FLAC project.  FLAC is comprised of several
6 #  components distributed under different licenses.  The codec libraries
7 #  are distributed under Xiph.Org's BSD-like license (see the file
8 #  COPYING.Xiph in this distribution).  All other programs, libraries, and
9 #  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
10 #  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
11 #  FLAC distribution contains at the top the terms under which it may be
12 #  distributed.
13 #
14 #  Since this particular file is relevant to all components of FLAC,
15 #  it may be distributed under the Xiph.Org license, which is the least
16 #  restrictive of those mentioned above.  See the file COPYING.Xiph in this
17 #  distribution.
18
19 ogg_version = 1.3.2
20 ogg_sha256sum = e19ee34711d7af328cb26287f4137e70630e7261b17cbe3cd41011d73a654692
21
22 flac_version = $(shell grep ^AC_INIT configure.ac | sed 's/[^ ]* \[//;s/\].*//')
23
24 win_build = $(shell pwd)/win-build
25
26 win32_name = i686-w64-mingw32
27 win64_name = x86_64-w64-mingw32
28
29 win32_target = --host=$(win32_name) --target=$(win32_name)
30 win64_target = --host=$(win64_name) --target=$(win64_name)
31
32 flac-$(flac_version)-win.zip : flac-$(flac_version)-win//AUTHORS
33         zip -r $@ flac-$(flac_version)-win
34         rm -rf flac-$(flac_version)-win
35
36
37
38 flac-$(flac_version)-win//AUTHORS : win-build/.stamp-flac-win32-install win-build/.stamp-flac-win64-install
39         mkdir -p flac-$(flac_version)-win/win32  flac-$(flac_version)-win/win64
40         cp $(win_build)/flac32/bin/flac.exe flac-$(flac_version)-win/win32/
41         cp $(win_build)/flac32/bin/metaflac.exe flac-$(flac_version)-win/win32/
42         $(win32_name)-strip flac-$(flac_version)-win/win32/*.exe
43         cp $(win_build)/flac64/bin/flac.exe flac-$(flac_version)-win/win64/
44         cp $(win_build)/flac64/bin/metaflac.exe flac-$(flac_version)-win/win64/
45         $(win64_name)-strip flac-$(flac_version)-win/win64/*.exe
46         cp -r doc/html flac-$(flac_version)-win/
47         rm -rf flac-$(flac_version)-win/html/api
48         find flac-$(flac_version)-win/ -name Makefile\* -exec rm -f {} \;
49         cp AUTHORS COPYING.* README flac-$(flac_version)-win/
50         touch $@
51
52 #-------------------------------------------------------------------------------
53 # Build and install 32 and 64 bit versions of a statically linked flac and
54 # metaflac executable.
55
56 win-build/.stamp-flac-win64-install : win-build/.stamp-flac-win64-config
57         make clean all install
58         touch $@
59
60 win-build/.stamp-flac-win64-config : win-build/.stamp-flac-prepare configure
61         mkdir -p $(win_build)/ogg64
62         ./configure --disable-shared  $(win64_target) --with-ogg=$(win_build)/ogg64 --prefix=$(win_build)/flac64
63         touch $@
64
65 win-build/.stamp-flac-win32-install : win-build/.stamp-flac-win32-config
66         make clean all install
67         touch $@
68
69 win-build/.stamp-flac-win32-config : win-build/.stamp-flac-prepare configure
70         mkdir -p $(win_build)/ogg32
71         ./configure --disable-shared  $(win32_target) --with-ogg=$(win_build)/ogg32 --prefix=$(win_build)/flac32
72         touch $@
73
74 win-build/.stamp-flac-prepare : win-build/.stamp-win32-install win-build/.stamp-win64-install
75         touch $@
76
77 #-------------------------------------------------------------------------------
78 # Build libogg for win32 and win64.
79
80 win-build/.stamp-win64-install : win-build/.stamp-win64-configure
81         (cd win-build/libogg-$(ogg_version) && make clean all check install)
82         touch $@
83
84 win-build/.stamp-win64-configure : win-build/.stamp-source
85         mkdir -p $(win_build)/win64
86         (cd win-build/libogg-$(ogg_version) && ./configure --prefix=$(win_build)/ogg64 $(win32_target) --disable-shared)
87         touch $@
88
89 win-build/.stamp-win32-install : win-build/.stamp-win32-configure
90         (cd win-build/libogg-$(ogg_version) && make clean all check install)
91         touch $@
92
93 win-build/.stamp-win32-configure : win-build/.stamp-source
94         mkdir -p $(win_build)/win32
95         (cd win-build/libogg-$(ogg_version) && ./configure --prefix=$(win_build)/ogg32 $(win32_target) --disable-shared)
96         touch $@
97
98 win-build/.stamp-source : win-build/.stamp-sha256sum-checked
99         (cd win-build && tar xf libogg-$(ogg_version).tar.gz)
100         touch $@
101
102 #-------------------------------------------------------------------------------
103 # Retrieve and check libogg tarball.
104
105 win-build/.stamp-sha256sum-checked : win-build/libogg-$(ogg_version).tar.gz
106         @if test $$(sha256sum $+ | sed 's/ .*//') != $(ogg_sha256sum) ; then exit 1 ; fi
107         @echo "sha256 sum : ok"
108         touch $@
109
110 win-build/libogg-$(ogg_version).tar.gz :
111         mkdir -p win-build
112         wget http://downloads.xiph.org/releases/ogg/$$(basename $@) -O $@
113
114 #-------------------------------------------------------------------------------
115 # Autotool stuff.
116
117 configure : configure.ac autogen.sh
118         ./autogen.sh
119
120 clean :
121         rm -rf $(win_build) flac-$(flac_version)-win