From a116313d5425b8b72729e881bf71a07876b8db86 Mon Sep 17 00:00:00 2001 From: "Mark M. Hoffman" Date: Sun, 18 Sep 2005 20:39:53 +0000 Subject: [PATCH] (mmh) This patch makes optional the sysfs support in libsensors. The default is to *disable* sysfs support if a 2.4.x kernel is detected, for all other versions, support will be enabled. This can be overridden in the top-level Makefile. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@3096 7894878c-1315-0410-8ee3-d5d059ff63e0 --- Makefile | 19 +++++++++++++++++++ lib/Module.mk | 11 ++++++++++- lib/sysfs.h | 10 ++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bf2235f0..a01243c9 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,19 @@ CC := gcc # /lib/modules/2.4.29 MODPREF := /lib/modules/$(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release |cut -f 2 -d'"') +# When building userspace for use with 2.4.x series kernels, we turn off +# sysfs support by default. You can override this (e.g. if you want +# to build binaries that work for both 2.4.x, and 2.6.x and above) +# by uncommenting the line after the next endif. Keep in mind, if and only +# if you do this: you will need to install the libsysfs libraries on your +# kernel 2.4.x systems also. +ifeq (,$(findstring /2.4., $(MODPREF))) + SYSFS_SUPPORT := 1 +else + SYSFS_SUPPORT := +endif +#SYSFS_SUPPORT := 1 + # Prevent 2.6+ users from using improper targets, as this won't work. ifeq (,$(findstring /2.4., $(MODPREF))) ifeq (, $(MAKECMDGOALS)) @@ -257,8 +270,14 @@ MODCFLAGS += $(ALL_CFLAGS) PROGCPPFLAGS := -DETCDIR="\"$(ETCDIR)\"" $(ALL_CPPFLAGS) -Wundef PROGCFLAGS := $(ALL_CFLAGS) ARCPPFLAGS := $(ALL_CPPFLAGS) +ifdef SYSFS_SUPPORT +ARCPPFLAGS := $(ARCPPFLAGS) -DSYSFS_SUPPORT +endif ARCFLAGS := $(ALL_CFLAGS) LIBCPPFLAGS := $(ALL_CPPFLAGS) +ifdef SYSFS_SUPPORT +LIBCPPFLAGS := $(LIBCPPFLAGS) -DSYSFS_SUPPORT +endif LIBCFLAGS := -fpic $(ALL_CFLAGS) .PHONY: all clean install version package dep diff --git a/lib/Module.mk b/lib/Module.mk index a8500292..9a507aa0 100644 --- a/lib/Module.mk +++ b/lib/Module.mk @@ -49,7 +49,11 @@ LIBTARGETS := $(MODULE_DIR)/$(LIBSTLIBNAME) $(MODULE_DIR)/$(LIBSHLIBNAME) \ LIBCSOURCES := $(MODULE_DIR)/data.c $(MODULE_DIR)/general.c \ $(MODULE_DIR)/error.c $(MODULE_DIR)/chips.c \ $(MODULE_DIR)/proc.c $(MODULE_DIR)/access.c \ - $(MODULE_DIR)/init.c $(MODULE_DIR)/sysfs.c + $(MODULE_DIR)/init.c +ifdef SYSFS_SUPPORT + LIBCSOURCES := $(LIBCSOURCES) $(MODULE_DIR)/sysfs.c +endif + LIBOTHEROBJECTS := $(MODULE_DIR)/conf-parse.o $(MODULE_DIR)/conf-lex.o LIBSHOBJECTS := $(LIBCSOURCES:.c=.lo) $(LIBOTHEROBJECTS:.o=.lo) LIBSTOBJECTS := $(LIBCSOURCES:.c=.ao) $(LIBOTHEROBJECTS:.o=.ao) @@ -60,8 +64,13 @@ LIBHEADERFILES := $(MODULE_DIR)/error.h $(MODULE_DIR)/sensors.h \ $(MODULE_DIR)/chips.h # How to create the shared library +ifdef SYSFS_SUPPORT $(MODULE_DIR)/$(LIBSHLIBNAME): $(LIBSHOBJECTS) $(CC) -shared -Wl,-soname,$(LIBSHSONAME) -o $@ $^ -lc -lm -lsysfs +else +$(MODULE_DIR)/$(LIBSHLIBNAME): $(LIBSHOBJECTS) + $(CC) -shared -Wl,-soname,$(LIBSHSONAME) -o $@ $^ -lc -lm +endif $(MODULE_DIR)/$(LIBSHSONAME): $(MODULE_DIR)/$(LIBSHLIBNAME) $(RM) $@ diff --git a/lib/sysfs.h b/lib/sysfs.h index 331307ad..216af73b 100644 --- a/lib/sysfs.h +++ b/lib/sysfs.h @@ -20,6 +20,7 @@ #ifndef SENSORS_LIB_SYSFS_H #define SENSORS_LIB_SYSFS_H +#ifdef SYSFS_SUPPORT extern int sensors_found_sysfs; extern char sensors_sysfs_mount[]; @@ -30,4 +31,13 @@ extern int sensors_read_sysfs_chips(void); extern int sensors_read_sysfs_bus(void); +#else + +#define sensors_found_sysfs 0 +#define sensors_init_sysfs() +#define sensors_read_sysfs_chips() (-1) +#define sensors_read_sysfs_bus() (-1) + +#endif + #endif /* !SENSORS_LIB_SYSFS_H */