HAL mini-patch

Martin Waitz tali at admingilde.org
Mon Dec 22 03:55:46 EET 2003


hi :)

here is my next set of changes.
it survives a make distcheck and debian packaging, but hasn't
been extensively tested yet.


the gstreamer guys have a nice m4 macro to determine
expanded variable names:
(downloaded from
http://cvs.sourceforge.net/viewcvs.py/*checkout*/autostars/autostars/ac-expand/as-ac-expand.m4,
modified to use $ac_default_prefix)

Index: acinclude.m4
===================================================================
RCS file: /cvs/hal/hal/acinclude.m4,v
retrieving revision 1.1
diff -u -p -r1.1 acinclude.m4
--- acinclude.m4	5 Nov 2003 23:22:50 -0000	1.1
+++ acinclude.m4	22 Dec 2003 01:33:05 -0000
@@ -1,2 +1,43 @@
+dnl as-ac-expand.m4 0.1.0
+dnl autostars m4 macro for expanding directories using configure's prefix
+dnl thomas at apestaart.org
 
-# Empty file
+dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
+dnl example
+dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
+dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
+
+AC_DEFUN(AS_AC_EXPAND,
+[
+  EXP_VAR=[$1]
+  FROM_VAR=[$2]
+
+  dnl first expand prefix and exec_prefix if necessary
+  prefix_save=$prefix
+  exec_prefix_save=$exec_prefix
+
+  dnl if no prefix given, then use /usr/local, the default prefix
+  if test "x$prefix" = "xNONE"; then
+    prefix=$ac_default_prefix
+  fi
+  dnl if no exec_prefix given, then use prefix
+  if test "x$exec_prefix" = "xNONE"; then
+    exec_prefix=$prefix
+  fi
+
+  full_var="$FROM_VAR"
+  dnl loop until it doesn't change anymore
+  while true; do
+    new_full_var="`eval echo $full_var`"
+    if test "x$new_full_var"="x$full_var"; then break; fi
+    full_var=$new_full_var
+  done
+
+  dnl clean up
+  full_var=$new_full_var
+  AC_SUBST([$1], "$full_var")
+
+  dnl restore prefix and exec_prefix
+  prefix=$prefix_save
+  exec_prefix=$exec_prefix_save
+])


simplify configure.in by using above macro
define $(LN_S) for installing hotplug script
and create Const.py by configure

Index: configure.in
===================================================================
RCS file: /cvs/hal/hal/configure.in,v
retrieving revision 1.6
diff -u -p -r1.6 configure.in
--- configure.in	20 Dec 2003 11:12:41 -0000	1.6
+++ configure.in	22 Dec 2003 01:33:05 -0000
@@ -13,6 +13,7 @@ AM_PROG_CC_STDC
 AC_HEADER_STDC
 AM_PROG_LIBTOOL
 AC_PROG_MAKE_SET
+AC_PROG_LN_S
 AM_PATH_PYTHON
 
 AC_ARG_WITH(hwdata,[  --with-hwdata=<dir>     where PCI and USB IDs are found (auto)])
