Skip to contentSkip to conversation

i2c-tools: Introduce libi2c

PATCH New Jean Delvare 1 participant 4 messages Apr 23, 2012 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover i2c-tools: Introduce libi2c

For years now, project i2c-tools has been carrying a modified copy of <linux/i2c-dev.h> for use by user-space applications accessing /dev/i2c-* device nodes. The modified copy includes parts of <linux/i2c.h> as well as i2c_smbus_*() inline functions mimicking their kernel counterparts.

Why it was done that way, I'm not sure. Maybe to make things easier for application authors, or maybe just because nobody ever cared to clean it all up. But what I'm sure of is that the current situation is ugly and should be cleaned up. Kernel interfaces should be described by kernel header files, not random user-space tool projects.

So I have a plan to get rid of <linux/i2c-dev.h> in i2c-tools and to move the inline i2c_smbus_*() functions to a proper library - they are too large to be inline functions and recent versions of gcc complain about that.

Signature · 1 line
Jean Delvare

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH v2 1/3 i2c-tools: Clean up <linux/i2c-dev.h>

Minimize differences between kernel and user-space flavors of <linux/i2c-dev.h>.

---
 include/linux/i2c-dev.h |   60 +++++++++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 33 deletions(-)
include/linux/i2c-dev.h +27 -33
@@ -20,10 +20,8 @@
     MA 02110-1301 USA.
 */
 
-/* $Id: i2c-dev.h 5894 2010-12-12 13:22:29Z khali $ */
-
-#ifndef LIB_I2CDEV_H
-#define LIB_I2CDEV_H
+#ifndef _LINUX_I2C_DEV_H
+#define _LINUX_I2C_DEV_H
 
 #include <linux/types.h>
 #include <sys/ioctl.h>
@@ -111,52 +109,48 @@ union i2c_smbus_data {
 #define I2C_SMBUS_I2C_BLOCK_DATA    8
 
 
-/* ----- commands for the ioctl like i2c_command call:
- * note that additional calls are defined in the algorithm and hw 
- *	dependent layers - these can be listed here, or see the 
- *	corresponding header files.
+/* /dev/i2c-X ioctl commands.  The ioctl's parameter is always an
+ * unsigned long, except for:
+ *	- I2C_FUNCS, takes pointer to an unsigned long
+ *	- I2C_RDWR, takes pointer to struct i2c_rdwr_ioctl_data
+ *	- I2C_SMBUS, takes pointer to struct i2c_smbus_ioctl_data
  */
-				/* -> bit-adapter specific ioctls	*/
-#define I2C_RETRIES	0x0701	/* number of times a device address      */
-				/* should be polled when not            */
-                                /* acknowledging 			*/
-#define I2C_TIMEOUT	0x0702	/* set timeout - call with int 		*/
-
-
-/* this is for i2c-dev.c	*/
-#define I2C_SLAVE	0x0703	/* Change slave address			*/
-				/* Attn.: Slave address is 7 or 10 bits */
-#define I2C_SLAVE_FORCE	0x0706	/* Change slave address			*/
-				/* Attn.: Slave address is 7 or 10 bits */
-				/* This changes the address, even if it */
-				/* is already taken!			*/
-#define I2C_TENBIT	0x0704	/* 0 for 7 bit addrs, != 0 for 10 bit	*/
+#define I2C_RETRIES	0x0701	/* number of times a device address should
+				   be polled when not acknowledging */
+#define I2C_TIMEOUT	0x0702	/* set timeout in units of 10 ms */
 
-#define I2C_FUNCS	0x0705	/* Get the adapter functionality */
-#define I2C_RDWR	0x0707	/* Combined R/W transfer (one stop only)*/
-#define I2C_PEC		0x0708	/* != 0 for SMBus PEC                   */
+/* NOTE: Slave address is 7 or 10 bits, but 10-bit addresses
+ * are NOT supported! (due to code brokenness)
+ */
+#define I2C_SLAVE	0x0703	/* Use this slave address */
+#define I2C_SLAVE_FORCE	0x0706	/* Use this slave address, even if it
+				   is already in use by a driver! */
+#define I2C_TENBIT	0x0704	/* 0 for 7 bit addrs, != 0 for 10 bit */
 
-#define I2C_SMBUS	0x0720	/* SMBus-level access */
+#define I2C_FUNCS	0x0705	/* Get the adapter functionality mask */
 
-/* -- i2c.h -- */
+#define I2C_RDWR	0x0707	/* Combined R/W transfer (one STOP only) */
 
+#define I2C_PEC		0x0708	/* != 0 to use PEC with SMBus */
+#define I2C_SMBUS	0x0720	/* SMBus transfer */
 
-/* Note: 10-bit addresses are NOT supported! */
 
 /* This is the structure as used in the I2C_SMBUS ioctl call */
 struct i2c_smbus_ioctl_data {
-	char read_write;
+	__u8 read_write;
 	__u8 command;
-	int size;
+	__u32 size;
 	union i2c_smbus_data *data;
 };
 
 /* This is the structure as used in the I2C_RDWR ioctl call */
 struct i2c_rdwr_ioctl_data {
 	struct i2c_msg *msgs;	/* pointers to i2c_msgs */
-	int nmsgs;		/* number of i2c_msgs */
+	__u32 nmsgs;			/* number of i2c_msgs */
 };
 
+#define  I2C_RDRW_IOCTL_MAX_MSGS	42
+
 
 static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command, 
                                      int size, union i2c_smbus_data *data)
