Commit 37a99466 authored by Vittorio Giovara's avatar Vittorio Giovara Committed by Tristan Matthews

import contrib system from VideoLan

Refs: #46617
Change-Id: I51a7bc40954c6d1175aaf6ef4d86fbec1fb9d44d
parent 8abd0fcc
#! /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"
echo " --disable-FOO configure to not build package FOO"
echo " --enable-FOO configure to build package FOO"
}
BUILD=
HOST=
PREFIX=
PKGS_ENABLE=
PKGS_DISABLE=
if test ! -f "../../contrib/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=}"
;;
--disable-*)
PKGS_DISABLE="${PKGS_DISABLE} ${1#--disable-}"
;;
--enable-*)
PKGS_ENABLE="${PKGS_ENABLE} ${1#--enable-}"
;;
*)
echo "Unrecognized options $1"
usage
exit 1
;;
esac
shift
done
if test -z "$BUILD"
then
echo -n "Guessing build system... "
BUILD="`${CC:-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%/}"
fi
#
# Prepare files
#
echo "Creating configuration file... config.mak"
exec 3>config.mak || exit $?
cat >&3 << EOF
# This file was automatically generated.
# Any change will be overwritten if ../bootstrap is run again.
BUILD := $BUILD
HOST := $HOST
PKGS_DISABLE := $PKGS_DISABLE
PKGS_ENABLE := $PKGS_ENABLE
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
}
check_ios_sdk()
{
if test -z "$SDKROOT"
then
SDKROOT=`xcode-select -print-path`/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}${SDK_VERSION}.sdk
echo "SDKROOT not specified, assuming $SDKROOT"
else
SDKROOT="$SDKROOT"
fi
if [ ! -d "${SDKROOT}" ]
then
echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
exit 1
fi
add_make "IOS_SDK=${SDKROOT}"
}
check_macosx_sdk()
{
if [ -z "${OSX_VERSION}" ]
then
OSX_VERSION=`xcrun --show-sdk-version`
echo "OSX_VERSION not specified, assuming $OSX_VERSION"
fi
if test -z "$SDKROOT"
then
SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
echo "SDKROOT not specified, assuming $SDKROOT"
fi
if [ ! -d "${SDKROOT}" ]
then
SDKROOT_NOT_FOUND=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
SDKROOT=`xcode-select -print-path`/SDKs/MacOSX$OSX_VERSION.sdk
echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
fi
if [ ! -d "${SDKROOT}" ]
then
SDKROOT_NOT_FOUND="$SDKROOT"
SDKROOT=`xcrun --show-sdk-path`
echo "SDKROOT not found at $SDKROOT_NOT_FOUND, trying $SDKROOT"
fi
if [ ! -d "${SDKROOT}" ]
then
echo "*** ${SDKROOT} does not exist, please install required SDK, or set SDKROOT manually. ***"
exit 1
fi
add_make "MACOSX_SDK=${SDKROOT}"
add_make "OSX_VERSION ?= ${OSX_VERSION}"
}
check_android_sdk()
{
[ -z "${ANDROID_NDK}" ] && echo "You must set ANDROID_NDK environment variable" && exit 1
add_make "ANDROID_NDK := ${ANDROID_NDK}"
[ -z "${ANDROID_ABI}" ] && echo "You must set ANDROID_ABI environment variable" && exit 1
add_make "ANDROID_ABI := ${ANDROID_ABI}"
[ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_NEON"
[ ${ANDROID_ABI} = "armeabi-v7a" ] && add_make_enabled "HAVE_ARMV7A"
[ ${ANDROID_ABI} = "armeabi" -a -z "${NO_ARMV6}" ] && add_make_enabled "HAVE_ARMV6"
}
test -z "$PREFIX" || add_make "PREFIX := $PREFIX"
#
# Checks
#
OS="${HOST#*-}" # strip architecture
case "${OS}" in
apple-darwin*)
if test -z "$BUILDFORIOS"
then
check_macosx_sdk
add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
else
check_ios_sdk
add_make_enabled "HAVE_IOS" "HAVE_DARWIN_OS" "HAVE_BSD" "HAVE_NEON" "HAVE_ARMV7A"
fi
;;
*bsd*)
add_make_enabled "HAVE_BSD"
;;
*android*)
check_android_sdk
add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
case "${HOST}" in
*arm*)
add_make "PLATFORM_SHORT_ARCH := arm"
;;
*i686*)
add_make "PLATFORM_SHORT_ARCH := x86"
;;
*mipsel*)
add_make "PLATFORM_SHORT_ARCH := mips"
;;
esac
;;
*linux*)
add_make_enabled "HAVE_LINUX"
;;
*wince*)
add_make_enabled "HAVE_WINCE"
;;
*mingw*)
add_make_enabled "HAVE_WIN32"
;;
*solaris*)
add_make_enabled "HAVE_SOLARIS"
;;
esac
#
# Results output
#
test -e Makefile && unlink Makefile
ln -sf ../../contrib/src/main.mak Makefile || exit $?
cat << EOF
Bootstrap completed.
Run "make" to start compilation.
Other targets:
* make install same as "make"
* make prebuilt fetch and install prebuilt binaries
* make list list packages
* make fetch fetch required source tarballs
* make fetch-all fetch all source tarballs
* make distclean clean everything and undo bootstrap
* make mostlyclean clean everything except source tarballs
* make clean clean everything
* make package prepare prebuilt packages
EOF
mkdir -p ../../contrib/tarballs || exit $?
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:
$(call download,$(FOO_URL))
# This will use the default rule: check SHA-512
.sum-foo: libfoo-$(FOO_VERSION).tar.bz2
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: libfoo-$(FOO_VERSION).tar.bz2 .sum-foo
$(UNPACK) # to libfoo-$(FOO_VERSION)
### apply patches here ###
# last command: make the target directory
$(MOVE)
.foo: libfoo
cd $< && $(HOSTVARS) ./configure $(HOSTCONF)
cd $< && $(MAKE) install
touch $@
Conditional builds
-------------------
As far as possible, build rules should determine automatically whether
a package is useful (for VLC media player) or not. Useful packages
should be listed in the PKGS special variable. See some examples:
# FFmpeg is always useful
PKGS += ffmpeg
# DirectX headers are useful only on Windows
ifdef HAVE_WIN32
PKGS += directx
endif
# x264 is only useful when stream output is enabled
ifdef BUILD_ENCODERS
PKGS += x264
endif
If a package is a dependency of another package, but it is not a
direct dependency of VLC, then it should NOT be added to PKGS. The
build system will automatically build it via dependencies (see below).
Some packages may be provided by the target system. This is especially
common when building natively on Linux or BSD. When this situation is
detected, the package name should be added to the PKGS_FOUND special
variable. The build system will then skip building this package:
# Asks pkg-config if foo version 1.2.3 or later is present:
ifeq ($(call need_pkg,'foo >= 1.2.3'),)
PKGS_FOUND += foo
endif
Note: The need_pkg function always return 1 during cross-compilation.
This is a known bug.
Dependencies
-------------
If package bar depends on package foo, the special DEPS_bar variable
should be defined as follow:
DEPS_bar = foo $(DEPS_foo)
Note that dependency resolution is unfortunately _not_ recursive.
Therefore $(DEPS_foo) really should be specified explicitly as shown
above. (In practice, this will not make any difference insofar as there
are no pure second-level nested dependencies. For instance, libass
depends on FontConfig, which depends on FreeType, but libass depends
directly on FreeType anyway.)
Also note that DEPS_bar is set "recursively" with =, rather than
"immediately" with :=. This is so that $(DEPS_foo) is expanded
correctly, even if DEPS_foo it is defined after DEPS_bar.
Implementation note:
If you must know, the main.mak build hackery will automatically
emit a dependency from .bar onto .dep-foo:
.bar: .dep-foo
...whereby .dep-foo will depend on .foo:
.dep-foo: .foo
touch $@
...unless foo was detected in the target distribution:
.dep-foo:
touch $@
So you really only need to set DEPS_bar.
#!/bin/sh
# ***************************************************************************
# change_prefix.sh : allow to transfer a contrib dir
# ***************************************************************************
# Copyright © 2012 VideoLAN and its authors
#
# Authors: Rafaël Carré
#
# 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.
# ***************************************************************************
set -e
LANG=C
export LANG
if test "$1" = "-h" -o "$1" = "--help" -o $# -gt 2; then
echo "Usage: $0 [old prefix] [new prefix]
Without arguments, this script assumes old prefix = @@CONTRIB_PREFIX@@,
and new prefix = current directory.
"
fi
if [ $# != 2 ]
then
old_prefix=@@CONTRIB_PREFIX@@
new_prefix=`pwd`
else
old_prefix=$1
new_prefix=$2
fi
# process [dir] [filemask] [text only]
process() {
for file in `find $1 -maxdepth 1 -type f -name "$2"`
do
if [ -n "$3" ]
then
file $file | sed "s/^.*: //" | grep -q 'text\|shell' || continue
fi
echo "Fixing up $file"
sed -i.orig -e "s,$old_prefix,$new_prefix,g" $file
rm -f $file.orig
done
}
process bin/ "*" check
process lib/ "*.la"
process lib/pkgconfig/ "*.pc"
#! /bin/sh
HOST="$1"
if test -z "$HOST"; then
echo "Usage: $0 <target machine>" >&2
exit 1
fi
case "$HOST" in
amd64-*)
ARCH="x86_64"
;;
i[3456]86-*)
ARCH="i386"
;;
powerpc-*|ppc-*)
ARCH="ppc"
;;
powerpc64-*|ppc64-*)
ARCH="ppc64"
;;
*-*)
ARCH="${HOST%%-*}"
;;
*)
echo "$HOST: invalid machine specification" >&2
exit 1
esac
echo $ARCH
This diff is collapsed.
#! /bin/sh
# Copyright (C) 2012 Rémi Denis-Courmont
# This file is distributed under the same license as the vlc package.
if test -z "$1" || test -n "$2"; then
echo "Usage: $0 <file.pc>" >&2
echo "Merges the pkg-config Libs.private stanza into Libs stanza." >&2
exit 1
fi
exec <"$1" >"$1.tmp" || exit $?
PUBLIC=""
PRIVATE=""
while read LINE; do
pub="${LINE#Libs:}"
priv="${LINE#Libs.private:}"
if test "$pub" != "$LINE"; then
PUBLIC="$pub"
elif test "$priv" != "$LINE"; then
PRIVATE="$priv"
else
echo "$LINE"
fi
done
echo "Libs: $PUBLIC $PRIVATE"
mv -f -- "$1.tmp" "$1"
*.tar.*
*.zip
*.h
*.tgz
*-git/
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