hal: Branch 'origin'

Richard Hughes hughsient at kemper.freedesktop.org
Sat Dec 16 04:47:11 PST 2006


 configure.in                  |   26 ++++++++++++++++++++++++++
 hald/linux/Makefile.am        |   34 ++++++++++++++++++++++++++--------
 hald/linux/acpi.h             |   14 +++++++++-----
 hald/linux/addons/Makefile.am |    8 ++++++--
 hald/linux/apm.h              |   14 +++++++++-----
 hald/linux/pmu.h              |   14 +++++++++-----
 6 files changed, 85 insertions(+), 25 deletions(-)

New commits:
diff-tree ec2f246285353aad75115282354b979b1f1e48b3 (from e543d270ef4113a7d6a1cb51b56391b2794658d9)
Author: Richard Hughes <richard at hughsie.com>
Date:   Sat Dec 16 12:03:49 2006 +0000

    make the acpi, apm and pmu backends inclusion configurable
    
    Removes the requirement to compile into hald the apm, acpi or pmu
    hotplug backends.
    Machines like OLPC and 770 should really use a slim, lightweight hal
    with as little unused code as possible.
    
    Adding these #ifdef's does the following on my test-B OLPC machine:
     - hald size 236k stripped (default)
     - hald size 210k stripped (--disable-acpi --disable-pmu --disable-apm)
    
    On my i386 laptop, I get:
     - hald size 240k stripped (default)
     - hald size 232k stripped (--disable-pmu --disable-apm)
    
    Adding ugly ifdef's is never a thing I like doing to source-code, but
    for a trivial 12% space saving on embedded devices I think it's
    worthwhile.

diff --git a/configure.in b/configure.in
index 8a5e786..9f5945b 100644
--- a/configure.in
+++ b/configure.in
@@ -301,6 +301,29 @@ if test "x$enable_policy_kit" != "xno"; 
 	fi
 fi
 
+# what extra hotplug backends to use (ACPI, APM, PMU etc)
+AC_ARG_ENABLE(have_acpi, [  --disable-acpi          Build without ACPI support])
+msg_acpi=no
+if test "x$enable_acpi" != "xno"; then
+	msg_acpi=yes
+  	AC_DEFINE(HAVE_ACPI, [], [Set if we have ACPI support])
+fi
+AM_CONDITIONAL(HAVE_ACPI, test x$msg_acpi = xyes, [Compiling ACPI])
+AC_ARG_ENABLE(have_apm, [  --disable-apm           Build without APM support])
+msg_apm=no
+if test "x$enable_apm" != "xno"; then
+	msg_apm=yes
+  	AC_DEFINE(HAVE_APM, [], [Set if we have APM support])
+fi
+AM_CONDITIONAL(HAVE_APM, test x$msg_apm = xyes, [Compiling APM])
+AC_ARG_ENABLE(have_pmu, [  --disable-pmu           Build without PMU support])
+msg_pmu=no
+if test "x$enable_pmu" != "xno"; then
+	msg_pmu=yes
+  	AC_DEFINE(HAVE_PMU, [], [Set if we have PMU support])
+fi
+AM_CONDITIONAL(HAVE_PMU, test x$msg_pmu = xyes, [Compiling PMU])
+
 # D-Bus libs
 PKG_CHECK_MODULES(DBUS, [$dbus_module])
 AC_SUBST(DBUS_CFLAGS)
@@ -633,6 +656,9 @@ echo "
         use libpci:                 ${USE_LIBPCI}
         use libparted:              ${USE_PARTED}
         use PolicyKit:              ${msg_polkit}
+        use ACPI:                   ${msg_acpi}
+        use PMU:                    ${msg_pmu}
+        use APM:                    ${msg_apm}
 
         Macbook Pro utils:          ${BUILD_MACBOOKPRO} (Linux only, x86 only, requires libpci)
         CPU frequency scaling:      ${BUILD_CPUFREQ} (Linux only)
diff --git a/hald/linux/Makefile.am b/hald/linux/Makefile.am
index b882d1a..315cd91 100644
--- a/hald/linux/Makefile.am
+++ b/hald/linux/Makefile.am
@@ -15,14 +15,32 @@ noinst_LTLIBRARIES = libhald_linux.la
 endif
 
 libhald_linux_la_SOURCES =					\
-				osspec.c			\
+	acpi.h							\
+	apm.h							\
+	pmu.h							\
+	osspec.c						\
 	osspec_linux.h						\
-	hotplug.h		hotplug.c			\
+	hotplug.h						\
+	hotplug.c						\
 	hotplug_helper.h					\
-	coldplug.h		coldplug.c			\
-	device.h		device.c			\
-	blockdev.h		blockdev.c			\
-	acpi.h			acpi.c				\
-	apm.h			apm.c				\
-	pmu.h			pmu.c
+	coldplug.h						\
+	coldplug.c						\
+	device.h						\
+	device.c						\
+	blockdev.h						\
+	blockdev.c
 
+if HAVE_ACPI
+libhald_linux_la_SOURCES +=					\
+	acpi.c
+endif
+
+if HAVE_APM
+libhald_linux_la_SOURCES +=					\
+	apm.c
+endif
+
+if HAVE_PMU
+libhald_linux_la_SOURCES +=					\
+	pmu.c
+endif
diff --git a/hald/linux/acpi.h b/hald/linux/acpi.h
index f7ed07a..be02c70 100644
--- a/hald/linux/acpi.h
+++ b/hald/linux/acpi.h
@@ -26,16 +26,20 @@
 #include "../hald.h"
 #include "hotplug.h"
 
+#ifdef HAVE_ACPI
 gboolean acpi_synthesize_hotplug_events (void);