@@ -332,4 +326,4 @@ static inline __s32 i2c_smbus_block_proc
 }
 
 
-#endif /* LIB_I2CDEV_H */
+#endif /* _LINUX_I2C_DEV_H */
Signature · 1 line
Jean Delvare
#3 lore raw

PATCH v2 2/3 i2c-tools: Split i2c-dev.h into parts

In reply to a message not in the archive

Properly split i2c-dev.h into parts:
* The i2c_smbus_* inline functions go to a dedicated user-space header file for now (and later to a library.)
* The parts from the kernel's i2c.h go away, and applications will include <linux/i2c.h> explicitly from now on.
* The parts from the kernel's i2c-dev.h stay here. This is now an exact copy of the file generated from the kernel's i2c-dev.h, and will be dropped soon.

Adjust all tools accordingly. Third party applications will have to do the same.
---
Changes since v1:
* Rename the future library from libi2c-dev to just libi2c.
* Add a few missing includes in tools.
* Fix "make install".

 eepromer/24cXX.c        |    3 
 eepromer/24cXX.h        |    2 
 eepromer/eeprom.c       |    2 
 eepromer/eepromer.c     |    2 
 include/Module.mk       |    6 -
 include/i2c/smbus.h     |  212 ++++++++++++++++++++++++++++++++++++++
 include/linux/i2c-dev.h |  257 -----------------------------------------------
 py-smbus/Module.mk      |    2 
 py-smbus/smbusmodule.c  |    3 
 tools/Module.mk         |   12 +-
 tools/i2cbusses.c       |    4 
 tools/i2cdetect.c       |    5 
 tools/i2cdump.c         |    5 
 tools/i2cget.c          |    5 
 tools/i2cset.c          |    5 
 15 files changed, 252 insertions(+), 273 deletions(-)
eepromer/24cXX.c +3 -0
@@ -18,11 +18,14 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <linux/fs.h>
+#include <linux/i2c.h>
+#include <linux/i2c-dev.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <errno.h>
 #include <assert.h>
 #include <string.h>
+#include <i2c/smbus.h>
 #include "24cXX.h"
 
 static int i2c_write_1b(struct eeprom *e, __u8 buf)
eepromer/24cXX.h +1 -1
@@ -15,7 +15,7 @@
  ***************************************************************************/
 #ifndef _24CXX_H_
 #define _24CXX_H_
-#include <linux/i2c-dev.h>
+#include <linux/types.h>
 
 #define EEPROM_TYPE_UNKNOWN	0
 #define EEPROM_TYPE_8BIT_ADDR	1
eepromer/eeprom.c +2 -0
@@ -2,6 +2,7 @@
 This program is hereby placed into the public domain.
 Of course the program is provided without warranty of any kind.
 */
+#include <sys/ioctl.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -9,6 +10,7 @@ Of course the program is provided withou
 #include <fcntl.h>
 #include <string.h>
 #include <time.h>
