]> git.sesse.net Git - vlc/blob - extras/contrib/Makefile
contrib: Build fat binary using binary contrib on Mac OS X.
[vlc] / extras / contrib / Makefile
1 # ***************************************************************************
2 # Makefile : Build vlc-contrib files
3 # ***************************************************************************
4 # Copyright (C) 2003-2009 the VideoLAN team
5 # $Id$
6
7 # Authors: Christophe Massiot <massiot@via.ecp.fr>
8 #          Derk-Jan Hartman <hartman at videolan dot org>
9 #          Christophe Mutricy <xtophe at videolan dot org>
10 #          Felix Paul Kühne <fkuehne at videolan dot org>
11 #
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or    
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 # ***************************************************************************
26
27 include ./config.mak
28
29 BUILDDIRS = hosts build
30
31 ifdef HAVE_DARWIN_OS
32 TARGETALL=fat-bin
33 else
34 TARGETALL=using-src
35 endif
36
37 all: $(TARGETALL)
38
39 using-src:
40         $(MAKE) -C src
41 ifdef HAVE_DARWIN_10
42         (cd $(PREFIX)/lib && sed -e 's%/usr/lib/libiconv.la%$(PREFIX)/lib/libiconv.la%g' -i.orig *.la && rm -f *.la.orig)
43 endif
44
45 # shortcut
46 src: using-src
47
48 ifdef HAVE_DARWIN_OS
49
50 CONTRIBREV=22
51
52 contrib-macosx-$(ARCH)-$(CONTRIBREV).tar.bz2:
53         $(WGET) http://downloads.videolan.org/pub/videolan/testing/contrib/$@
54
55 hosts/$(HOST)/.$(CONTRIBREV): contrib-macosx-$(ARCH)-$(CONTRIBREV).tar.bz2
56         @if test -d tmp; then \
57                 echo "Move away ./tmp, it's in the way" ; \
58                 exit 1 ; \
59         fi
60         mkdir tmp
61         mkdir -p $(PREFIX)
62         (cd tmp && tar jxvf ../$<)
63         ./change_prefix.sh tmp @@CONTRIB_PREFIX@@  $(PREFIX)
64         (cd tmp && find . -type d) | while read dir; do mkdir -p -- "$(PREFIX)/$$dir"; done
65         (cd tmp && find . -not -type d) | while read i; do mv -f -- tmp/"$$i" "$(PREFIX)/$$i"; done
66         rm -rf tmp
67     # libiconv.la is no longer present on Snow Leopard, so fix possible references to it, which would
68     # result in linking issues
69 ifdef HAVE_DARWIN_10
70         (cd $(PREFIX)/lib && sed -e 's%/usr/lib/libiconv.la%$(PREFIX)/lib/libiconv.la%g' -i.orig *.la && rm -f *.la.orig)
71         (cd src && $(MAKE) .iconv)
72 endif
73         touch $@
74
75 using-bin: hosts/$(HOST)/.$(CONTRIBREV) 
76
77 hosts/fat/.$(CONTRIBREV)-from-archs:
78         @if test -d tmp; then \
79                 echo "Move away ./tmp, it's in the way" ; \
80                 exit 1 ; \
81         fi
82         # FIXME - Doing this without rerunning bootstrap & make would be nicer
83         ./bootstrap i686-apple-darwin10 && make && \
84         ./bootstrap x86_64-apple-darwin10 && make && \
85         mkdir tmp;
86         cp -R hosts/x86_64-apple-darwin10/ tmp;
87         (cd tmp/lib && find . -name "*.dylib" -or -name "*.a") | while read lib; do rm tmp/lib/$$lib \
88            lipo -create hosts/x86_64-apple-darwin10/lib/$$lib hosts/i686-apple-darwin10/lib/$$lib -output tmp/lib/$$lib; \
89         done;
90         rm -Rf hosts/fat && \
91         mv tmp hosts/fat && \
92         touch $@
93         
94 fat-bin: hosts/fat/.$(CONTRIBREV)-from-archs
95
96 endif
97
98 clean-src:
99         rm -rf $(BUILDDIRS)
100         $(MAKE) -C src clean-src
101
102 clean-bin:
103         rm -rf $(BUILDDIRS)
104         $(MAKE) -C src clean-dots
105
106 clean:
107         $(MAKE) clean-src
108         rm -rf config.mak distro.mak
109
110 bin: using-bin
111
112 package-macosx:
113         @if test -d tmp; then \
114                 echo "Move away ./tmp, it's in the way" ; \
115                 exit 1 ; \
116         fi
117         mkdir tmp
118         (cd $(PREFIX); tar cf - *) | (cd tmp; tar xf -)
119         ./change_prefix.sh tmp $(PREFIX) @@CONTRIB_PREFIX@@
120         (cd tmp; tar cf - .) | bzip2 -c > contrib-macosx.tar.bz2
121         rm -rf tmp
122         rm -f contrib-macosx-$(ARCH)-$(CONTRIBREV).tar.bz2
123         mv contrib-macosx.tar.bz2 contrib-macosx-$(ARCH)-$(CONTRIBREV).tar.bz2
124
125 DISTDIR = usr/win$*
126
127 package-win%:
128         @if test -d tmp; then \
129                 echo "Move away ./tmp, it's in the way" ; \
130                 exit 1 ; \
131         fi
132         mkdir -p tmp/$(DISTDIR)
133         (cd $(PREFIX); tar cf - --dereference bin sbin include lib share/aclocal*\
134                 share/autoconf* share/qt4* \
135                 share/automake* share/gettext* gecko-sdk)\
136                 | (cd tmp/$(DISTDIR); tar xpf -)
137 #kludge for live.com
138         mkdir -p tmp/$(DISTDIR)/live.com
139         for i in groupsock liveMedia UsageEnvironment BasicUsageEnvironment; do \
140                 mkdir -p  tmp/$(DISTDIR)/live.com/$$i/include; \
141                 cp -r src/live/$$i/include tmp/$(DISTDIR)/live.com/$$i; \
142                 cp src/live/$$i/lib$${i}.a  tmp/$(DISTDIR)/live.com/$$i; \
143         done;
144 # Change Prefix.
145         ./change_prefix.sh tmp $(PREFIX) $(DISTDIR)
146 # Remove unused and potentially harmful files (but skip qt4 executables)
147         (cd tmp/$(DISTDIR)/bin && rm -fv `find . -name 'uic.exe' -o -name 'rcc.exe' -o -name 'moc.exe' -o -name '*.exe' -printf '%p '` && chmod a+x * || true)
148 # Tar it.
149         (cd tmp; tar cf - $(DISTDIR)) | bzip2 -c > contrib-`date +%Y%m%d`-win$*-bin-gcc-`$(CC) --version|head -n 1|cut -f 3 -d ' '`-runtime-`/bin/echo -e "#include <_mingw.h>\n__MINGW32_VERSION"|$(CC) -E -|grep -v ^#|grep -v ' '`-only.tar.bz2
150         rm -rf tmp
151
152 .PHONY: all clean-src clean-bin clean package-macosx