| 1 | # I2C tools for Linux |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2007 Jean Delvare <khali@linux-fr.org> |
|---|
| 4 | # |
|---|
| 5 | # Licensed under the GNU General Public License. |
|---|
| 6 | |
|---|
| 7 | TOOLS_DIR := tools |
|---|
| 8 | |
|---|
| 9 | TOOLS_CFLAGS := -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ |
|---|
| 10 | -Wcast-align -Wwrite-strings -Wnested-externs -Winline \ |
|---|
| 11 | -W -Wundef -Wmissing-prototypes -Iinclude |
|---|
| 12 | |
|---|
| 13 | TOOLS_TARGETS := i2cdetect i2cdump i2cset i2cget |
|---|
| 14 | |
|---|
| 15 | # |
|---|
| 16 | # Programs |
|---|
| 17 | # |
|---|
| 18 | |
|---|
| 19 | $(TOOLS_DIR)/i2cdetect: $(TOOLS_DIR)/i2cdetect.o $(TOOLS_DIR)/i2cbusses.o |
|---|
| 20 | $(CC) $(LDFLAGS) -o $@ $^ |
|---|
| 21 | |
|---|
| 22 | $(TOOLS_DIR)/i2cdump: $(TOOLS_DIR)/i2cdump.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o |
|---|
| 23 | $(CC) $(LDFLAGS) -o $@ $^ |
|---|
| 24 | |
|---|
| 25 | $(TOOLS_DIR)/i2cset: $(TOOLS_DIR)/i2cget.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o |
|---|
| 26 | $(CC) $(LDFLAGS) -o $@ $^ |
|---|
| 27 | |
|---|
| 28 | $(TOOLS_DIR)/i2cget: $(TOOLS_DIR)/i2cset.o $(TOOLS_DIR)/i2cbusses.o $(TOOLS_DIR)/util.o |
|---|
| 29 | $(CC) $(LDFLAGS) -o $@ $^ |
|---|
| 30 | |
|---|
| 31 | # |
|---|
| 32 | # Objects |
|---|
| 33 | # |
|---|
| 34 | |
|---|
| 35 | $(TOOLS_DIR)/i2cdetect.o: $(TOOLS_DIR)/i2cdetect.c $(TOOLS_DIR)/i2cbusses.h |
|---|
| 36 | $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ |
|---|
| 37 | |
|---|
| 38 | $(TOOLS_DIR)/i2cdump.o: $(TOOLS_DIR)/i2cdump.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h |
|---|
| 39 | $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ |
|---|
| 40 | |
|---|
| 41 | $(TOOLS_DIR)/i2cset.o: $(TOOLS_DIR)/i2cset.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h |
|---|
| 42 | $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ |
|---|
| 43 | |
|---|
| 44 | $(TOOLS_DIR)/i2cget.o: $(TOOLS_DIR)/i2cget.c $(TOOLS_DIR)/i2cbusses.h $(TOOLS_DIR)/util.h |
|---|
| 45 | $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ |
|---|
| 46 | |
|---|
| 47 | $(TOOLS_DIR)/i2cbusses.o: $(TOOLS_DIR)/i2cbusses.c $(TOOLS_DIR)/i2cbusses.h |
|---|
| 48 | $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ |
|---|
| 49 | |
|---|
| 50 | $(TOOLS_DIR)/util.o: $(TOOLS_DIR)/util.c $(TOOLS_DIR)/util.h |
|---|
| 51 | $(CC) $(CFLAGS) $(TOOLS_CFLAGS) -c $< -o $@ |
|---|
| 52 | |
|---|
| 53 | # |
|---|
| 54 | # Commands |
|---|
| 55 | # |
|---|
| 56 | |
|---|
| 57 | all-tools: $(addprefix $(TOOLS_DIR)/,$(TOOLS_TARGETS)) |
|---|
| 58 | |
|---|
| 59 | strip-tools: $(addprefix $(TOOLS_DIR)/,$(TOOLS_TARGETS)) |
|---|
| 60 | strip $(addprefix $(TOOLS_DIR)/,$(TOOLS_TARGETS)) |
|---|
| 61 | |
|---|
| 62 | clean-tools: |
|---|
| 63 | $(RM) $(addprefix $(TOOLS_DIR)/,*.o $(TOOLS_TARGETS)) |
|---|
| 64 | |
|---|
| 65 | install-tools: $(addprefix $(TOOLS_DIR)/,$(TOOLS_TARGETS)) |
|---|
| 66 | $(INSTALL_DIR) $(DESTDIR)$(sbindir) $(DESTDIR)$(man8dir) |
|---|
| 67 | for program in $(TOOLS_TARGETS) ; do \ |
|---|
| 68 | $(INSTALL_PROGRAM) $(TOOLS_DIR)/$$program $(DESTDIR)$(sbindir) ; \ |
|---|
| 69 | $(INSTALL_DATA) $(TOOLS_DIR)/$$program.8 $(DESTDIR)$(man8dir) ; done |
|---|
| 70 | |
|---|
| 71 | uninstall-tools: |
|---|
| 72 | for program in $(TOOLS_TARGETS) ; do \ |
|---|
| 73 | $(RM) $(DESTDIR)$(sbindir)/$$program ; \ |
|---|
| 74 | $(RM) $(DESTDIR)$(man8dir)/$$program.8 ; done |
|---|
| 75 | |
|---|
| 76 | all: all-tools |
|---|
| 77 | |
|---|
| 78 | strip: strip-tools |
|---|
| 79 | |
|---|
| 80 | clean: clean-tools |
|---|
| 81 | |
|---|
| 82 | install: install-tools |
|---|
| 83 | |
|---|
| 84 | uninstall: uninstall-tools |
|---|