+#include <linux/i2c.h>
 #include <linux/i2c-dev.h>
 
 /*
eepromer/eepromer.c +2 -0
@@ -1,3 +1,4 @@
+#include <sys/ioctl.h>
 #include <errno.h>                                                              
 #include <string.h>                                                             
 #include <stdio.h>                                                              
@@ -5,6 +6,7 @@
 #include <unistd.h>                                                             
 #include <fcntl.h>                                                              
 #include <time.h>
+#include <linux/i2c.h>
 #include <linux/i2c-dev.h>
 
 
include/Module.mk +3 -3
@@ -1,6 +1,6 @@
 # Linux I2C header files
 #
-# Copyright (C) 2007  Jean Delvare <[email protected]>
+# Copyright (C) 2007, 2012  Jean Delvare <[email protected]>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -9,14 +9,14 @@
 
 INCLUDE_DIR	:= include
 
-INCLUDE_TARGETS	:= linux/i2c-dev.h
+INCLUDE_TARGETS	:= i2c/smbus.h
 
 #
 # Commands
 #
 
 install-include: $(addprefix $(INCLUDE_DIR)/,$(INCLUDE_TARGETS))
-	$(INSTALL_DIR) $(DESTDIR)$(incdir)/linux
+	$(INSTALL_DIR) $(DESTDIR)$(incdir)/i2c
 	for file in $(INCLUDE_TARGETS) ; do \
 	$(INSTALL_DATA) $(INCLUDE_DIR)/$$file $(DESTDIR)$(incdir)/$$file ; done
 
include/i2c/smbus.h new file +212 -0

212 lines not on this page · raw message

include/linux/i2c-dev.h +0 -257

267 lines not on this page · raw message

py-smbus/Module.mk +1 -1
@@ -14,7 +14,7 @@ DISTUTILS := \
 	cd $(PY_SMBUS_DIR) && \
 	CPPFLAGS="$(CPPFLAGS) -I../include" $(PYTHON) setup.py
 
-all-python: $(INCLUDE_DIR)/linux/i2c-dev.h
+all-python: $(INCLUDE_DIR)/i2c/smbus.h
 	$(DISTUTILS) build
 
 clean-python:
py-smbus/smbusmodule.c +3 -0
@@ -18,10 +18,13 @@
 
 #include <Python.h>
 #include "structmember.h"
+#include <sys/ioctl.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <fcntl.h>
+#include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <i2c/smbus.h>
 
 /*
 ** These are required to build this module against Linux older than 2.6.23.
tools/Module.mk +6 -6
@@ -1,6 +1,6 @@
 # I2C tools for Linux
 #
-# Copyright (C) 2007  Jean Delvare <[email protected]>
+# Copyright (C) 2007, 2012  Jean Delvare <[email protected]>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -35,19 +35,19 @@ $(TOOLS_DIR)/i2cget: $(TOOLS_DIR)/i2cget
 # Objects
 #
 
-$(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/linux/i2c-dev.h
+$(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/i2c/smbus.h
 	$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
 
-$(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/linux/i2c-dev.h
+$(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h
 	$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
 
-$(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/linux/i2c-dev.h
+$(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h
 	$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
 
-$(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/linux/i2c-dev.h
+$(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h $(INCLUDE_DIR)/i2c/smbus.h
 	$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
 
-$(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h $(INCLUDE_DIR)/linux/i2c-dev.h
+$(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h
 	$(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@
 
 $(TOOLS_DIR)/util.o: $(TOOLS_DIR)/util.c $(TOOLS_DIR)/util.h
tools/i2cbusses.c +3 -1
@@ -4,7 +4,7 @@
                devices.
     Copyright (c) 1999-2003  Frodo Looijaard <[email protected]> and
                              Mark D. Studebaker <mdsxyz123-/[email protected]>
-    Copyright (C) 2008-2010  Jean Delvare <[email protected]>
+    Copyright (C) 2008-2012  Jean Delvare <[email protected]>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -28,6 +28,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/param.h>	/* for NAME_MAX */
+#include <sys/ioctl.h>
 #include <string.h>
 #include <strings.h>	/* for strcasecmp() */
 #include <stdio.h>
@@ -38,6 +39,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include "i2cbusses.h"
+#include <linux/i2c.h>
 #include <linux/i2c-dev.h>
 
 enum adt { adt_dummy, adt_isa, adt_i2c, adt_smbus, adt_unknown };
tools/i2cdetect.c +4 -1
@@ -2,7 +2,7 @@
     i2cdetect.c - a user-space program to scan for I2C devices
     Copyright (C) 1999-2004  Frodo Looijaard <[email protected]>, and
                              Mark D. Studebaker <mdsxyz123-/[email protected]>
-    Copyright (C) 2004-2010  Jean Delvare <[email protected]>
+    Copyright (C) 2004-2012  Jean Delvare <[email protected]>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -20,12 +20,15 @@
     MA 02110-1301 USA.
 */
 
+#include <sys/ioctl.h>
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <i2c/smbus.h>
 #include "i2cbusses.h"
 #include "../version.h"
 
