Commit 3aa1cecf authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

New contrib system

 * support for fetching only needed sources
 * always building from source tarball:
   - easier GPL compliance
   - easier offline/firewalled builds
 * shared source tarballs for all targets
 * dynamic package selection, no static distribution files
 * fixed file dependency propagation with delete on errors
 * fixed directory dependencies using atomic rename

Only ogg and tremor are in this initial version. This focuses on the
core of the system. The bulk of packages still need to be ported.
parent 73cadb23
#! /bin/sh
# Copyright (C) 2003-2011 the VideoLAN team
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
#
# Command line handling
#
usage()
{
echo "Usage: $0 [--build=BUILD] [--host=HOST] [--prefix=PREFIX]"
echo " --build=BUILD configure for building on BUILD"
echo " --host=HOST cross-compile to build to run on HOST"
echo " --prefix=PREFIX install files in PREFIX"
}
BUILD=
HOST=
PREFIX=
if test ! -f "../src/main.mak"
then
echo "$0 must be run from a subdirectory"
exit 1
fi
while test -n "$1"
do
case "$1" in
--build=*)
BUILD="${1#--build=}"
;;
--help|-h)
usage
exit 0
;;
--host=*)
HOST="${1#--host=}"
;;
--prefix=*)
PREFIX="${1#--prefix=}"
;;
*)
echo "Unrecognized options $1"
usage
exit 1
;;
esac
shift
done
if test -z "$BUILD"
then
echo -n "Guessing build system... "
BUILD="`cc -dumpmachine`"
if test -z "$BUILD"; then
echo "FAIL!"
exit 1
fi
echo "$BUILD"
fi
if test -z "$HOST"
then
echo -n "Guessing host system... "
HOST="$BUILD"
echo "$HOST"
fi
if test "$PREFIX"
then
# strip trailing slash
PREFIX="${PREFIX%/}"
else
PREFIX="../hosts/$HOST"
fi
#
# Prepare files
#
echo "Creating prefix... $PREFIX"
mkdir -p -- "$PREFIX" || exit $?
mkdir -p -- "$PREFIX/share/aclocal" || exit $?
echo "Creating configuration file... config.mak"
exec 3>config.mak
cat >&3 << EOF
# This file was automatically generated.
# Any change will be overwritten if ../bootstrap is run again.
BUILD := $BUILD
HOST := $HOST
PREFIX := $PREFIX
EOF
add_make()
{
while test -n "$1"
do
echo "$1" >&3
shift
done
}
add_make_enabled()
{
while test -n "$1"
do
add_make "$1 := 1"
shift
done
}
#
# Checks
#
OS="${HOST#*-}" # strip architecture
case "${OS}" in
*darwin*)
add_make_enabled "HAVE_DARWIN_OS" "HAVE_BSD"
;;
*bsd*)
add_make_enabled "HAVE_BSD"
;;
*linux*)
add_make_enabled "HAVE_LINUX"
;;
*mingw*)
add_make_enabled "HAVE_WIN32"
;;
*wince*)
add_make_enabled "HAVE_WINCE"
;;
esac
#
# Results output
#
test -e Makefile && unlink Makefile
ln -sf ../src/main.mak Makefile
cat << EOF
Bootstrap completed.
The following packages were selected:
$PKGS
Run "make" to start compilation.
Other targets:
* make install same as "make"
* make fetch fetch required source tarballs
* make fetch-all fetch all source tarballs
* make distclean clean everything and undo bootstrap
* make clean clean everything
* make mostlyclean clean everything except source tarballs
EOF
Writing rules
==============
At the bare minimum, a package in contrib must provide two Makefile
targets in src/foo/rules.mak:
- .foo to build and install the package, and
- .sum-foo to fetch or create a source tarball and verify it,
where foo the package name.
Tarball
--------
.sum-foo typically depends on a separate target that fetches the source
code. In that case, .sum-foo needs only verify that the tarball
is correct, e.g.:
$(TARBALLS)/libfoo-$(FOO_VERSION).tar.bz2:
$(WGET) $(FOO_URL)
.sum-foo: $(TARBALLS)/libfoo-$(FOO_VERSION).tar.bz2
$(CHECKSUM) $(SRC)/foo/SHA512SUMS
touch $@
NOTE: contrary to the previous VLC contribs, this system always uses
a source tarball, even if the source code is downloaded from a VCS.
This serves two purposes:
- offline builds (or behind a firewall),
- source code requirements compliance.
Compilation
------------
Similarly, .foo typically depends on the source code directory. In this
case, care must be taken that the directory name only exists if the
source code is fully ready. Otherwise Makefile dependencies will break
(this is not an issue for files, only directories).
libfoo: $(TARBALLS)/libfoo-$(FOO_VERSION).tar.bz2 .sum-foo
$(EXTRACT_BZ2) # to libfoo-$(FOO_VERSION)
### apply patches here ###
# last command: make the target directory
mv libfoo-$(FOO_VERSION) libfoo
.foo: libfoo
cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
cd $< && $(MAKE) install
touch $@
Dependencies
-------------
If package bar depends on package foo, a Makefile dependency can ensure
that bar will be built after foo. It will also ensure that foo will be
built even if it was not selected explicitly in the $(PKGS) variable:
.bar: libbar .foo
cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
cd $< && $(MAKE) install
touch $@
Conditional builds
-------------------
Some packages may be provided by the target system. This is especially
common when building natively on Linux or BSD. A dummy build rule can
be used conditionally.
NEED_FOO := $(call need_pkg,'foo >= 1.2.3')
ifeq ($(NEED_FOO),)
.foo:
else
.foo: libfoo
### foo compilation rules here ###
endif
touch $@
If pkg-config finds foo.pc with version 1.2.3 or larger, this will be
equivalent to:
.foo: ; touch .foo
Note: The need_pkg function always return 1 during cross-compilation.
# Main makefile for VLC 3rd party libraries ("contrib")
# Copyright (C) 2003-2011 the VideoLAN team
#
# This file is under the same license as the vlc package.
all: install
ALL_PKGS := $(patsubst ../src/%/rules.mak,%,$(wildcard ../src/*/rules.mak))
SRC := ../src
TARBALLS := ../tarballs
# Common download locations
GNU := http://ftp.gnu.org/gnu
SF := http://heanet.dl.sourceforge.net/sourceforge
VIDEOLAN := http://downloads.videolan.org/pub/videolan
CONTRIB_VIDEOLAN := $(VIDEOLAN)/testing/contrib
# bootstrap configuration
include config.mak
#
# Machine-dependent variables
#
PREFIX := $(abspath $(BIN)/$(HOST))
ifneq ($(HOST),$(BUILD))
HAVE_CROSS_COMPILE = 1
endif
ifdef HAVE_CROSS_COMPILE
need_pkg = 1
else
need_pkg = $(shell $(PKG_CONFIG) $(1) || echo 1)
endif
#
# Default values for tools
#
ifndef HAVE_CROSS_COMPILE
ifneq ($(findstring $(origin CC),undefined default),)
CC := gcc
endif
ifneq ($(findstring $(origin CXX),undefined default),)
CXX := g++
endif
ifneq ($(findstring $(origin LD),undefined default),)
LD := ld
endif
ifneq ($(findstring $(origin AR),undefined default),)
AR := ar
endif
ifneq ($(findstring $(origin RANLIB),undefined default),)
RANLIB := ranlib
endif
ifneq ($(findstring $(origin STRIP),undefined default),)
STRIP := strip
endif
else
ifneq ($(findstring $(origin CC),undefined default),)
CC := $(HOST)-gcc
endif
ifneq ($(findstring $(origin CXX),undefined default),)
CXX := $(HOST)-g++
endif
ifneq ($(findstring $(origin LD),undefined default),)
LD := $(HOST)-ld
endif
ifneq ($(findstring $(origin AR),undefined default),)
AR := $(HOST)-ar
endif
ifneq ($(findstring $(origin RANLIB),undefined default),)
RANLIB := $(HOST)-ranlib
endif
ifneq ($(findstring $(origin STRIP),undefined default),)
STRIP := $(HOST)-strip
endif
endif
EXTRA_CFLAGS += -I$(PREFIX)/include
CPPFLAGS := $(CPPFLAGS) $(EXTRA_CFLAGS)
CFLAGS := $(CFLAGS) $(EXTRA_CFLAGS)
CXXFLAGS := $(CXXFLAGS) $(EXTRA_CFLAGS)
EXTRA_LDFLAGS += -L$(PREFIX)/lib
LDFLAGS := $(LDFLAGS) $(EXTRA_LDFLAGS)
# Do not export those! Use HOSTVARS.
ACLOCAL_AMFLAGS += -I$(PREFIX)/share/aclocal
export ACLOCAL_AMFLAGS
PKG_CONFIG ?= pkg-config
ifdef HAVE_CROSS_COMPILE
# This inhibits .pc file from within the cross-compilation toolchain sysroot.
# Hopefully, nobody ever needs that.
PKG_CONFIG_PATH :=
PKG_CONFIG_LIBDIR := /dev/null
export PKG_CONFIG_LIBDIR
endif
PKG_CONFIG_PATH += :$(PREFIX)/lib/pkgconfig
export PKG_CONFIG_PATH
SVN ?= svn
WGET ?= wget
#
# Common helpers
#
HOSTVARS := CPPFLAGS="$(CPPFLAGS)"
HOSTVARS += CC="$(CC)"
HOSTVARS += CFLAGS="$(CFLAGS)"
HOSTVARS += CXX="$(CXX)"
HOSTVARS += CXXFLAGS="$(CXXFLAGS)"
HOSTVARS += LD="$(LD)"
HOSTVARS += LDFLAGS="$(LDFLAGS)"
HOSTVARS += AR="$(AR)"
HOSTVARS += RANLIB="$(RANLIB)"
HOSTVARS += STRIP="$(STRIP)"
HOSTVARS_AR += AR="$(AR) rcvu"
HOSTCONF := --prefix="$(PREFIX)"
HOSTCONF += --build="$(BUILD)" --host="$(HOST)" --target="$(HOST)"
HOSTCONF += --program-prefix=""
# libtool stuff:
HOSTCONF += --enable-static --disable-shared --disable-dependency-tracking
ifdef HAVE_WIN32
HOSTCONF += --without-pic
else
HOSTCONF += --with-pic
endif
DOWNLOAD = cd $(TARBALLS) && $(WGET) -nc
checksum = (cd $(TARBALLS) && $(1)sum -c -) < \
$(SRC)/$(patsubst .sum-%,%,$@)/$(2)SUMS
CHECK_SHA256 = $(call checksum,sha512,SHA512)
CHECK_SHA512 = $(call checksum,sha512,SHA512)
untar = $(RM) -R $@; tar xv$(1)f $<
UNPACK_GZ = $(call untar,z)
UNPACK_BZ2 = $(call untar,j)
UNPACK_XZ = $(call untar,J)
UNPACK_ZIP = $(RM) -R $@; unzip $<
#
# Per-package build rules
#
include ../src/*/rules.mak
#
# Targets
#
fetch: $(PKGS:%=.sum-%)
fetch-all: $(ALL_PKGS:%=.sum-%)
install: $(PKGS:%=.%)
mostlyclean:
-$(RM) $(ALL_PKGS:%=.%) $(ALL_PKGS:%=.sum-%)
-$(RM) -R "$(PREFIX)"
-find -maxdepth 1 -type d '!' -name . -exec $(RM) -R '{}' ';'
clean: mostlyclean
-$(RM) $(TARBALLS)/*.*
distclean: clean
$(RM) config.mak
unlink Makefile
.DELETE_ON_ERROR:
c6f4ee6833542bf75b5d5f65778de5221fe322aefa10a1382141eac3508103b6b7ec2198c34d6226d23c360a9338540e22817c23eed3505d0d9d3f4762e97feb libogg-1.2.2.tar.xz
--- libogg/configure.in 2010-11-01 21:13:42.000000000 +0100
+++ libogg.new/configure.in 2010-11-03 23:59:54.267733114 +0100
@@ -28,17 +28,17 @@
case $host in
*-*-irix*)
DEBUG="-g -signed"
- CFLAGS="-O2 -w -signed"
+ EXTRA_CFLAGS="-O2 -w -signed"
PROFILE="-p -g3 -O2 -signed"
;;
sparc-sun-solaris*)
DEBUG="-v -g"
- CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
+ EXTRA_CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc"
;;
*)
DEBUG="-g"
- CFLAGS="-O"
+ EXTRA_CFLAGS="-O"
PROFILE="-g -p"
;;
esac
@@ -46,27 +46,27 @@
case $host in
*-*-linux*)
DEBUG="-g -Wall -fsigned-char"
- CFLAGS="-O20 -Wall -ffast-math -fsigned-char"
+ EXTRA_CFLAGS="-O20 -Wall -ffast-math -fsigned-char"
PROFILE="-Wall -W -pg -g -O20 -ffast-math -fsigned-char"
;;
sparc-sun-*)
DEBUG="-g -Wall -fsigned-char"
- CFLAGS="-O20 -ffast-math -fsigned-char"
+ EXTRA_CFLAGS="-O20 -ffast-math -fsigned-char"
PROFILE="-pg -g -O20 -fsigned-char"
;;
*-*-darwin*)
DEBUG="-fno-common -g -Wall -fsigned-char"
- CFLAGS="-fno-common -O4 -Wall -fsigned-char -ffast-math"
+ EXTRA_CFLAGS="-fno-common -O4 -Wall -fsigned-char -ffast-math"
PROFILE="-fno-common -O4 -Wall -pg -g -fsigned-char -ffast-math"
;;
*)
DEBUG="-g -Wall -fsigned-char"
- CFLAGS="-O20 -fsigned-char"
+ EXTRA_CFLAGS="-O20 -fsigned-char"
PROFILE="-O20 -g -pg -fsigned-char"
;;
esac
fi
-CFLAGS="$CFLAGS $cflags_save"
+CFLAGS="$EXTRA_CFLAGS $cflags_save"
DEBUG="$DEBUG $cflags_save"
PROFILE="$PROFILE $cflags_save"
--- libogg/include/ogg/os_types.h 2005-11-22 23:01:12.000000000 +0000
+++ libogg/include/ogg/os_types.h 2005-11-22 23:05:11.000000000 +0000
@@ -55,6 +55,10 @@
typedef unsigned __int16 ogg_uint16_t;
# endif
+# if defined(UNDER_CE)
+# define exit(a)
+# endif
+
#elif defined(__MACOS__)
# include <sys/types.h>
# libogg
OGG_VERSION := 1.2.2
OGG_TARBALL := libogg-$(OGG_VERSION).tar.xz
OGG_URL := http://downloads.xiph.org/releases/ogg/$(OGG_TARBALL)
#OGG_URL := $(CONTRIB_VIDEOLAN)/$(OGG_TARBALL)
OGG_CVSROOT := :pserver:anoncvs@xiph.org:/usr/local/cvsroot
NEED_OGG = $(call need_pkg,"ogg >= 1.0")
$(TARBALLS)/$(OGG_TARBALL):
$(DOWNLOAD) $(OGG_URL)
.sum-ogg: $(TARBALLS)/$(OGG_TARBALL)
$(CHECK_SHA512)
touch $@
libogg: $(TARBALLS)/$(OGG_TARBALL) .sum-ogg
$(UNPACK_XZ)
(cd $@-$(OGG_VERSION) && patch -p1) < $(SRC)/ogg/libogg-1.1.patch
ifdef HAVE_WINCE
(cd $@-$(OGG_VERSION) && patch -p1) < $(SRC)/ogg/libogg-wince.patch
endif
mv $@-$(OGG_VERSION) $@
ifeq ($(NEED_OGG),)
.ogg:
else
PKGS += ogg
.ogg: libogg
#cd $< && autoreconf
cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
cd $< && $(MAKE) install
endif
touch $@
# tremor (fixed-point Vorbis)
$(TARBALLS)/tremor-svn.tar.xz:
rm -Rf tremor-svn
$(SVN) export http://svn.xiph.org/trunk/Tremor tremor-svn
tar cv tremor-svn | xz > $@
.sum-tremor: $(TARBALLS)/tremor-svn.tar.xz
$(warning Integrity check skipped.)
touch $@
tremor: $(TARBALLS)/tremor-svn.tar.xz .sum-tremor
# Stuff that does not depend on libogg
$(UNPACK_XZ)
(cd tremor-svn && patch -p0) < $(SRC)/tremor/tremor.patch
rm -f tremor-svn/ogg.h tremor-svn/os_types.h
echo '#include <ogg/ogg.h>' > tremor-svn/ogg.h
echo '#include <ogg/os_types.h>' > tremor-svn/os_types.h
mv tremor-svn tremor
.tremor: tremor .ogg
# Stuff that depends on libogg
cd $< && \
$(HOSTVARS) ./autogen.sh $(HOSTCONF) \
--prefix="$(PREFIX)" --disable-shared CFLAGS="$(NOTHUMB)"
cd $< && $(MAKE) install
touch $@
Index: os.h
===================================================================
--- os.h (révision 17483)
+++ os.h (copie de travail)
@@ -20,6 +20,14 @@
#include <math.h>
#include <ogg/os_types.h>
+#ifdef _LOW_ACCURACY_
+# define X(n) (((((n)>>22)+1)>>1) - ((((n)>>22)+1)>>9))
+# define LOOKUP_T const unsigned char
+#else
+# define X(n) (n)
+# define LOOKUP_T const ogg_int32_t
+#endif
+
#ifndef _V_IFDEFJAIL_H_
# define _V_IFDEFJAIL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment