[SF#671] The "alias" config in 'weather' plugin may be numeric, not string.
[lxde/lxpanel.git] / configure.ac
index f1a7f36..4a08f98 100644 (file)
@@ -1,8 +1,12 @@
 AC_PREREQ(2.53)
-AC_INIT(lxpanel, 0.5.4.1, http://lxde.org/)
-AM_INIT_AUTOMAKE
-AC_CONFIG_SRCDIR([src/bg.c])
+AC_INIT(lxpanel, 0.7.0, http://lxde.org/)
+AM_INIT_AUTOMAKE([-Wall foreign no-dist-gzip dist-xz])
 AC_CONFIG_HEADER([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+
+# Support silent build rules. Disable by either passing --disable-silent-rules
+# to configure or passing V=1 to make
+AM_SILENT_RULES([yes])
 
 # Force to dynamic
 AC_DISABLE_STATIC
@@ -11,19 +15,70 @@ AC_DISABLE_STATIC
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
-AC_PROG_LIBTOOL
 AC_PROG_INTLTOOL(, [no-xml])
 AM_PROG_CC_C_O
+m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
+
+#Initialize libtool
+LT_PREREQ([2.2])
+LT_INIT
 
 # Checks for libraries.
-pkg_modules="gtk+-2.0 >= 2.12.0 \
+AC_ARG_ENABLE(gtk3,
+AC_HELP_STRING([--enable-gtk3],[enable to use gtk-3.0 instead of gtk-2.0]),
+[case "${enableval}" in
+  yes)  enable_gtk3=yes ;;
+  no)   enable_gtk3=no ;;
+  *) AC_MSG_ERROR([bad value "${enableval}" for --enable-gtk3, use "yes" (default) or "no".]) ;;
+esac],[])
+
+if test "x$enable_gtk3" = "xyes" ; then
+  CFLAGS="$CFLAGS -DENABLE_GTK3"
+  pkg_modules="$pkg_modules gtk+-3.0 libfm-gtk3 >= 1.2.0 libwnck-3.0"
+else
+  pkg_modules="$pkg_modules gtk+-2.0 >= 2.18.0 libfm-gtk >= 1.2.0 libwnck-1.0"
+fi
+
+pkg_modules="$pkg_modules \
              gio-unix-2.0 \
-             gthread-2.0"
-#             libstartup-notification-1.0"
+             gthread-2.0 \
+             gmodule-2.0"
 PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
 AC_SUBST(PACKAGE_CFLAGS)
 AC_SUBST(PACKAGE_LIBS)
 
+###########################
+# Indicator Info
+###########################
+AC_ARG_ENABLE([indicator_support],
+    AS_HELP_STRING([--enable-indicator-support],
+               [enable plugin loading (default: disable)]),
+               indicator_support=$enableval, indicator_support="no")
+AM_CONDITIONAL(ENABLE_INDICATOR_SUPPORT, test x"$indicator_support" = x"yes")
+
+if test "$indicator_support" != "no"; then
+       INDICATOR_REQUIRED_VERSION=0.3.0
+       INDICATOR_PKG_NAME=indicator-0.4
+
+       PKG_CHECK_MODULES(APPLET, $INDICATOR_PKG_NAME >= $INDICATOR_REQUIRED_VERSION)
+       AC_SUBST(APPLET_CFLAGS)
+
+       if test "x$with_localinstall" = "xyes"; then
+               INDICATORDIR="${libdir}/indicators/2/"
+               INDICATORICONSDIR="${datadir}/indicator-applet/icons/"
+       else
+               INDICATORDIR=`$PKG_CONFIG --variable=indicatordir $INDICATOR_PKG_NAME`
+               INDICATORICONSDIR=`$PKG_CONFIG --variable=iconsdir $INDICATOR_PKG_NAME`
+fi
+       AC_SUBST(INDICATORDIR)
+       AC_SUBST(INDICATORICONSDIR)
+fi
+
+
+pkg_modules="x11"
+PKG_CHECK_MODULES(X11, [$pkg_modules])
+AC_SUBST(X11_LIBS)
+
 pkg_modules="libmenu-cache"
 PKG_CHECK_MODULES(MENU_CACHE, [$pkg_modules],
                  enable_menu_cache=yes, enable_menu_cache=no)
@@ -33,9 +88,21 @@ if test x"$enable_menu_cache" = "xno"; then
 fi
 AC_SUBST(MENU_CACHE_CFLAGS)
 AC_SUBST(MENU_CACHE_LIBS)
-AM_CONDITIONAL(ENABLE_MENU_CACHE, test x"$enable_menu_cache" = x"yes") 
+AM_CONDITIONAL(ENABLE_MENU_CACHE, test x"$enable_menu_cache" = x"yes")
 
-PACKAGE_CFLAGS="$PACKAGE_CFLAGS $MENU_CACHE_CFLAGS"
+AC_ARG_ENABLE(more_warnings,
+       [AC_HELP_STRING([--enable-more-warnings],
+               [Add more warnings @<:@default=no@:>@])],
+       [enable_more_warnings="${enableval}"],
+       [enable_more_warnings=no]
+)
+
+if test x"$enable_more_warnings" = x"yes"; then
+  ADDITIONAL_FLAGS="-Wall -Werror=all -Werror=format -Werror=implicit-function-declaration -Werror=implicit-int -Werror=missing-braces -Werror=parentheses -Werror=return-type -Werror=strict-aliasing -Werror=switch -Wuninitialized -Werror=unused-label -Werror=unused-value -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Werror=missing-declarations -Wredundant-decls -Wmissing-noreturn -Wpointer-arith -Wcast-align -Wwrite-strings -Werror=inline -Werror=format-nonliteral -Wformat-nonliteral -Werror=format-security -Wformat-security -Winit-self -Werror=missing-include-dirs -Werror=undef -Werror=aggregate-return -Wmissing-format-attribute -Werror=nested-externs -fno-strict-aliasing -fmessage-length=0 -Wp,-D_FORTIFY_SOURCE=2 -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -DGDK_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_DEPRECATED -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED -DGTK_DISABLE_SINGLE_INCLUDES"
+fi
+AC_SUBST(ADDITIONAL_FLAGS)
+
+PACKAGE_CFLAGS="$PACKAGE_CFLAGS $MENU_CACHE_CFLAGS $ADDITIONAL_FLAGS"
 PACKAGE_LIBS="$PACKAGE_LIBS $MENU_CACHE_LIBS"
 
 AC_ARG_ENABLE(man,
@@ -45,16 +112,6 @@ AC_ARG_ENABLE(man,
        [enable_man=no]
 )
 
-AC_ARG_ENABLE([cast-checks],
-    AS_HELP_STRING([--enable-cast-checks],
-               [enable Glib casting checks (default: disable)]),
-               cast_checks=$enableval, cast_checks="no")
-G_CAST_CHECKS=""
-if test x"$cast_checks" = "xno"; then
-    G_CAST_CHECKS="-DG_DISABLE_CAST_CHECKS"
-fi
-AC_SUBST(G_CAST_CHECKS)
-
 dnl linker tweaking
 # The function of the link flag --as-needed is to prevent unnecesary linking.
 # Example: A -> B -> C
@@ -147,6 +204,7 @@ fi
 
 dnl Here are plugin listing.
 plugin_netstatus=
+plugin_netstat=
 plugin_volume=
 plugin_volumealsa=
 plugin_cpu=
@@ -156,14 +214,19 @@ plugin_xkb=
 plugin_kbled=
 plugin_thermal=
 plugin_cpufreq=
+plugin_monitors=
+plugin_indicator=
 
 AC_MSG_CHECKING([which plugins should be built dynamically])
 AC_ARG_WITH(plugins,
 [  --with-plugins=<list>  compile dynamic plugins in <list> ]
 [                         plugins may be comma separated ]
 [                         'all' builds all plugins (default), 'none' builds none ]
+[                         plugins prefixed with '-' are not built]
 [                         Possible plugins are: ]
-[                         netstatus, volume, volumealsa, cpu, deskno, batt, kbled, xkb, thermal, cpufreq], plugins="$withval",[plugins="all"])
+[                         netstatus, netstat, volume, volumealsa, cpu, deskno, batt,]
+[                         kbled, xkb, thermal, cpufreq, monitors, weather]
+, plugins="$withval",[plugins="all"])
 
 if test x"$plugins" != xall -a x"$plugins" != xnone; then
     if test x"$plugins_loading" = xno; then
@@ -172,71 +235,44 @@ if test x"$plugins" != xall -a x"$plugins" != xnone; then
     fi
 fi
 
-ALL_PLUGINS_LIST="netstatus volume volumealsa cpu deskno batt kbled xkb thermal cpufreq"
+ALL_PLUGINS_LIST="netstatus netstat volume volumealsa cpu deskno batt kbled xkb thermal cpufreq monitors indicator weather"
 AC_SUBST(ALL_PLUGINS_LIST)
 
-if test x"$plugins" = xall; then
-dnl    for name in $ALL_PLUGINS
-dnl    do
-dnl        export plugin_$name="$name"
-dnl    done
-
-    plugin_netstatus=netstatus
-    plugin_volume=volume
-    plugin_volumealsa=volumealsa
-    plugin_cpu=cpu
-    plugin_deskno=deskno
-    plugin_batt=batt
-    plugin_kbled=kbled
-    plugin_xkb=xkb
-    plugin_thermal=thermal
-    plugin_cpufreq=cpufreq
-
-    AC_MSG_RESULT(all)
-else
-    if test "$plugins" != "none"; then
-        plugins=`echo $plugins | sed 's/,/ /g'`
-        for plugin in $plugins
-        do
+AC_DEFUN([check_plugin_name],[
+    plugin_found=false
+    for name in $ALL_PLUGINS_LIST; do
+        if test x[$1] = x[$name]; then
+            plugin_found=true
+        fi
+    done
+    if test x[$plugin_found] = false; then
+        echo [Unknown plugin $1.]
+        exit 1
+    fi
+])
+
+if test "$plugins" != "none"; then
+    plugins=`echo $plugins | sed 's/,/ /g'`
+    for plugin in $plugins
+    do
         case "$plugin" in
-            netstatus)
-                plugin_netstatus=netstatus
-                ;;
-            volume)
-                plugin_volume=volume
-                ;;
-            volumealsa)
-                plugin_volumealsa=volumealsa
-                ;;
-            cpu)
-                plugin_cpu=cpu
-                ;;
-            deskno)
-                plugin_deskno=deskno
-                ;;
-            batt)
-                plugin_batt=batt
+            all)
+                for name in $ALL_PLUGINS_LIST
+                do
+                    export plugin_$name="$name"
+                done
                 ;;
