Commit 4e2b9801 authored by Accident's avatar Accident

Accident: Universal build of libbluray.so/a, examples/. Minor changes to build
          on Unix.
parent dd6bbf52
SUBDIRS=src/libbdplus src/libbdnav src/examples
SUBDIRS=src
EXTRA_DIST=README.txt
# SUggested by autoconf
ACLOCAL_AMFLAGS=-I m4
......@@ -3,18 +3,212 @@ AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign])
# Run ./configure in libaacs
#AC_CONFIG_SUBDIRS([src/libaacs])
# The big search for OpenSSL
# copied from openssh's configure.ac
tryssldir=""
AC_ARG_WITH(ssl-dir,
[ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
[
if test "x$withval" != "xno" ; then
tryssldir=$withval
fi
]
)
# Run ./configure in libbdplus
AC_CONFIG_SUBDIRS([src/libbdplus])
AC_PROG_CC
# Run ./configure in examples
AC_CONFIG_SUBDIRS([src/examples])
AC_PROG_CXX
# Run ./configure in libbdnav
AC_CONFIG_SUBDIRS([src/libbdnav])
AC_TYPE_SIGNAL
AC_HEADER_TIME
AC_CONFIG_FILES([Makefile])
AC_CHECK_HEADERS([stdarg.h varargs.h sys/time.h sys/types.h dirent.h sys/file.h sys/param.h sys/statfs.h sys/vfs.h sys/statvfs.h errno.h libgen.h time.h malloc.h stdlib.h mntent.h linux/cdrom.h])
# mount depends on param
AC_CHECK_HEADERS([sys/mount.h], [], [], [#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif])
AC_STRUCT_DIRENT_D_TYPE
AH_TEMPLATE([NEED_SYS_ERRLIST_DECLARED],
[Define this if sys_errlist must be declared (if it exists).])
AC_SYS_LARGEFILE
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_LIBTOOL
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket inet])
AC_SEARCH_LIBS([crypt], [crypt])
AC_SEARCH_LIBS([dlopen], [dl])
AC_CHECK_FUNC([snprintf],
[AC_DEFINE(HAVE_SNPRINTF,1,[Presence of snprintf found])],
[AC_MSG_WARN(Adding internal snprintf function)])
AC_CHECK_FUNC([strcasestr],
[AC_DEFINE(HAVE_STRCASESTR,1,[Presence of strcasestr found])],
[])
if test "x$ac_cv_prog_gcc" = xyes ; then
CFLAGS="$CFLAGS -Wall -g "
fi
AC_CHECK_FUNCS([strtoul strtouq strtoull strtoll])
dnl Where do you live, openssl? And how do we call you?
AC_ARG_WITH([openssl],
[AS_HELP_STRING([--without-openssl],[Disable openssl support])],
[],
[with_openssl=yes])
dnl If SSL was NOT disable, then go look for it.
if test x"$with_openssl" != x"no" ; then
AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssl_dir, [
saved_LIBS="$LIBS"
saved_LDFLAGS="$LDFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
ssl_found=no
for ssldir in $tryssldir "" $prefix /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS -lssl -lcrypto"
# Skip the directory if it isn't there.
if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
continue;
fi
if test ! -z "$ssldir" ; then
if test -d "$ssldir/lib" ; then
LDFLAGS="-L$ssldir/lib $LDFLAGS"
else
LDFLAGS="-L$ssldir $LDFLAGS"
fi
if test -d "$ssldir/include" ; then
CPPFLAGS="-I$ssldir/include $CPPFLAGS"
else
CPPFLAGS="-I$ssldir $CPPFLAGS"
fi
fi
# Can I link it?
AC_TRY_LINK([#include <openssl/rand.h>],
[ RAND_add((void*)0,0,0); ],
[ openssl_linked=yes ], [ openssl_linked=no ])
if test $openssl_linked = yes; then
if test ! -z "$ssldir" ; then
ac_cv_openssl_dir=$ssldir
else
ac_cv_openssl_dir="(system)"
fi
ssl_found=yes
break
fi
done
LIBS="$saved_LIBS"
LDFLAGS="$saved_LDFLAGS"
CPPFLAGS="$saved_CPPFLAGS"
if test $ssl_found = no ; then
AC_MSG_ERROR([Could not find a linkable OpenSSL. You can specify an explicit path using --with-ssl-dir])
fi
])
AC_DEFINE([WITH_SSL], 1, [Define if we found OpenSSL - Legacy name])
LIBS="$LIBS -lssl -lcrypto"
if test "$ac_cv_openssl_dir" != "(system)"; then
if test -d "$ac_cv_openssl_dir/lib" ; then
LDFLAGS="-L$ac_cv_openssl_dir/lib $LDFLAGS"
ssl_libdir="$ac_cv_openssl_dir/lib"
else
LDFLAGS="-L$ac_cv_openssl_dir $LDFLAGS"
ssl_libdir="$ac_cv_openssl_dir"
fi
if test -d "$ac_cv_openssl_dir/include" ; then
CPPFLAGS="-I$ac_cv_openssl_dir/include $CPPFLAGS"
else
CPPFLAGS="-I$ac_cv_openssl_dir $CPPFLAGS"
fi
fi
if test -z $CROSS_COMPILE
then
AC_CACHE_CHECK([whether we need extra options to link OpenSSL],
ac_cv_openssl_linker_option, [
saved_LDFLAGS="$LDFLAGS"
ssl_runs=no
linked_with=nothing
for ssl_extra in "" "-Wl,-R$ssl_libdir" "-R$ssl_libdir" ; do
LDFLAGS="$ssl_extra $saved_LDFLAGS"
AC_TRY_RUN([
#include <string.h>
#include <openssl/rand.h>
int main(void)
{
char a[2048];
memset(a, 0, sizeof(a));
RAND_add(a, sizeof(a), sizeof(a));
return(RAND_status() <= 0);
}
],
openssl_runs=yes, openssl_runs=no)
if test $openssl_runs = yes ; then
if test "$linked_with" = nothing; then
linked_with="$ssl_extra"
fi
AC_TRY_RUN([
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
int main(void) {
return (OPENSSL_VERSION_NUMBER == SSLeay()) == 0;
}],
right_version=yes, right_version=no)
if test "$right_version" = yes; then
if test -z "$ssl_extra" ; then
ac_cv_openssl_linker_option='(none)'
else
ac_cv_openssl_linker_option=$ssl_extra
fi
ssl_runs=yes
break
fi
fi
done
if test $ssl_runs = no ; then
if test "$linked_with" = 'nothing' ; then
AC_MSG_ERROR([Found linkable OpenSSL in $ac_cv_openssl_dir, but it doesn't run, even with -R. Maybe specify another using --with-ssl-dir?])
else
if test -z "$linked_with" ; then
ac_cv_openssl_linker_option='(none)'
else
ac_cv_openssl_linker_option=$linked_with
fi
AC_MSG_WARN([I managed to make OpenSSL link and run, but I couldn't make it link against the same version I found header files for.])
fi
fi
LDFLAGS="$saved_LDFLAGS"
])
if test "$ac_cv_openssl_linker_option" != '(none)' ; then
LDFLAGS="$ac_cv_openssl_linker_option $LDFLAGS"
fi
fi
dnl if NOSSL
fi
# Make sure OpenSSL is cool enough to play with the big boys.
AC_CHECK_HEADERS([openssl/ecdsa.h], [], [
AC_MSG_ERROR([Version of OpenSSL does not feature openssl/ecdsa.h, please upgrade]) ]
, [])
AM_CONFIG_HEADER(config.h)
# List all Makefiles here.
AC_CONFIG_FILES([Makefile src/Makefile src/libaacs/Makefile src/libbdnav/Makefile src/libbdplus/Makefile src/examples/Makefile])
AC_OUTPUT
SUBDIRS=libaacs libbdplus libbdnav examples
AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_builddir)/src/libbdplus
# The master library,
lib_LTLIBRARIES=libbluray.la
libbluray_la_SOURCES= bluray.c bluray.h
libbluray_la_LIBADD = libbdplus/libbdplus.la libbdnav/libbdnav.la
libbluray_la_LDFLAGS= -version-info 0:0:0
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <dlfcn.h>
#include <stdio.h>
......@@ -6,6 +17,9 @@
#include "util/macro.h"
#include "util/logging.h"
#include "bdplus.h"
BLURAY *bd_open(const char* device_path, const char* keyfile_path)
{
BLURAY *bd = malloc(sizeof(BLURAY));
......
AM_CPPFLAGS = -I $(top_builddir)/..
# Set this for all builds, or use $bin_CPPFLAGS for individual
AM_CPPFLAGS = -I$(top_builddir)/src
bin_PROGRAMS=bdplus_test bdsplice mpls_dump clpi_dump
bdplus_test_SOURCE=bdplus_test.c
bdplus_test_LDADD=$(top_builddir)/../libbdplus/libbdplus.a
bdplus_test_CPPFLAGS = -I$(top_builddir)/../libbdplus
BDNAV_LIB = $(top_builddir)/../libbdnav/libbdnav.a
bdplus_test_LDADD=$(top_builddir)/src/libbluray.la
bdplus_test_CPPFLAGS = -I$(top_builddir)/src/libbdplus
BDNAV_LIB = $(top_builddir)/src/libbdnav/libbdnav.la
bdsplice_SOURCES = \
bdsplice.c
......
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_STDINT_H
#include <stdint.h>
......@@ -7,9 +18,6 @@
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include "bdplus.h"
......@@ -35,7 +43,7 @@ int main(int argc, char **argv)
// Technically not required, yet
if (bdplus_init()) goto fail;
if (bdplus_init(NULL, NULL, NULL)) goto fail;
// Debug flags?
bluray_debuglevel = 3;
......
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <sys/stat.h>
#include <stdio.h>
#include <stdint.h>
......@@ -52,7 +63,7 @@ _write_packets(FILE *out, FILE *tsfile, uint32_t start_pkt, uint32_t end_pkt)
static void
_usage(char *cmd)
{
fprintf(stderr,
fprintf(stderr,
"Usage: %s -t playlist [-c first[-last]] <bd path> [dest]\n"
"Summary:\n"
" Given a playlist number and Blu-Ray directory tree,\n"
......@@ -86,7 +97,7 @@ main(int argc, char *argv[])
do {
opt = getopt(argc, argv, OPTS);
switch (opt) {
case -1:
case -1:
break;
case 't':
......@@ -151,7 +162,7 @@ main(int argc, char *argv[])
}
if (verbose) {
fprintf(stderr, "Start SPN %u - End SPN %u\n",
fprintf(stderr, "Start SPN %u - End SPN %u\n",
clip->start_pkt, clip->end_pkt);
}
size = _write_packets(out, tsfile, clip->start_pkt, clip->end_pkt);
......
AC_INIT([examples],[0.1.0], [bug-report@bdplus])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign])
# The big search for OpenSSL
# copied from openssh's configure.ac
tryssldir=""
AC_ARG_WITH(ssl-dir,
[ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
[
if test "x$withval" != "xno" ; then
tryssldir=$withval
fi
]
)
AC_PROG_CC
AC_PROG_CXX
AC_CHECK_PROG(BUILD, build, build)
AC_TYPE_SIGNAL
AC_HEADER_TIME
AC_CHECK_HEADERS([stdarg.h varargs.h sys/time.h sys/types.h dirent.h sys/file.h sys/param.h sys/statfs.h sys/vfs.h sys/statvfs.h errno.h libgen.h time.h])
# mount depends on param
AC_CHECK_HEADERS([sys/mount.h], [], [], [#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif])
AC_STRUCT_DIRENT_D_TYPE
AH_TEMPLATE([NEED_SYS_ERRLIST_DECLARED],
[Define this if sys_errlist must be declared (if it exists).])
AC_SYS_LARGEFILE
AC_PROG_RANLIB
AC_SEARCH_LIBS([gethostbyname], [nsl])
AC_SEARCH_LIBS([socket], [socket inet])
AC_SEARCH_LIBS([crypt], [crypt])
AC_SEARCH_LIBS([dlopen], [dl])
AC_CHECK_FUNC([snprintf],
[AC_DEFINE(HAVE_SNPRINTF,1,[Presence of snprintf found])],
[AC_MSG_WARN(Adding internal snprintf function)])
AC_CHECK_FUNC([strcasestr],
[AC_DEFINE(HAVE_STRCASESTR,1,[Presence of strcasestr found])],
[])
if test "x$ac_cv_prog_gcc" = xyes ; then
CFLAGS="$CFLAGS -Wall -g "
fi
AC_CHECK_FUNCS([strtoul strtouq strtoull strtoll])
dnl Where do you live, openssl? And how do we call you?
AC_ARG_WITH([openssl],
[AS_HELP_STRING([--without-openssl],[Disable openssl support])],
[],
[with_openssl=yes])
dnl If SSL was NOT disable, then go look for it.
if test x"$with_openssl" != x"no" ; then
AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssl_dir, [
saved_LIBS="$LIBS"
saved_LDFLAGS="$LDFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
ssl_found=no
for ssldir in $tryssldir "" $prefix /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/athena /usr/pkg /opt /opt/openssl ; do
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS -lssl -lcrypto"
# Skip the directory if it isn't there.
if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
continue;
fi
if test ! -z "$ssldir" ; then
if test -d "$ssldir/lib" ; then
LDFLAGS="-L$ssldir/lib $LDFLAGS"
else
LDFLAGS="-L$ssldir $LDFLAGS"
fi
if test -d "$ssldir/include" ; then
CPPFLAGS="-I$ssldir/include $CPPFLAGS"
else
CPPFLAGS="-I$ssldir $CPPFLAGS"
fi
fi
# Can I link it?
AC_TRY_LINK([#include <openssl/rand.h>],
[ RAND_add((void*)0,0,0); ],
[ openssl_linked=yes ], [ openssl_linked=no ])
if test $openssl_linked = yes; then
if test ! -z "$ssldir" ; then
ac_cv_openssl_dir=$ssldir
else
ac_cv_openssl_dir="(system)"
fi
ssl_found=yes
break
fi
done
LIBS="$saved_LIBS"
LDFLAGS="$saved_LDFLAGS"
CPPFLAGS="$saved_CPPFLAGS"
if test $ssl_found = no ; then
AC_MSG_ERROR([Could not find a linkable OpenSSL. You can specify an explicit path using --with-ssl-dir])
fi
])
AC_DEFINE([WITH_SSL], 1, [Define if we found OpenSSL - Legacy name])
LIBS="$LIBS -lssl -lcrypto"
if test "$ac_cv_openssl_dir" != "(system)"; then
if test -d "$ac_cv_openssl_dir/lib" ; then
LDFLAGS="-L$ac_cv_openssl_dir/lib $LDFLAGS"
ssl_libdir="$ac_cv_openssl_dir/lib"
else
LDFLAGS="-L$ac_cv_openssl_dir $LDFLAGS"
ssl_libdir="$ac_cv_openssl_dir"
fi
if test -d "$ac_cv_openssl_dir/include" ; then
CPPFLAGS="-I$ac_cv_openssl_dir/include $CPPFLAGS"
else
CPPFLAGS="-I$ac_cv_openssl_dir $CPPFLAGS"
fi
fi
if test -z $CROSS_COMPILE
then
AC_CACHE_CHECK([whether we need extra options to link OpenSSL],
ac_cv_openssl_linker_option, [
saved_LDFLAGS="$LDFLAGS"
ssl_runs=no
linked_with=nothing
for ssl_extra in "" "-Wl,-R$ssl_libdir" "-R$ssl_libdir" ; do
LDFLAGS="$ssl_extra $saved_LDFLAGS"
AC_TRY_RUN([
#include <string.h>
#include <openssl/rand.h>
int main(void)
{
char a[2048];
memset(a, 0, sizeof(a));
RAND_add(a, sizeof(a), sizeof(a));
return(RAND_status() <= 0);
}
],
openssl_runs=yes, openssl_runs=no)
if test $openssl_runs = yes ; then
if test "$linked_with" = nothing; then
linked_with="$ssl_extra"
fi
AC_TRY_RUN([
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
int main(void) {
return (OPENSSL_VERSION_NUMBER == SSLeay()) == 0;
}],
right_version=yes, right_version=no)
if test "$right_version" = yes; then
if test -z "$ssl_extra" ; then
ac_cv_openssl_linker_option='(none)'
else
ac_cv_openssl_linker_option=$ssl_extra
fi
ssl_runs=yes
break
fi
fi
done
if test $ssl_runs = no ; then
if test "$linked_with" = 'nothing' ; then
AC_MSG_ERROR([Found linkable OpenSSL in $ac_cv_openssl_dir, but it doesn't run, even with -R. Maybe specify another using --with-ssl-dir?])
else
if test -z "$linked_with" ; then
ac_cv_openssl_linker_option='(none)'
else
ac_cv_openssl_linker_option=$linked_with
fi
AC_MSG_WARN([I managed to make OpenSSL link and run, but I couldn't make it link against the same version I found header files for.])
fi
fi
LDFLAGS="$saved_LDFLAGS"
])
if test "$ac_cv_openssl_linker_option" != '(none)' ; then
LDFLAGS="$ac_cv_openssl_linker_option $LDFLAGS"
fi
fi
dnl if NOSSL
fi
dnl static build?
AC_ARG_ENABLE(static,
[ --enable-static Enable static linking [[default=no ]] ],
static="$enableval", static="no")
AC_MSG_CHECKING([for --enable-static])
AC_MSG_RESULT($static)
if test $static == yes; then
LDFLAGS="$LDFLAGS -static";
AC_DEFINE([STATIC_BUILD], [], [Define when making a static build])
fi
AM_CONFIG_HEADER(config.h)
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include "configfile.h"
#include "file.h"
......
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <dirent.h>
#include "dir.h"
......
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <stdio.h>
#include "file.h"
......
## Process this file with automake to produce Makefile.in
AM_CPPFLAGS = -I $(top_builddir)/..
AM_CPPFLAGS = -I $(top_builddir)/src
noinst_LIBRARIES = libbdnav.a
noinst_LTLIBRARIES = libbdnav.la
libbdnav_a_SOURCES = \
libbdnav_la_SOURCES = \
../util/logging.c \
../util/strutl.c \
../file/file_posix.c \
......
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <stdint.h>
#include <string.h>
#include "../util/macro.h"
......
......@@ -5,6 +5,11 @@
char out[512];
debug_mask_t debug_mask = 0;
static int debug_init = 0;
char *print_hex(uint8_t *buf, int count)
{
memset(out, 0, count);
......@@ -19,16 +24,20 @@ char *print_hex(uint8_t *buf, int count)
void debug(char *file, int line, uint32_t mask, const char *format, ...)
{
uint32_t master_mask;
char *env;
if ((env = getenv("BD_DEBUG_MASK"))) {
master_mask = atoi(env);
} else {
master_mask = 0xffff;