m4/gst.m4: Add
[platform/upstream/gst-common.git] / m4 / gst-check.m4
1 dnl pkg-config-based checks for GStreamer modules and dependency modules
2
3 dnl generic:
4 dnl AG_GST_PKG_CHECK_MODULES([PREFIX], [WHICH], [REQUIRED])
5 dnl sets HAVE_[$PREFIX], [$PREFIX]_*
6 dnl AG_GST_CHECK_MODULES([PREFIX], [MODULE], [MINVER], [NAME], [REQUIRED])
7 dnl sets HAVE_[$PREFIX], [$PREFIX]_*
8
9 dnl specific:
10 dnl AG_GST_CHECK_GST([MAJMIN], [MINVER], [REQUIRED])
11 dnl   also sets/ACSUBSTs GST_TOOLS_DIR and GST_PLUGINS_DIR
12 dnl AG_GST_CHECK_GST_BASE([MAJMIN], [MINVER], [REQUIRED])
13 dnl AG_GST_CHECK_GST_GDP([MAJMIN], [MINVER], [REQUIRED])
14 dnl AG_GST_CHECK_GST_CONTROLLER([MAJMIN], [MINVER], [REQUIRED])
15 dnl AG_GST_CHECK_GST_CHECK([MAJMIN], [MINVER], [REQUIRED])
16 dnl AG_GST_CHECK_GST_PLUGINS_BASE([MAJMIN], [MINVER], [REQUIRED])
17 dnl   also sets/ACSUBSTs GSTPB_PLUGINS_DIR
18
19 AC_DEFUN([AG_GST_PKG_CHECK_MODULES],
20 [
21   which="[$2]"
22   dnl not required by default, since we use this mostly for plugin deps
23   required=ifelse([$3], , "no", [$3])
24
25   PKG_CHECK_MODULES([$1], $which,
26     [
27       HAVE_[$1]="yes"
28     ],
29     [
30       HAVE_[$1]="no"
31       AC_MSG_RESULT(no)
32       if test "x$required" = "xyes"; then
33         AC_MSG_ERROR($[$1]_PKG_ERRORS)
34       else
35         AC_MSG_NOTICE($[$1]_PKG_ERRORS)
36       fi
37     ])
38
39   dnl AC_SUBST of CFLAGS and LIBS was not done before automake 1.7
40   dnl It gets done automatically in automake >= 1.7, which we now require
41 ]))
42
43 AC_DEFUN([AG_GST_CHECK_MODULES],
44 [
45   module=[$2]
46   minver=[$3]
47   name="[$4]"
48   required=ifelse([$5], , "yes", [$5]) dnl required by default
49
50   PKG_CHECK_MODULES([$1], $module >= $minver,
51     [
52       HAVE_[$1]="yes"
53     ],
54     [
55       HAVE_[$1]="no"
56       AC_MSG_RESULT(no)
57       AC_MSG_NOTICE($[$1]_PKG_ERRORS)
58       if test "x$required" = "xyes"; then
59         AC_MSG_ERROR([no $module >= $minver ($name) found])
60       else
61         AC_MSG_NOTICE([no $module >= $minver ($name) found])
62       fi
63     ])
64
65   dnl AC_SUBST of CFLAGS and LIBS was not done before automake 1.7
66   dnl It gets done automatically in automake >= 1.7, which we now require
67 ]))
68
69 AC_DEFUN([AG_GST_CHECK_GST],
70 [
71   AG_GST_CHECK_MODULES(GST, gstreamer-[$1], [$2], [GStreamer], [$3])
72   GST_TOOLS_DIR=`$PKG_CONFIG --variable=toolsdir gstreamer-[$1]`
73   if test -z $GST_TOOLS_DIR; then
74     AC_MSG_ERROR(
75       [no tools dir set in GStreamer pkg-config file; core upgrade needed.])
76   fi
77   AC_SUBST(GST_TOOLS_DIR)
78
79   dnl check for where core plug-ins got installed
80   dnl this is used for unit tests
81   GST_PLUGINS_DIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-[$1]`
82   if test -z $GST_PLUGINS_DIR; then
83     AC_MSG_ERROR(
84       [no pluginsdir set in GStreamer pkg-config file; core upgrade needed.])
85   fi
86   AC_SUBST(GST_PLUGINS_DIR)
87 ])
88
89 AC_DEFUN([AG_GST_CHECK_GST_BASE],
90 [
91   AG_GST_CHECK_MODULES(GST_BASE, gstreamer-base-[$1], [$2],
92     [GStreamer Base Libraries], [$3])
93 ])
94   
95 AC_DEFUN([AG_GST_CHECK_GST_GDP],
96 [
97   AG_GST_CHECK_MODULES(GST_GDP, gstreamer-dataprotocol-[$1], [$2],
98     [GStreamer Data Protocol Library], [$3])
99 ])
100   
101 AC_DEFUN([AG_GST_CHECK_GST_CONTROLLER],
102 [
103   AG_GST_CHECK_MODULES(GST_CONTROLLER, gstreamer-controller-[$1], [$2],
104     [GStreamer Controller Library], [$3])
105 ])  
106
107 AC_DEFUN([AG_GST_CHECK_GST_CHECK],
108 [
109   AG_GST_CHECK_MODULES(GST_CHECK, gstreamer-check-[$1], [$2],
110     [GStreamer Check unittest Library], [$3])
111 ])
112
113 AC_DEFUN([AG_GST_CHECK_GST_PLUGINS_BASE],
114 [
115   AG_GST_CHECK_MODULES(GST_PLUGINS_BASE, gstreamer-plugins-base-[$1], [$2],
116     [GStreamer Base Plug-ins Library], [$3])
117
118   dnl check for where base plug-ins got installed
119   dnl this is used for unit tests
120   GSTPB_PLUGINS_DIR=`$PKG_CONFIG --variable=pluginsdir gstreamer-plugins-base-[$1]`
121   if test -z $GSTPB_PLUGINS_DIR; then
122     AC_MSG_ERROR(
123       [no pluginsdir set in GStreamer Base Plug-ins pkg-config file])
124   fi
125   AC_SUBST(GSTPB_PLUGINS_DIR)
126 ])