@@ -39,14 +40,6 @@ if test x$enable_verbose_mode = xyes; th
     AC_DEFINE(ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
 fi
 
-BUILD_DIR=`pwd`
-AC_SUBST(BUILD_DIR)
-#if test x$USE_MAINTAINER_MODE = xyes; then
-#    AC_DEFINE(USE_MAINTAINER_MODE, 1 , [Building in maintainer mode])
-#    AC_DEFINE_UNQUOTED(BUILD_DIR, "$BUILD_DIR", [Path to source of project])
-#fi
-AM_CONDITIONAL(USE_MAINTAINER_MODE, test x$USE_MAINTAINER_MODE = xyes)
-AC_DEFINE_UNQUOTED(BUILD_DIR, "$BUILD_DIR", [Path to source of build dir])
 
 #### gcc warning flags
 
@@ -183,51 +176,11 @@ AC_MSG_RESULT(yes)
 
 
 
-#### Have to go $localstatedir->$prefix/var->/usr/local/var   
-#### someone please fix this a better way...
-
-#### find the actual value for $prefix that we'll end up with
-##   (I know this is broken and should be done in the Makefile, but
-##    that's a major pain and almost nobody actually seems to care)
-REAL_PREFIX=
-if test "x$prefix" = "xNONE"; then
-  REAL_PREFIX=$ac_default_prefix
-else
-  REAL_PREFIX=$prefix
-fi
-
-## temporarily change prefix and exec_prefix
-old_prefix=$prefix
-prefix=$REAL_PREFIX
-
-if test "x$exec_prefix" = xNONE ; then
-   REAL_EXEC_PREFIX=$REAL_PREFIX
-else
-   REAL_EXEC_PREFIX=$exec_prefix
-fi
-old_exec_prefix=$exec_prefix
-exec_prefix=$REAL_EXEC_PREFIX
-
-## eval everything
-LOCALSTATEDIR_TMP="$localstatedir"
-EXPANDED_LOCALSTATEDIR=`eval echo $LOCALSTATEDIR_TMP`
-AC_SUBST(EXPANDED_LOCALSTATEDIR)
-
-SYSCONFDIR_TMP="$sysconfdir"
-EXPANDED_SYSCONFDIR=`eval echo $SYSCONFDIR_TMP`
-AC_SUBST(EXPANDED_SYSCONFDIR)
-
-DATADIR_TMP="$datadir"
-EXPANDED_DATADIR=`eval echo $DATADIR_TMP`
-AC_SUBST(EXPANDED_DATADIR)
-
-BINDIR_TMP="$bindir"
-EXPANDED_BINDIR=`eval echo $BINDIR_TMP`
-AC_SUBST(EXPANDED_BINDIR)
-
-LIBDIR_TMP="$libdir"
-EXPANDED_LIBDIR=`eval echo $LIBDIR_TMP`
-AC_SUBST(EXPANDED_LIBDIR)
+AS_AC_EXPAND(LOCALSTATEDIR, $localstatedir)
+AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
+AS_AC_EXPAND(DATADIR, $datadir)
+AS_AC_EXPAND(BINDIR, $bindir)
+AS_AC_EXPAND(LIBDIR, $libdir)
 
 
 AC_ARG_WITH(dbus-sys, [  --with-dbus-sys=<dir>   where D-BUS system.d directory is])
@@ -235,7 +188,7 @@ AC_ARG_WITH(dbus-sys, [  --with-dbus-sys
 if ! test -z "$with_dbus_sys" ; then
     DBUS_SYS_DIR="$with_dbus_sys"
 else
-    DBUS_SYS_DIR="$EXPANDED_SYSCONFDIR/dbus-1/system.d"
+    DBUS_SYS_DIR="$SYSCONFDIR/dbus-1/system.d"
 fi
 AC_SUBST(DBUS_SYS_DIR)
 AC_DEFINE_UNQUOTED(DBUS_SYSTEMD_DIR, "$DBUS_SYS_DIR", [Where system.d dir for DBUS is])
@@ -246,7 +199,7 @@ AC_ARG_WITH(hotplug-dir, [  --with-hotpl
 if ! test -z "$with_hotplug" ; then
     LINUX_HOTPLUG_DIR="$with_hotplug"
 else
-#    LINUX_HOTPLUG_DIR="$EXPANDED_SYSCONFDIR/hotplug.d"
+#    LINUX_HOTPLUG_DIR="$SYSCONFDIR/hotplug.d"
 # It's quite uncommon to have hotplug.d other places than this, so default
 # to it
     LINUX_HOTPLUG_DIR=/etc/hotplug.d
@@ -255,9 +208,13 @@ AC_SUBST(LINUX_HOTPLUG_DIR)
 AC_DEFINE_UNQUOTED(LINUX_HOTPLUG_DIR, "$LINUX_HOTPLUG_DIR", [where hotplug.d directory is])
 
 
-## put prefix and exec_prefix back
-prefix=$old_prefix
-exec_prefix=$old_exec_prefix
+if test x$USE_MAINTAINER_MODE = xyes; then
+    DEVICEMANAGER_DIR=$(cd $top_srcdir; pwd)/tools/device-manager
+else
+    DEVICEMANAGER_DIR=$DATADIR/$PACKAGE/device-manager
+fi
+AC_SUBST(DEVICEMANAGER_DIR)
+
 
 AC_OUTPUT([
 hal.pc
@@ -268,6 +225,7 @@ libhal/Makefile
 tools/Makefile
 tools/linux/Makefile
 tools/device-manager/Makefile
+tools/device-manager/Const.py
 ])
 
 dnl ==========================================================================
@@ -277,11 +235,11 @@ echo "
 
         prefix:                   ${prefix}
         exec_prefix:              ${REAL_EXEC_PREFIX}
-        libdir:                   ${EXPANDED_LIBDIR}
-        bindir:                   ${EXPANDED_BINDIR}
-        datadir:                  ${EXPANDED_DATADIR}
-        sysconfdir:               ${EXPANDED_SYSCONFDIR}
-        localstatedir:            ${EXPANDED_LOCALSTATEDIR}
+        libdir:                   ${LIBDIR}
+        bindir:                   ${BINDIR}
+        datadir:                  ${DATADIR}
+        sysconfdir:               ${SYSCONFDIR}
+        localstatedir:            ${LOCALSTATEDIR}
         dbus-1 system.d dir:      ${DBUS_SYS_DIR}
         pci.ids, usb.ids dir:     ${HWDATA_DIR}
         linux hotplug.d dir:      ${LINUX_HOTPLUG_DIR}
@@ -302,7 +260,7 @@ if test x$enable_verbose_mode = xyes; th
 fi
 
 dnl if test x${USE_MAINTAINER_MODE} = xyes; then
-dnl    echo "NOTE: device info files will be read from the device_info_files directory in the source distribution rather than from ${EXPANDED_LOCALSTATEDIR}/hal/fdi"
+dnl    echo "NOTE: device info files will be read from the device_info_files directory in the source distribution rather than from ${LOCALSTATEDIR}/hal/fdi"
 dnl   echo
 dnl fi
 


add top_srcdir to include path, needed for make distcheck

Index: hald/Makefile.am
===================================================================
RCS file: /cvs/hal/hal/hald/Makefile.am,v
retrieving revision 1.4
diff -u -p -r1.4 Makefile.am
--- hald/Makefile.am	20 Dec 2003 11:12:41 -0000	1.4
+++ hald/Makefile.am	22 Dec 2003 01:33:05 -0000
@@ -4,6 +4,7 @@ INCLUDES = \
 	-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
 	-DPACKAGE_BIN_DIR=\""$(bindir)"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+	-I$(top_srcdir) \
 	@PACKAGE_CFLAGS@
 
 sbin_PROGRAMS = hald


again add top_srcdir to include path, needed for make distcheck
and use direct path to library
otherwise we could use an old version installed in /usr/lib

Index: tools/Makefile.am
===================================================================
RCS file: /cvs/hal/hal/tools/Makefile.am,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile.am
--- tools/Makefile.am	21 Dec 2003 02:08:00 -0000	1.3
+++ tools/Makefile.am	22 Dec 2003 01:33:05 -0000
@@ -6,20 +6,20 @@ INCLUDES = \
 	-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
 	-DPACKAGE_BIN_DIR=\""$(bindir)"\" \
 	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-    -I$(top_builddir) \
+	-I$(top_srcdir) \
 	@PACKAGE_CFLAGS@
 
 bin_PROGRAMS = lshal hal_get_property hal_set_property
 
 lshal_SOURCES = lshal.c
 lshal_LDADD = -ldbus-1 -ldbus-glib-1 -lglib-2.0 \
-              -L$(top_builddir)/libhal -lhal
+              $(top_builddir)/libhal/libhal.la
 
 hal_get_property_SOURCES = hal_get_property.c
-hal_get_property_LDADD = -ldbus-1 -L$(top_builddir)/libhal -lhal
+hal_get_property_LDADD = -ldbus-1 $(top_builddir)/libhal/libhal.la
 
 hal_set_property_SOURCES = hal_set_property.c
-hal_set_property_LDADD = -ldbus-1 -L$(top_builddir)/libhal -lhal
+hal_set_property_LDADD = -ldbus-1 $(top_builddir)/libhal/libhal.la
 
 clean-local :
 	rm -f *~


use autoconf variables

Index: tools/device-manager/Const.py.in
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/Const.py.in,v
retrieving revision 1.1
diff -u -p -r1.1 Const.py.in
--- tools/device-manager/Const.py.in	20 Dec 2003 11:16:46 -0000	1.1
+++ tools/device-manager/Const.py.in	22 Dec 2003 01:33:05 -0000
@@ -2,7 +2,7 @@
 
 NAME = "hal-device-manager"
 NAME_LONG = "HAL Device Manager"
-VERSION = "VERSION_IN"
+VERSION = "@VERSION@"
 COPYRIGHT = "Copyright (C) 2003 David Zeuthen."
 INFO = "This application shows information about\nhardware on your system"""
 AUTHORS = [
@@ -10,7 +10,7 @@ AUTHORS = [
     "Shannon -jj Behrens <jjinux at yahoo.com> (for simplepy)"
 ]
 
-DATADIR = "DATADIR_IN"
+DATADIR = "@DEVICEMANAGER_DIR@"
 
 PIXBUF_COLUMN = 0
 TITLE_COLUMN  = 1


simplify Makefile.am by removing manual variable replacement
and by using dist_ and nodist_ prefixes
use $(LN_S) to link (and don't point link to $(DESTDIR))

Index: tools/device-manager/Makefile.am
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/Makefile.am,v
retrieving revision 1.1
diff -u -p -r1.1 Makefile.am
--- tools/device-manager/Makefile.am	20 Dec 2003 11:12:41 -0000	1.1
+++ tools/device-manager/Makefile.am	22 Dec 2003 01:33:05 -0000
@@ -1,28 +1,19 @@
 
-if USE_MAINTAINER_MODE
-    DATADIR = $(BUILD_DIR)/tools/device-manager
-else
-    DATADIR = $(datadir)/hal/device-manager
-endif
+devicemanagerdir = $(pkgdatadir)/device-manager
 
-all : Const.py
 
-Const.py : Const.py.in
-	sed -e 's#DATADIR_IN#$(DATADIR)#; s/VERSION_IN/@PACKAGE_VERSION@/' Const.py.in > Const.py
-
-devicemanagerdir = $(datadir)/hal/device-manager
-
-devicemanager_SCRIPTS = hal-device-manager
+dist_devicemanager_SCRIPTS = hal-device-manager
 
+nodist_devicemanager_PYTHON =                      \
+                       Const.py
 devicemanager_PYTHON =                             \
-                       Const.py                    \
                        DeviceManager.py            \
                        Device.py                   \
                        GtkAttributesFacade.py      \
                        LibGladeApplication.py      \
                        Representation.py
 
-devicemanager_DATA =                                               \
+dist_devicemanager_DATA =                                          \
                        fdo-logo.png          hal-cat-mouse.png     \
                        hal-abstract.png      hal-cdrom.png         \
                        hal-audio.png         hal-flash.png         \
@@ -33,14 +24,11 @@ devicemanager_DATA =                    
                        hal-cat-keyboard.png  hal-video.png         \
                        hal-device-manager.glade
 
-EXTRA_DIST = $(devicemanager_DATA) $(devicemanager_SCRIPTS) Const.py.in
-
-dist-hook : 
-	- rm -f $(distdir)/Const.py
 
+# symlink for hotplug integration
 install-data-local :
 	$(mkinstalldirs) $(DESTDIR)$(bindir)
-	- /bin/ln -s $(DESTDIR)$(datadir)/hal/device-manager/hal-device-manager $(DESTDIR)$(bindir)
+	- cd $(DESTDIR)$(bindir) && $(LN_S) $(pkgdatadir)/device-manager/hal-device-manager hal-device-manager
 
 uninstall-local :
 	- rm -f $(DESTDIR)$(bindir)/hal-device-manager


again fix symlinking

Index: tools/linux/Makefile.am
===================================================================
RCS file: /cvs/hal/hal/tools/linux/Makefile.am,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile.am
--- tools/linux/Makefile.am	21 Dec 2003 02:08:00 -0000	1.3
+++ tools/linux/Makefile.am	22 Dec 2003 01:48:43 -0000
@@ -19,7 +19,7 @@ clean-local :
 
 install-data-local :
 	$(mkinstalldirs) $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default
-	- /bin/ln -sf $(DESTDIR)$(libexecdir)/hal.hotplug $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default
+	- cd $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default && $(LN_S) $(libexecdir)/hal.hotplug hal.hotplug
 
 uninstall-local :
 	- rm -f $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default/hal.hotplug


so, ok that's it for now...
i'll test this a bit tomorrow, it's late already

-- 
CU,		  / Friedrich-Alexander University Erlangen, Germany
Martin Waitz	//  Department of Computer Science 3       _________
______________/// - - - - - - - - - - - - - - - - - - - - ///
dies ist eine manuell generierte mail, sie beinhaltet    //
tippfehler und ist auch ohne grossbuchstaben gueltig.   /
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/xdg/attachments/20031222/db1cedb7/attachment.pgp 


More information about the xdg mailing list