-            kbled)
-                plugin_kbled=kbled
-                ;;
-            xkb)
-                plugin_xkb=xkb
-                ;;
-            thermal)
-                plugin_thermal=thermal
-                ;;
-            cpufreq)
-                plugin_cpufreq=cpufreq
+            -*)
+                check_plugin_name([${plugin#-}])
+                export plugin_${plugin#-}=
                 ;;
             *)
-                echo "Unknown plugin $plugin."
-                exit 1
+                check_plugin_name([$plugin])
+                export plugin_$plugin=$plugin
                 ;;
         esac
-        done
-        AC_MSG_RESULT($plugins)
-    fi
+    done
+    AC_MSG_RESULT($plugins)
 fi
 
 dnl FIXME: OSS/ALSA checking
@@ -249,8 +285,15 @@ else
     dnl force OSS plugin to <null>
     plugin_volume=
 fi
+
+dnl Exclude indicator support when there is no support.
+if test x"$indicator_support" = "xno"; then
+    plugin_indicator=
+fi
+
 PLUGINS_LIST="\
     $plugin_netstatus \
+    $plugin_netstat \
     $plugin_volume \
     $plugin_volumealsa \
     $plugin_cpu \
@@ -259,10 +302,26 @@ PLUGINS_LIST="\
     $plugin_kbled \
     $plugin_xkb \
     $plugin_thermal \
-    $plugin_cpufreq"
+    $plugin_cpufreq \
+    $plugin_monitors \
+    $plugin_indicator \
+    $plugin_weather"
 
 AC_SUBST(PLUGINS_LIST)
 
+# Plugin-specific dependencies
+# nestat
+if test x"$plugin_netstat" != "x";then
+AC_CHECK_HEADER([iwlib.h],,
+ AC_MSG_ERROR([netstat plugin requires wireless-tools-devel]))
+fi
+
+# weather
+if test x"$plugin_weather" != "x";then
+PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
+AC_SUBST(LIBXML2_CFLAGS)
+AC_SUBST(LIBXML2_LIBS)
+fi
 
 # Checks for header files.
 AC_PATH_X
@@ -283,14 +342,29 @@ AC_FUNC_STAT
 AC_FUNC_STRFTIME
 AC_CHECK_FUNCS([bzero memset mkdir setlocale strchr])
 
+dnl check for menu-cache versions 0.4.x since no macro MENU_CACHE_CHECK_VERSION
+dnl is available in those versions
+LIBS_save="${LIBS}"
+LIBS="${LIBS} ${MENU_CACHE_LIBS}"
+AC_CHECK_FUNCS(menu_cache_dir_list_children)
+LIBS="${LIBS_save}"
+
+# Generate po/LINGUAS on the fly rather than relying on translators
+# to maintain it manually. This also overcome the problem that Transifex
+# cannot add a language to po/LINGUAS if a new po file is submitted.
+rm -f $srcdir/po/LINGUAS
+for po_file in `ls $srcdir/po/*.po | sort`;
+do
+    lang=`echo "$po_file" | sed "s|.*/po/\(.*\)\.po|\1|g"`
+    echo $lang >> $srcdir/po/LINGUAS
+done
 
 GETTEXT_PACKAGE=lxpanel
-#AM_GNU_GETTEXT([external])
+AM_GNU_GETTEXT([external])
 AM_GNU_GETTEXT_VERSION(0.14.1)
 AC_SUBST(GETTEXT_PACKAGE)
 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
 
-ALL_LINGUAS="af ar cs da de es et eu fa fi fr gl hu hr id it ja ko lt ml ms nb nl nn pl ps pt pt_BR ru sk sl sv tr uk ur ur_PK vi zh_CN zh_TW"
 AM_GLIB_GNU_GETTEXT
 
 if test x"$enable_man" = x"yes"; then
@@ -308,24 +382,59 @@ fi
 
 AM_CONDITIONAL(ENABLE_REGENERATE_MAN, test "x$enable_man" != "xno")
 
+AC_ARG_ENABLE(debug,
+    [AC_HELP_STRING([--enable-debug],
+        [enable debug support @<:@default=no@:>@])],
+    [enable_debug="${enableval}"],
+    [enable_debug=no]
+)
+if test "$enable_debug" = "yes"; then
+    # turn on debug and disable optimization
+    CPPFLAGS="$CPPFLAGS -DG_ENABLE_DEBUG -O0 -g"
+    case "$CC" in
+    gcc*)
+        CPPFLAGS="$CPPFLAGS -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration"
+        ;;
+    *)
+        ;;
+    esac
+    dnl Be more strict on portability
+    #CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=700"
+else
+    # turn off glib debug checks
+    CPPFLAGS="$CPPFLAGS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
+fi
+
+dnl Fix invalid sysconfdir when --prefix=/usr
+if test `eval "echo $sysconfdir"` = /usr/etc
+then
+    sysconfdir=/etc
+fi
+
 AC_CONFIG_FILES([
     lxpanel.pc
     Makefile
     src/Makefile
-    src/plugins/Makefile
-    src/plugins/netstatus/Makefile
-    src/plugins/volume/Makefile
-    src/plugins/volumealsa/Makefile
-    src/plugins/cpu/Makefile
-    src/plugins/deskno/Makefile
-    src/plugins/batt/Makefile
-    src/plugins/kbled/Makefile
-    src/plugins/xkb/Makefile
-    src/plugins/thermal/Makefile
-    src/plugins/cpufreq/Makefile
+    plugins/Makefile
+    plugins/netstatus/Makefile
+    plugins/netstat/Makefile
+    plugins/volume/Makefile
+    plugins/volumealsa/Makefile
+    plugins/cpu/Makefile
+    plugins/deskno/Makefile
+    plugins/batt/Makefile
+    plugins/kbled/Makefile
+    plugins/xkb/Makefile
+    plugins/thermal/Makefile
+    plugins/cpufreq/Makefile
+    plugins/monitors/Makefile
+    plugins/indicator/Makefile
+    plugins/weather/Makefile
     po/Makefile.in
     data/Makefile
     data/default/panels/panel
+    data/two_panels/panels/top
+    data/two_panels/panels/bottom
     man/Makefile
 ])
 AC_OUTPUT
@@ -334,11 +443,17 @@ echo
 echo lxpanel ......................... : Version $VERSION
 echo
 echo Prefix........................... : $prefix
+echo System config directory.......... : `eval "echo $sysconfdir"`
+echo
+
 if test x$plugins_loading = xyes; then
 echo Building dynamic plugins:
     if test x"$plugin_netstatus" != x; then
         AC_MSG_RESULT([    netstatus - Monitor networking status])
     fi
+    if test x"$plugin_netstat" != x; then
+        AC_MSG_RESULT([    netstat - Monitor networking status])
+    fi
     if test x"$plugin_volume" != x; then
         AC_MSG_RESULT([    volume - Display and adjust volume of sound card for OSS])
     fi
@@ -358,7 +473,7 @@ echo Building dynamic plugins:
         AC_MSG_RESULT([    kbled - Indicator for CapsLock, NumLock, and ScrLock])
     fi
     if test x"$plugin_xkb" != x; then
-        AC_MSG_RESULT([    xkb - Keyboard layout switcher])
+        AC_MSG_RESULT([    xkb - Keyboard layout handler])
     fi
     if test x"$plugin_thermal" != x; then
         AC_MSG_RESULT([    thermal - Temperature monitor])
@@ -366,10 +481,25 @@ echo Building dynamic plugins:
     if test x"$plugin_cpufreq" != x; then
         AC_MSG_RESULT([    cpufreq - CpuFreq frontend])
     fi
+    if test x"$plugin_monitors" != x; then
+        AC_MSG_RESULT([    monitors - Monitors for CPU & RAM])
+    fi
+    if test x"$plugin_indicator" != x; then
+        AC_MSG_RESULT([    indicator - Indicator support])
+    fi
+    if test x"$plugin_weather" != x; then
+        AC_MSG_RESULT([    weather - Weather conditions and forecast])
+    fi
 else
 echo Dynamic loader for plugins....... : disabled.
 fi
 
+if test x"$sysconfdir" != x'/etc'; then
+    echo
+    echo 'Warning: sysconfdir is not /etc. It might be not what you want.'
+    echo 'Please consider passing --sysconfdir=/etc to configure.'
+fi
+
 echo
 echo 'LXPanel requires menu-cache and lxmenu-data packages since'
 echo 'version 0.4.0. Please make sure they are correctly installed.'