1# I2C tools for Linux 2# 3# Copyright (C) 2007, 2012 Jean Delvare <jdelvare@suse.de> 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9 10TOOLS_DIR := tools 11 12TOOLS_CFLAGS := -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ 13 -Wcast-align -Wwrite-strings -Wnested-externs -Winline \ 14 -W -Wundef -Wmissing-prototypes -Iinclude 15ifeq ($(USE_STATIC_LIB),1) 16TOOLS_LDFLAGS := $(LIB_DIR)/$(LIB_STLIBNAME) 17else 18TOOLS_LDFLAGS := -L$(LIB_DIR) -li2c 19endif 20 21TOOLS_TARGETS := i2cdetect i2cdump i2cset i2cget i2ctransfer 22 23# 24# Programs 25# 26 27$(TOOLS_DIR)/i2cdetect: $(TOOLS_DIR)/i2cdetect.o $(TOOLS_DIR)/i2cbusses.o $(LIB_DEPS) 28 $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) 29 30$(TOOLS_DIR)/i2cdump: $(TOOLS_DIR)/i2cdump.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o $(LIB_DEPS) 31 $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) 32 33$(TOOLS_DIR)/i2cset: $(TOOLS_DIR)/i2cset.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o $(LIB_DEPS) 34 $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) 35 36$(TOOLS_DIR)/i2cget: $(TOOLS_DIR)/i2cget.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o $(LIB_DEPS) 37 $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) 38 39$(TOOLS_DIR)/i2ctransfer: $(TOOLS_DIR)/i2ctransfer.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o $(LIB_DEPS) 40 $(CC) $(LDFLAGS) -o $@ $^ $(TOOLS_LDFLAGS) 41 42# 43# Objects 44# 45 46$(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h version.h $(INCLUDE_DIR)/i2c/smbus.h 47 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 48 49$(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/i2c/smbus.h 50 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 51 52$(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/i2c/smbus.h 53 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 54 55$(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h $(INCLUDE_DIR)/i2c/smbus.h 56 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 57 58$(TOOLS_DIR)/i2ctransfer.o: $(TOOLS_DIR)/i2ctransfer.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h version.h 59 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 60 61$(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h 62 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 63 64$(TOOLS_DIR)/util.o: $(TOOLS_DIR)/util.c $(TOOLS_DIR)/util.h 65 $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ 66 67# 68# Commands 69# 70 71all-tools: $(addprefix $(TOOLS_DIR)/,$(TOOLS_TARGETS)) 72 73strip-tools: $(addprefix $(TOOLS_DIR)/,$(TOOLS_TARGETS)) 74 $(STRIP) $(addprefix $(TOOLS_DIR)/,$(TOOLS_TARGETS)) 75 76clean-tools: 77 $(RM) $(addprefix $(TOOLS_DIR)/,*.o $(TOOLS_TARGETS)) 78 79install-tools: $(addprefix $(TOOLS_DIR)/,$(TOOLS_TARGETS)) 80 $(INSTALL_DIR) $(DESTDIR)$(sbindir) $(DESTDIR)$(man8dir) 81 for program in $(TOOLS_TARGETS) ; do \ 82 $(INSTALL_PROGRAM) $(TOOLS_DIR)/$$program $(DESTDIR)$(sbindir) ; \ 83 $(INSTALL_DATA) $(TOOLS_DIR)/$$program.8 $(DESTDIR)$(man8dir) ; done 84 85uninstall-tools: 86 for program in $(TOOLS_TARGETS) ; do \ 87 $(RM) $(DESTDIR)$(sbindir)/$$program ; \ 88 $(RM) $(DESTDIR)$(man8dir)/$$program.8 ; done 89 90all: all-tools 91 92strip: strip-tools 93 94clean: clean-tools 95 96install: install-tools 97 98uninstall: uninstall-tools 99