| 1 | # Module.mk - Makefile for a Linux module for reading sensor data. |
|---|
| 2 | # Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> |
|---|
| 3 | # |
|---|
| 4 | # This program is free software; you can redistribute it and/or modify |
|---|
| 5 | # it under the terms of the GNU General Public License as published by |
|---|
| 6 | # the Free Software Foundation; either version 2 of the License, or |
|---|
| 7 | # (at your option) any later version. |
|---|
| 8 | # |
|---|
| 9 | # This program is distributed in the hope that it will be useful, |
|---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | # GNU General Public License for more details. |
|---|
| 13 | # |
|---|
| 14 | # You should have received a copy of the GNU General Public License |
|---|
| 15 | # along with this program; if not, write to the Free Software |
|---|
| 16 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|---|
| 17 | |
|---|
| 18 | # Note that MODULE_DIR (the directory in which this file resides) is a |
|---|
| 19 | # 'simply expanded variable'. That means that its value is substituted |
|---|
| 20 | # verbatim in the rules, until it is redefined. |
|---|
| 21 | MODULE_DIR := kernel |
|---|
| 22 | KERNELDIR := $(MODULE_DIR) |
|---|
| 23 | |
|---|
| 24 | # Regrettably, even 'simply expanded variables' will not put their currently |
|---|
| 25 | # defined value verbatim into the command-list of rules... |
|---|
| 26 | # We will only include those modules which are not already built into this |
|---|
| 27 | # kernel. |
|---|
| 28 | KERNELTARGETS := |
|---|
| 29 | KERNELINCLUDES := |
|---|
| 30 | ifneq ($(shell if grep -q '^CONFIG_I2C=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 31 | KERNELTARGETS += $(MODULE_DIR)/i2c-core.o |
|---|
| 32 | KERNELINCLUDES += $(MODULE_DIR)/i2c.h $(MODULE_DIR)/i2c-id.h |
|---|
| 33 | endif |
|---|
| 34 | ifneq ($(shell if grep -q '^CONFIG_I2C_CHARDEV=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 35 | KERNELTARGETS += $(MODULE_DIR)/i2c-dev.o |
|---|
| 36 | endif |
|---|
| 37 | ifneq ($(shell if grep -q '^CONFIG_I2C_ALGOBIT=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 38 | KERNELTARGETS += $(MODULE_DIR)/i2c-algo-bit.o |
|---|
| 39 | KERNELINCLUDES += $(MODULE_DIR)/i2c-algo-bit.h |
|---|
| 40 | endif |
|---|
| 41 | ifneq ($(shell if grep -q '^CONFIG_I2C_ALGOBITHS=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 42 | KERNELTARGETS += $(MODULE_DIR)/i2c-algo-biths.o |
|---|
| 43 | KERNELINCLUDES += $(MODULE_DIR)/i2c-algo-biths.h |
|---|
| 44 | endif |
|---|
| 45 | ifneq ($(shell if grep -q '^CONFIG_I2C_PHILIPSPAR=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 46 | ifeq ($(shell if grep -q '^CONFIG_PARPORT=[my]' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 47 | KERNELTARGETS += $(MODULE_DIR)/i2c-philips-par.o |
|---|
| 48 | endif |
|---|
| 49 | endif |
|---|
| 50 | ifneq ($(shell if grep -q '^CONFIG_I2C_ELV=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 51 | KERNELTARGETS += $(MODULE_DIR)/i2c-elv.o |
|---|
| 52 | endif |
|---|
| 53 | ifneq ($(shell if grep -q '^CONFIG_I2C_VELLEMAN=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 54 | KERNELTARGETS += $(MODULE_DIR)/i2c-velleman.o |
|---|
| 55 | endif |
|---|
| 56 | ifneq ($(shell if grep -q '^CONFIG_I2C_ALGOPCF=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 57 | KERNELTARGETS += $(MODULE_DIR)/i2c-algo-pcf.o |
|---|
| 58 | KERNELINCLUDES += $(MODULE_DIR)/i2c-algo-pcf.h |
|---|
| 59 | endif |
|---|
| 60 | # will not build outside kernel tree |
|---|
| 61 | ifneq ($(shell if grep -q '^CONFIG_I2C_ELEKTOR=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 62 | #KERNELTARGETS += $(MODULE_DIR)/i2c-elektor.o |
|---|
| 63 | #KERNELINCLUDES += $(MODULE_DIR)/i2c-pcf8584.h |
|---|
| 64 | endif |
|---|
| 65 | ifneq ($(shell if grep -q '^CONFIG_I2C_PROC=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 66 | KERNELTARGETS += $(MODULE_DIR)/i2c-proc.o |
|---|
| 67 | KERNELINCLUDES += $(MODULE_DIR)/i2c-proc.h |
|---|
| 68 | endif |
|---|
| 69 | ifneq ($(shell if grep -q '^CONFIG_I2C_PPORT=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 70 | KERNELTARGETS += $(MODULE_DIR)/i2c-pport.o |
|---|
| 71 | endif |
|---|
| 72 | #ifeq ($(shell if grep -q '^CONFIG_I2C_IOP3XX=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 73 | #KERNELTARGETS += $(MODULE_DIR)/i2c-iop3xx.o |
|---|
| 74 | #endif |
|---|
| 75 | # |
|---|
| 76 | # No CONFIG option for this yet (not in mkpatch) |
|---|
| 77 | # |
|---|
| 78 | # will not build outside kernel tree |
|---|
| 79 | #KERNELTARGETS += $(MODULE_DIR)/i2c-pcf-epp.o |
|---|
| 80 | # |
|---|
| 81 | # following require kernel 2.4.3 or higher... and PPC |
|---|
| 82 | # |
|---|
| 83 | #ifneq ($(shell if grep -q '^CONFIG_I2C_ALGO8XX=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 84 | #KERNELTARGETS += $(MODULE_DIR)/i2c-algo-8xx.o |
|---|
| 85 | #KERNELINCLUDES += $(MODULE_DIR)/i2c-algo-8xx.h |
|---|
| 86 | #endif |
|---|
| 87 | #ifneq ($(shell if grep -q '^CONFIG_I2C_RPXLITE=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 88 | #KERNELTARGETS += $(MODULE_DIR)/i2c-rpx.o |
|---|
| 89 | #endif |
|---|
| 90 | |
|---|
| 91 | # Include all dependency files |
|---|
| 92 | INCLUDEFILES += $(KERNELTARGETS:.o=.d) |
|---|
| 93 | |
|---|
| 94 | all-kernel: $(KERNELTARGETS) |
|---|
| 95 | all :: all-kernel |
|---|
| 96 | |
|---|
| 97 | # |
|---|
| 98 | # If $MODPREF/kernel exists, we presume the new (2.4.0) /lib/modules/x.y.z directory |
|---|
| 99 | # layout, so we install in kernel/drivers/i2c/ and remove old versions in misc/ |
|---|
| 100 | # Otherwise we install in misc/ as before. |
|---|
| 101 | # |
|---|
| 102 | install-kernel: all-kernel |
|---|
| 103 | if [ -n "$(KERNELTARGETS)" ] ; then \ |
|---|
| 104 | $(MKDIR) $(DESTDIR)$(MODPREF)/kernel/drivers/i2c ; \ |
|---|
| 105 | $(INSTALL) -m 644 $(KERNELTARGETS) $(DESTDIR)$(MODPREF)/kernel/drivers/i2c ; \ |
|---|
| 106 | for i in $(KERNELTARGETS) ; do \ |
|---|
| 107 | $(RM) $(DESTDIR)$(MODPREF)/misc/`basename $$i` $(DESTDIR)$(MODPREF)/misc/`basename $$i`.gz $(DESTDIR)$(MODPREF)/kernel/drivers/i2c/`basename $$i`.gz ; \ |
|---|
| 108 | done ; \ |
|---|
| 109 | for i in i2c-elektor.o i2c-pcf-epp.o ; do \ |
|---|
| 110 | $(RM) $(DESTDIR)$(MODPREF)/misc/`basename $$i` $(DESTDIR)$(MODPREF)/misc/`basename $$i`.gz $(DESTDIR)$(MODPREF)/kernel/drivers/i2c/`basename $$i` $(DESTDIR)$(MODPREF)/kernel/drivers/i2c/`basename $$i`.gz ; \ |
|---|
| 111 | done ; \ |
|---|
| 112 | $(RMDIR) $(DESTDIR)$(MODPREF)/misc 2> /dev/null || true ; \ |
|---|
| 113 | fi |
|---|
| 114 | if [ -n "$(KERNELINCLUDES)" ] ; then \ |
|---|
| 115 | $(MKDIR) $(DESTDIR)$(LINUX_INCLUDE_DIR) ; \ |
|---|
| 116 | $(INSTALL) -m 644 $(KERNELINCLUDES) $(DESTDIR)$(LINUX_INCLUDE_DIR) ; \ |
|---|
| 117 | fi |
|---|
| 118 | install :: install-kernel |
|---|
| 119 | |
|---|
| 120 | clean-kernel: |
|---|
| 121 | $(RM) $(KERNELDIR)/*.o $(KERNELDIR)/*.d $(KERNELDIR)/.*.o.flags |
|---|
| 122 | $(RM) $(KERNELDIR)/*~ |
|---|
| 123 | clean :: clean-kernel |
|---|
| 124 | |
|---|