tools/i2cdump.c +4 -1
@@ -2,7 +2,7 @@
     i2cdump.c - a user-space program to dump I2C registers
     Copyright (C) 2002-2003  Frodo Looijaard <[email protected]>, and
                              Mark D. Studebaker <mdsxyz123-/[email protected]>
-    Copyright (C) 2004-2010  Jean Delvare <[email protected]>
+    Copyright (C) 2004-2012  Jean Delvare <[email protected]>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -20,12 +20,15 @@
     MA 02110-1301 USA.
 */
 
+#include <sys/ioctl.h>
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <i2c/smbus.h>
 #include "i2cbusses.h"
 #include "util.h"
 #include "../version.h"
tools/i2cget.c +4 -1
@@ -1,6 +1,6 @@
 /*
     i2cget.c - A user-space program to read an I2C register.
-    Copyright (C) 2005-2010  Jean Delvare <[email protected]>
+    Copyright (C) 2005-2012  Jean Delvare <[email protected]>
 
     Based on i2cset.c:
     Copyright (C) 2001-2003  Frodo Looijaard <[email protected]>, and
@@ -23,12 +23,15 @@
     MA 02110-1301 USA.
 */
 
+#include <sys/ioctl.h>
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <i2c/smbus.h>
 #include "i2cbusses.h"
 #include "util.h"
 #include "../version.h"
tools/i2cset.c +4 -1
@@ -2,7 +2,7 @@
     i2cset.c - A user-space program to write an I2C register.
     Copyright (C) 2001-2003  Frodo Looijaard <[email protected]>, and
                              Mark D. Studebaker <mdsxyz123-/[email protected]>
-    Copyright (C) 2004-2010  Jean Delvare <[email protected]>
+    Copyright (C) 2004-2012  Jean Delvare <[email protected]>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -20,12 +20,15 @@
     MA 02110-1301 USA.
 */
 
+#include <sys/ioctl.h>
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <linux/i2c.h>
 #include <linux/i2c-dev.h>
+#include <i2c/smbus.h>
 #include "i2cbusses.h"
 #include "util.h"
 #include "../version.h"
Signature · 1 line
Jean Delvare
#4 lore raw

PATCH v2 3/3 i2c-tools: New libi2c library

In reply to a message not in the archive

New library for I2C device access under Linux. As a first step, the library will host the i2c_smbus_*() inline functions which were previously in the user-space flavor of <linux/i2c-dev.h>.

---
 Makefile            |   14 ++-
 README              |   32 +++++---
 include/i2c/smbus.h |  191 ++++-------------------------------------------
 lib/Module.mk       |  102 +++++++++++++++++++++++++
 lib/libi2c.map      |   18 ++++
 lib/smbus.c         |  203 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/Module.mk     |    9 +-
 7 files changed, 378 insertions(+), 191 deletions(-)
Makefile +10 -4
@@ -14,19 +14,25 @@ sbindir	= $(prefix)/sbin
 mandir	= $(prefix)/share/man
 man8dir	= $(mandir)/man8
 incdir	= $(prefix)/include
+libdir	= $(prefix)/lib
 
 INSTALL		:= install
 INSTALL_DATA	:= $(INSTALL) -m 644
 INSTALL_DIR	:= $(INSTALL) -m 755 -d
 INSTALL_PROGRAM	:= $(INSTALL) -m 755
+LN		:= ln -sf
 RM		:= rm -f
 
 CC	?= gcc
+AR	?= ar
 
-CFLAGS	?= -O2
+CFLAGS		?= -O2
 # When debugging, use the following instead
-#CFLAGS	:= -O -g
-CFLAGS	+= -Wall
+#CFLAGS		:= -O -g
+CFLAGS		+= -Wall
+SOCFLAGS	:= -fpic -D_REENTRANT $(CFLAGS)
+
+BUILD_STATIC_LIB ?= 1
 
 KERNELVERSION	:= $(shell uname -r)
 
@@ -36,5 +42,5 @@ all:
 
 EXTRA	:=
 #EXTRA	+= py-smbus
-SRCDIRS	:= include eeprom stub tools $(EXTRA)
+SRCDIRS	:= include lib eeprom stub tools $(EXTRA)
 include $(SRCDIRS:%=%/Module.mk)
README +21 -11
@@ -1,10 +1,15 @@
 I2C TOOLS FOR LINUX
 ===================
 
