Add file Scripts/cross-build-win-binaries.mk.
[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         cp $(win_build)/flac64/bin/flac.exe flac-$(flac_version)-win/win64/
43         cp $(win_build)/flac64/bin/metaflac.exe flac-$(flac_version)-win/win64/
44         cp -r doc/html flac-$(flac_version)-win/
45         rm -rf flac-$(flac_version)-win/html/api
46         find flac-$(flac_version)-win/ -name Makefile\* -exec rm -f {} \;
47         cp AUTHORS COPYING.* README flac-$(flac_version)-win/
48         touch $@
49
50 #-------------------------------------------------------------------------------
51 # Build and install 32 and 64 bit versions of a statically linked flac and
52 # metaflac executable.
53
54 win-build/.stamp-flac-win64-install : win-build/.stamp-flac-win64-config
55         make clean all install
56         touch $@
57
58 win-build/.stamp-flac-win64-config : win-build/.stamp-flac-prepare configure
59         mkdir -p $(win_build)/ogg64
60         ./configure --disable-shared  $(win64_target) --with-ogg=$(win_build)/ogg64 --prefix=$(win_build)/flac64
61         touch $@
62
63 win-build/.stamp-flac-win32-install : win-build/.stamp-flac-win32-config
64         make clean all install
65         touch $@
66
67 win-build/.stamp-flac-win32-config : win-build/.stamp-flac-prepare configure
68         mkdir -p $(win_build)/ogg32
69         ./configure --disable-shared  $(win32_target) --with-ogg=$(win_build)/ogg32 --prefix=$(win_build)/flac32
70         touch $@
71
72 win-build/.stamp-flac-prepare : win-build/.stamp-win32-install win-build/.stamp-win64-install
73         touch $@
74
75 #-------------------------------------------------------------------------------
76 # Build libogg for win32 and win64.
77
78 win-build/.stamp-win64-install : win-build/.stamp-win64-configure
79         (cd win-build/libogg-$(ogg_version) && make clean all check install)
80         touch $@
81
82 win-build/.stamp-win64-configure : win-build/.stamp-source
83         mkdir -p $(win_build)/win64
84         (cd win-build/libogg-$(ogg_version) && ./configure --prefix=$(win_build)/ogg64 $(win32_target) --disable-shared)
85         touch $@
86
87 win-build/.stamp-win32-install : win-build/.stamp-win32-configure
88         (cd win-build/libogg-$(ogg_version) && make clean all check install)
89         touch $@
90
91 win-build/.stamp-win32-configure : win-build/.stamp-source
92         mkdir -p $(win_build)/win32
93         (cd win-build/libogg-$(ogg_version) && ./configure --prefix=$(win_build)/ogg32 $(win32_target) --disable-shared)
94         touch $@
95
96 win-build/.stamp-source : win-build/.stamp-sha256sum-checked
97         (cd win-build && tar xf libogg-$(ogg_version).tar.gz)
98         touch $@
99
100 #-------------------------------------------------------------------------------
101 # Retrieve and check libogg tarball.
102
103 win-build/.stamp-sha256sum-checked : win-build/libogg-$(ogg_version).tar.gz
104         @if test $$(sha256sum $+ | sed 's/ .*//') != $(ogg_sha256sum) ; then exit 1 ; fi
105         @echo "sha256 sum : ok"
106         touch $@
107
108 win-build/libogg-$(ogg_version).tar.gz :
109         mkdir -p win-build
110         wget http://downloads.xiph.org/releases/ogg/$$(basename $@) -O $@
111
112 #-------------------------------------------------------------------------------
113 # Autotool stuff.
114
115 configure : configure.ac autogen.sh
116         ./autogen.sh
117