diff options
author | Mans Rullgard <mans@mansr.com> | 2012-10-15 02:38:17 +0100 |
---|---|---|
committer | Mans Rullgard <mans@mansr.com> | 2012-10-23 12:01:18 +0100 |
commit | 4ebc6a74108f6c0448249b398ef33b25f3b16c0c (patch) | |
tree | 192b17707146db4caf896724cf89897de89a539b | |
parent | 80521c1997a23e148edf89e11b939ab8646297ca (diff) | |
download | ffmpeg-streaming-4ebc6a74108f6c0448249b398ef33b25f3b16c0c.zip ffmpeg-streaming-4ebc6a74108f6c0448249b398ef33b25f3b16c0c.tar.gz |
build: Plan 9 support
This adds support for building on Plan 9 x86-32. The compat/plan9
directory contains these items:
- replacements for the 'head' and 'printf' shell commands
- wrapper for main() to disable FPU exceptions
Larger required changes to the system are described in the
documentation.
Signed-off-by: Mans Rullgard <mans@mansr.com>
-rwxr-xr-x | compat/plan9/head | 10 | ||||
-rw-r--r-- | compat/plan9/main.c | 34 | ||||
-rwxr-xr-x | compat/plan9/printf | 2 | ||||
-rwxr-xr-x | configure | 22 | ||||
-rw-r--r-- | doc/platform.texi | 63 | ||||
-rw-r--r-- | libavformat/os_support.h | 2 |
6 files changed, 131 insertions, 2 deletions
diff --git a/compat/plan9/head b/compat/plan9/head new file mode 100755 index 0000000..2840b2d --- /dev/null +++ b/compat/plan9/head @@ -0,0 +1,10 @@ +#!/bin/sh + +n=10 + +case "$1" in + -n) n=$2; shift 2 ;; + -n*) n=${1#-n}; shift ;; +esac + +exec sed ${n}q "$@" diff --git a/compat/plan9/main.c b/compat/plan9/main.c new file mode 100644 index 0000000..97d7067 --- /dev/null +++ b/compat/plan9/main.c @@ -0,0 +1,34 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +int plan9_main(int argc, char **argv); + +#undef main +int main(int argc, char **argv) +{ + /* The setfcr() function in lib9 is broken, must use asm. */ +#ifdef __i386 + short fcr; + __asm__ volatile ("fstcw %0 \n" + "or $63, %0 \n" + "fldcw %0 \n" + : "=m"(fcr)); +#endif + + return plan9_main(argc, argv); +} diff --git a/compat/plan9/printf b/compat/plan9/printf new file mode 100755 index 0000000..1a70a9e --- /dev/null +++ b/compat/plan9/printf @@ -0,0 +1,2 @@ +#!/bin/sh +exec awk "BEGIN { for (i = 2; i < ARGC; i++) printf \"$1\", ARGV[i] }" "$@" @@ -956,7 +956,7 @@ apply(){ cp_if_changed(){ cmp -s "$1" "$2" && echo "$2 is unchanged" && return mkdir -p "$(dirname $2)" - cp -f "$1" "$2" + $cp_f "$1" "$2" } # CONFIG_LIST contains configurable options, while HAVE_LIST is for @@ -1753,6 +1753,7 @@ shlibdir_default="$libdir_default" ar_default="ar" cc_default="gcc" host_cc_default="gcc" +cp_f="cp -f" ln_s="ln -sf" nm_default="nm -g" objformat="elf" @@ -2879,6 +2880,19 @@ case $target_os in ;; minix) ;; + plan9) + add_cppflags -D_C99_SNPRINTF_EXTENSION \ + -D_REENTRANT_SOURCE \ + -D_RESEARCH_SOURCE \ + -DFD_SETSIZE=96 \ + -DHAVE_SOCK_OPTS + add_compat strtod.o strtod=avpriv_strtod + network_extralibs='-lbsd' + exeobjs=compat/plan9/main.o + disable avserver + ln_s='ln -s -f' + cp_f='cp' + ;; none) ;; *) @@ -3531,6 +3545,12 @@ elif enabled msvc; then enabled x86_32 && disable aligned_stack fi +case $target_os in + plan9) + add_cppflags -Dmain=plan9_main + ;; +esac + enabled_any $THREADS_LIST && enable threads enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; } diff --git a/doc/platform.texi b/doc/platform.texi index d637f00..6bb7136 100644 --- a/doc/platform.texi +++ b/doc/platform.texi @@ -298,4 +298,67 @@ and for a build with shared libraries ./configure --target-os=mingw32 --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin @end example +@chapter Plan 9 + +The native @uref{http://plan9.bell-labs.com/plan9/, Plan 9} compiler +does not implement all the C99 features needed by Libav so the gcc +port must be used. Furthermore, a few items missing from the C +library and shell environment need to be fixed. + +@itemize + +@item GNU awk, grep, make, and sed + +Working packages of these tools can be found at +@uref{http://code.google.com/p/ports2plan9/downloads/list, ports2plan9}. +They can be installed with @uref{http://9front.org/, 9front's} @code{pkg} +utility by setting @code{pkgpath} to +@code{http://ports2plan9.googlecode.com/files/}. + +@item Missing/broken @code{head} and @code{printf} commands + +Replacements adequate for building Libav can be found in the +@code{compat/plan9} directory. Place these somewhere they will be +found by the shell. These are not full implementations of the +commands and are @emph{not} suitable for general use. + +@item Missing C99 @code{stdint.h} and @code{inttypes.h} + +Replacement headers are available from +@url{http://code.google.com/p/plan9front/issues/detail?id=152}. + +@item Missing or non-standard library functions + +Some functions in the C library are missing or incomplete. The +@code{@uref{http://ports2plan9.googlecode.com/files/gcc-apelibs-1207.tbz, +gcc-apelibs-1207}} package from +@uref{http://code.google.com/p/ports2plan9/downloads/list, ports2plan9} +includes an updated C library, but installing the full package gives +unusable executables. Instead, keep the files from @code{gccbin.tgz} +under @code{/386/lib/gnu}. From the @code{libc.a} archive in the +@code{gcc-apelibs-1207} package, extract the following object files and +turn them into a library: + +@itemize +@item @code{strerror.o} +@item @code{strtoll.o} +@item @code{snprintf.o} +@item @code{vsnprintf.o} +@item @code{vfprintf.o} +@item @code{_IO_getc.o} +@item @code{_IO_putc.o} +@end itemize + +Use the @code{--extra-libs} option of @code{configure} to inform the +build system of this library. + +@item FPU exceptions enabled by default + +Unlike most other systems, Plan 9 enables FPU exceptions by default. +These must be disabled before calling any Libav functions. While the +included tools will do this automatically, other users of the +libraries must do it themselves. + +@end itemize + @bye diff --git a/libavformat/os_support.h b/libavformat/os_support.h index 1bf79eb..c5d3ab4 100644 --- a/libavformat/os_support.h +++ b/libavformat/os_support.h @@ -58,7 +58,7 @@ static inline int is_dos_path(const char *path) return 0; } -#if defined(__OS2__) +#if defined(__OS2__) || defined(__Plan9__) #define SHUT_RD 0 #define SHUT_WR 1 #define SHUT_RDWR 2 |