-This package contains an heterogeneous set of I2C tools for the Linux kernel.
-These tools were originally part of the lm-sensors project but were finally
-split into their own package for convenience. They compile, run and have been
-tested on GNU/Linux.
+This package contains an heterogeneous set of I2C tools for the Linux kernel
+as well as an I2C library. The tools were originally part of the lm-sensors
+project but were finally split into their own package for convenience. The
+library is used by some of the tools, but can also be used by third-party
+applications. The tools and library compile, run and have been tested on
+GNU/Linux.
+
+The latest version of the code can be downloaded from:
+  http://www.lm-sensors.org/wiki/I2CTools
 
 
 CONTENTS
@@ -25,6 +30,10 @@ category has its own sub-directory:
   C/C++ header files for I2C and SMBus access over i2c-dev. Installed by
   default.
 
+* lib
+  The I2C library, used by eepromer, py-smbus and tools. Installed by
+  default.
+
 * py-smbus
   Python wrapper for SMBus access over i2c-dev. Not installed by default.
 
@@ -40,16 +49,17 @@ category has its own sub-directory:
 INSTALLATION
 ------------
 
-There's no configure script, so simply run "make" to build the tools, and
-"make install" to install them. You also can use "make uninstall" to remove
-all the files you installed. By default, files are installed in /usr/local
-but you can change this behavior by editing the Makefile file and setting
-prefix to wherever you want. You may change the C compiler and the
-compilation flags as well.
+There's no configure script, so simply run "make" to build the library and
+tools, and "make install" to install them. You also can use "make uninstall"
+to remove all the files you installed. By default, files are installed in
+/usr/local but you can change the location by editing the Makefile file and
+setting prefix to wherever you want. You may change the C compiler and the
+compilation flags as well, and also decide whether to build the static
+library or not.
 
 Optionally, you can run "make strip" prior to "make install" if you want
 smaller binaries. However, be aware that this will prevent any further
-attempt to debug the programs.
+attempt to debug the library and tools.
 
 If you wish to include sub-directories that are not enabled by default, then
 just set them via the EXTRA make variable. For example, to build py-smbus,
include/i2c/smbus.h +19 -172

209 lines not on this page · raw message

lib/Module.mk new file +102 -0

102 lines not on this page · raw message

lib/libi2c.map new file +18 -0
@@ -0,0 +1,18 @@
+{
+global:
+  i2c_smbus_access;
+  i2c_smbus_write_quick;
+  i2c_smbus_read_byte;
+  i2c_smbus_write_byte;
+  i2c_smbus_read_byte_data;
+  i2c_smbus_write_byte_data;
+  i2c_smbus_read_word_data;
+  i2c_smbus_write_word_data;
+  i2c_smbus_process_call;
+  i2c_smbus_read_block_data;
+  i2c_smbus_write_block_data;
+  i2c_smbus_read_i2c_block_data;
+  i2c_smbus_write_i2c_block_data;
+  i2c_smbus_block_process_call;
+local: *;
+ };
lib/smbus.c new file +203 -0

203 lines not on this page · raw message

tools/Module.mk +5 -4
@@ -12,6 +12,7 @@ TOOLS_DIR	:= tools
 TOOLS_CFLAGS	:= -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
 		   -Wcast-align -Wwrite-strings -Wnested-externs -Winline \
 		   -W -Wundef -Wmissing-prototypes -Iinclude
+TOOLS_LDFLAGS	:= -Llib -li2c
 
 TOOLS_TARGETS	:= i2cdetect i2cdump i2cset i2cget
 
@@ -20,16 +21,16 @@ TOOLS_TARGETS	:= i2cdetect i2cdump i2cse
 #
 
 $(TOOLS_DIR)/i2cdetect: $(TOOLS_DIR)/i2cdetect.o $(TOOLS_DIR)/i2cbusses.o
-	$(CC) $(LDFLAGS) -o $@ $^
+	$(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^
 
 $(TOOLS_DIR)/i2cdump: $(TOOLS_DIR)/i2cdump.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o
-	$(CC) $(LDFLAGS) -o $@ $^
+	$(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^
 
 $(TOOLS_DIR)/i2cset: $(TOOLS_DIR)/i2cset.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o
-	$(CC) $(LDFLAGS) -o $@ $^
+	$(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^
 
 $(TOOLS_DIR)/i2cget: $(TOOLS_DIR)/i2cget.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o
-	$(CC) $(LDFLAGS) -o $@ $^
+	$(CC) $(LDFLAGS) $(TOOLS_LDFLAGS) -o $@ $^
 
 #
 # Objects
Signature · 1 line
Jean Delvare