genmf 1.86 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#! /bin/sh

##  genmf file for the VLC media player
##
## Copyright (C) 2005-2007 the VideoLAN team
##
##  Authors: Sam Hocevar <sam@zoy.org>
##           Rémi Denis-Courmont <rem # videolan # org>

cd $(dirname "$0")/.. || exit 1

while test "$1"
do
  dir="$1"
  modf="modules/${dir}/Modules.am"
16
  if test ! -f "$modf"; then
17 18 19
    echo "$modf does not exist!" >&2
    exit 1
  fi
20 21
  makf="modules/${dir}/Makefile.am"
  basedir="`echo "${dir}" | cut -f1 -d/`"
22 23
  mods="`sed -n -e 's/^ *SOURCES_\([^ ]*\).*/\1/p' < "${modf}" | sort | uniq | xargs`"
  plugins="`sed -n -e 's/^.*lib\([^ ]*\)_plugin\.la.*/\1/p' < "${modf}" | sort | uniq | xargs`"
24
  rm -f "${makf}" && cat > "${makf}" << EOF
Rémi Denis-Courmont's avatar
Rémi Denis-Courmont committed
25 26
# ${makf} automatically generated from ${modf} by $0
# DO NOT EDIT THIS FILE DIRECTLY! See Modules.am instead.
27

28 29 30
${basedir}dir = \$(pluginsdir)/${basedir}
${basedir}_LTLIBRARIES =
EXTRA_LTLIBRARIES =
31

32 33
EXTRA_DIST = Modules.am

34
include \$(top_srcdir)/modules/common.am
35 36 37 38
include \$(srcdir)/Modules.am

if MAINTAINER_MODE
\$(srcdir)/Makefile.am: \$(srcdir)/Modules.am \$(top_srcdir)/modules/genmf
39
	\$(AM_V_GEN)cd \\\$(top_srcdir) && \\\$(SHELL) modules/genmf ${dir}
40
endif
41 42 43 44
EOF
  for mod in $mods
  do
    cat >> "${makf}" << EOF
45

46
lib${mod}_plugin_la_SOURCES = \$(SOURCES_${mod})
47 48
lib${mod}_plugin_la_CPPFLAGS = \$(AM_CPPFLAGS) \$(CPPFLAGS_${mod}) \
	-DMODULE_NAME_IS_${mod}
49 50 51
lib${mod}_plugin_la_CFLAGS = \$(AM_CFLAGS) \$(CFLAGS_${mod})
lib${mod}_plugin_la_CXXFLAGS = \$(AM_CXXFLAGS) \$(CXXFLAGS_${mod})
lib${mod}_plugin_la_OBJCFLAGS = \$(AM_OBJCFLAGS) \$(OBJCFLAGS_${mod})
52
lib${mod}_plugin_la_LIBADD = \$(LIBS_${mod})
53 54 55 56 57 58 59 60 61
lib${mod}_plugin_la_LDFLAGS = \$(AM_LDFLAGS) -rpath '\$(${basedir}dir)' \$(LDFLAGS_${mod})
EOF
    case " ${plugins} " in
      *\ ${mod}\ *)
	;;
      *)
        cat >> "${makf}" << EOF
EXTRA_LTLIBRARIES += lib${mod}_plugin.la
${basedir}_LTLIBRARIES += \$(LTLIB${mod})
62
EOF
63 64
      ;;
    esac
65 66 67 68
  done

  shift
done