-
 void hotplug_event_begin_add_acpi (const gchar *acpi_path, int acpi_type, HalDevice *parent, void *end_token);
-
 void hotplug_event_begin_remove_acpi (const gchar *acpi_path, int acpi_type, void *end_token);
-
 gboolean acpi_rescan_device (HalDevice *d);
-
 HotplugEvent *acpi_generate_add_hotplug_event (HalDevice *d);
-
 HotplugEvent *acpi_generate_remove_hotplug_event (HalDevice *d);
+#else /* HAVE_ACPI */
+static inline gboolean acpi_synthesize_hotplug_events (void) {return FALSE;}
+static inline void hotplug_event_begin_add_acpi (const gchar *acpi_path, int acpi_type, HalDevice *parent, void *end_token) {return;}
+static inline void hotplug_event_begin_remove_acpi (const gchar *acpi_path, int acpi_type, void *end_token) {return;}
+static inline gboolean acpi_rescan_device (HalDevice *d) {return FALSE;}
+static inline HotplugEvent *acpi_generate_add_hotplug_event (HalDevice *d) {return NULL;}
+static inline HotplugEvent *acpi_generate_remove_hotplug_event (HalDevice *d) {return NULL;}
+#endif /* HAVE_ACPI */
 
 #endif /* ACPI_H */
diff --git a/hald/linux/addons/Makefile.am b/hald/linux/addons/Makefile.am
index 943fafb..87bc0de 100644
--- a/hald/linux/addons/Makefile.am
+++ b/hald/linux/addons/Makefile.am
@@ -10,13 +10,17 @@ INCLUDES = \
 
 if HALD_COMPILE_LINUX
 libexec_PROGRAMS  = 			\
-	hald-addon-acpi 		\
-	hald-addon-acpi-buttons-toshiba \
 	hald-addon-hid-ups 		\
 	hald-addon-keyboard 		\
 	hald-addon-pmu			\
 	hald-addon-storage
 
+if HAVE_ACPI
+libexec_PROGRAMS  += 			\
+	hald-addon-acpi 		\
+	hald-addon-acpi-buttons-toshiba
+endif
+
 if BUILD_MACBOOKPRO
 libexec_PROGRAMS += hald-addon-macbookpro-backlight
 hald_addon_macbookpro_backlight_SOURCES = addon-macbookpro-backlight.c ../../logger.c
diff --git a/hald/linux/apm.h b/hald/linux/apm.h
index 80d0de6..b979ed0 100644
--- a/hald/linux/apm.h
+++ b/hald/linux/apm.h
@@ -26,16 +26,20 @@
 #include "../hald.h"
 #include "hotplug.h"
 
+#ifdef HAVE_APM
 gboolean apm_synthesize_hotplug_events (void);
-
 void hotplug_event_begin_add_apm (const gchar *apm_path, int apm_type, HalDevice *parent, void *end_token);
-
 void hotplug_event_begin_remove_apm (const gchar *apm_path, int apm_type, void *end_token);
-
 gboolean apm_rescan_device (HalDevice *d);
-
 HotplugEvent *apm_generate_add_hotplug_event (HalDevice *d);
-
 HotplugEvent *apm_generate_remove_hotplug_event (HalDevice *d);
+#else /* HAVE_APM */
+static inline gboolean apm_synthesize_hotplug_events (void) {return FALSE;}
+static inline void hotplug_event_begin_add_apm (const gchar *apm_path, int apm_type, HalDevice *parent, void *end_token) {return;}
+static inline void hotplug_event_begin_remove_apm (const gchar *apm_path, int apm_type, void *end_token) {return;}
+static inline gboolean apm_rescan_device (HalDevice *d) {return FALSE;}
+static inline HotplugEvent *apm_generate_add_hotplug_event (HalDevice *d) {return NULL;}
+static inline HotplugEvent *apm_generate_remove_hotplug_event (HalDevice *d) {return NULL;}
+#endif /* HAVE_APM */
 
 #endif /* APM_H */
diff --git a/hald/linux/pmu.h b/hald/linux/pmu.h
index c8304b3..9773ef0 100644
--- a/hald/linux/pmu.h
+++ b/hald/linux/pmu.h
@@ -25,16 +25,20 @@
 #include "../hald.h"
 #include "hotplug.h"
 
+#ifdef HAVE_PMU
 gboolean pmu_synthesize_hotplug_events (void);
-
 void hotplug_event_begin_add_pmu (const gchar *pmu_path, int pmu_type, HalDevice *parent, void *end_token);
-
 void hotplug_event_begin_remove_pmu (const gchar *pmu_path, int pmu_type, void *end_token);
-
 gboolean pmu_rescan_device (HalDevice *d);
-
 HotplugEvent *pmu_generate_add_hotplug_event (HalDevice *d);
-
 HotplugEvent *pmu_generate_remove_hotplug_event (HalDevice *d);
+#else /* HAVE_PMU */
+static inline gboolean pmu_synthesize_hotplug_events (void) {return FALSE;}
+static inline void hotplug_event_begin_add_pmu (const gchar *pmu_path, int pmu_type, HalDevice *parent, void *end_token) {return;}
+static inline void hotplug_event_begin_remove_pmu (const gchar *pmu_path, int pmu_type, void *end_token) {return;}
+static inline gboolean pmu_rescan_device (HalDevice *d) {return FALSE;}
+static inline HotplugEvent *pmu_generate_add_hotplug_event (HalDevice *d) {return NULL;}
+static inline HotplugEvent *pmu_generate_remove_hotplug_event (HalDevice *d) {return NULL;}
+#endif /* HAVE_PMU */
 
 #endif /* PMU_H */


More information about the hal-commit mailing list