⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makefile

📁 I2C总线LINUX驱动程序
💻
字号:
#  Makefile - Makefile for a Linux module for reading sensor data.#  Copyright (c) 1998, 1999, 2000  Frodo Looijaard <frodol@dds.nl>##  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#  the Free Software Foundation; either version 2 of the License, or#  (at your option) any later version.##  This program is distributed in the hope that it will be useful,#  but WITHOUT ANY WARRANTY; without even the implied warranty of#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the#  GNU General Public License for more details.##  You should have received a copy of the GNU General Public License#  along with this program; if not, write to the Free Software#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.# Everything you may want to change is in the top of this file. Usually, you# can just use the defaults, fortunately.# If your /bin/sh is not bash, change the below definition so that make can# find bash. Or you can hope your sh-like shell understands all scripts.# I think so, but I have not tested it.#SHELL := /usr/bin/bash# The currently running kernel version. This is used right below to# determine where the kernel sources can be found.KERNELVERSION := $(shell uname -r)# The location of linux itself. This is used to find the kernel headers# and other things.#LINUX := /usr/src/linuxLINUX := $(shell if [ -L /lib/modules/$(KERNELVERSION)/build ] ; \	then echo "/lib/modules/$(KERNELVERSION)/build" ; \	else echo "/usr/src/linux" ; fi)LINUX_HEADERS := $(LINUX)/include# Determine whether we need to compile the kernel modules, or only the# user-space utilities. By default, the kernel modules are compiled.#COMPILE_KERNEL := 0COMPILE_KERNEL := 1# Uncomment the third line on SMP systems if the magic invocation fails. It# is a bit complicated because SMP configuration changed around kernel 2.1.130SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \                  grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \               then echo 1; else echo 0; fi)#SMP := 0#SMP := 1# Uncomment the second or third line if the magic invocation fails.# We need to know whether CONFIG_MODVERSIONS is defined.MODVER := $(shell if cat $(LINUX_HEADERS)/linux/config.h $(LINUX_HEADERS)/linux/autoconf.h 2>/dev/null | grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_MODVERSIONS[[:space:]]*1'; then echo 1; else echo 0; fi)#MODVER := 0#MODVER := 1# Your C compilerCC := gcc# This is the directory into which the modules will be installed.# The magic invocation will return something like this:#   /lib/modules/2.4.29MODPREF := /lib/modules/$(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release |cut -f 2 -d'"')# Prevent 2.6+ users from using this package, as this won't work.ifeq (,$(findstring /2.4., $(MODPREF)))    ifeq (, $(MAKECMDGOALS))        $(error For 2.6 kernels and later, you do not need this package)    endif    ifeq (install, $(MAKECMDGOALS))        $(error For 2.6 kernels and later, you do not need this package)    endifendif# This is the directory into which the header files will be installed.# If you want to make sure your current kernel tree is not overwritten,# the default should work. This is ignored for the i2c build system.LINUX_INCLUDE_DIR := /usr/local/include/linux#LINUX_INCLUDE_DIR := $(LINUX_HEADERS)/linux# If you want to isntall everything at some other place then at which# you will run it, DESTDIR defines a prefix used at installation-time.DESTDIR :=# Uncomment the second line if you are a developer. This will enable many# additional warnings at compile-timeWARN := 0#WARN := 1MACHINE := $(shell uname -m)################################################### Below this, nothing should need to be changed. ###################################################.PHONY: all clean install patch# Note that this is a monolithic Makefile; it calls no sub-Makefiles,# but instead, it compiles everything right from here. Yes, there are# some distinct advantages to this; see the following paper for more info:#   http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html# Note that is still uses Makefile fragments in sub-directories; these# are called 'Module.mk'.# Within each Module.mk, rules and dependencies can be added to targets# all, install and clean. Use double colons instead of single ones# to do this.# The subdirectories we need to build things inSRCDIRS := mkpatchifeq ($(COMPILE_KERNEL),1)SRCDIRS += kernelendif# Some often-used commands with default optionsMKDIR := mkdir -pRMDIR := rmdirRM := rm -fBISON := bisonFLEX := flexAR := arINSTALL := installLN := ln -sfnGREP := grep# Determine the default compiler flags# MODCFLAGS is to create in-kernel object files (modules)CPPFLAGS := -I$(LINUX_HEADERS)CFLAGS := -Wall -O2ifeq ($(WARN),1)CFLAGS += -W -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \          -Wcast-align -Wwrite-strings -Wnested-externs -Winlineendif# The -DEXPORT_SYMTAB is to keep the symbol export mechanism quiet.MODCFLAGS := $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer \             -DEXPORT_SYMTAB -fno-strict-aliasingifeq ($(MACHINE),alpha)MODCFLAGS += -ffixed-8 -mno-fp-regs -mcpu=ev56endififeq ($(MACHINE),x86_64)MODCFLAGS += -fno-common -fomit-frame-pointer -mno-red-zone \	     -mcmodel=kernel -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduceendififeq ($(MACHINE),mips)MODCFLAGS += -mabi=32 -mips3 -Wa,-32 -Wa,-mips3 -Wa,--trapendififeq ($(MACHINE),sparc32)MODCFLAGS += -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7endififeq ($(MACHINE),sparc64)MODCFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow \	     -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare \	     -Wa,--undeclared-regsendififeq ($(SMP),1)MODCPPFLAGS += -D__SMP__endififeq ($(MODVER),1)MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.hendif# This magic is from the kernel Makefile.# Extra cflags for kbuild 2.4.  The default is to forbid includes by kernel code# from user space headers.kbuild_2_4_nostdinc := -nostdinc $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')MODCPPFLAGS += $(CPPFLAGS) $(kbuild_2_4_nostdinc).PHONY: dep# Make all the default ruleall::# Include all makefiles for sub-modulesINCLUDEFILES :=ifneq ($(SRCDIRS),)include $(patsubst %,%/Module.mk,$(SRCDIRS))endififneq ($(MAKECMDGOALS),clean)ifneq ($(INCLUDEFILES),)include $(INCLUDEFILES)endifendif# Making the dependency files - done automatically!dep :all ::ifeq ($(shell if grep -q '^CONFIG_I2C=y' $(LINUX)/.config; then echo 1; fi),1)	@echo "*************** WARNING *************************** WARNING ***************"	@echo "***                                                                     ***"	@echo "*** You have I2C support built into your kernel (CONFIG_I2C=y). Unless  ***"	@echo "*** you know what you are doing, installing our version of i2c will not ***"	@echo "*** work. Newly built i2c modules probably won't load. Other modules    ***"	@echo "*** that rely on the i2c layer, such as lm_sensors, will fail to        ***"	@echo "*** compile. Please consider compiling your kernel again with I2C       ***"	@echo "*** support enabled as modules or disabled.                             ***"	@echo "***                                                                     ***"	@echo "*************** WARNING *************************** WARNING ***************"endifinstall :: allifeq ($(DESTDIR),)	-/sbin/depmod -aelse	@echo "*** This is a \`staged' install using \"$(DESTDIR)\" as prefix."	@echo "***"	@echo "*** Once the modules have been moved to their final destination"	@echo "*** you must run the command \"/sbin/depmod -a\"."	@echo "***"	@echo "*** Alternatively, if you build a package (e.g. rpm), include the"	@echo "*** command \"/sbin/depmod -a\" in the post-(un)install procedure."	@echo "***"	@echo "*** If the depmod command mentioned above generates errors, you should"	@echo "*** pay particular attention to the note #1 below."endif	@echo "*** Installation successful!"	@echo "*** Important notes:"	@echo "*** 1* Compatibility with the Linux 2.4 kernel has been restored."	@echo "*** 2* The i2c-elektor and i2c-pcf-epp modules were not built. If you"	@echo "***    need them, you have to use compilation option 3 as described in"	@echo "***    the INSTALL file."clean::$(LINUX)/.config:	@echo	@echo "Error - missing file $(LINUX)/.config !! "	@echo "  Verify kernel source is in $(LINUX) and then"	@echo "  cd to $(LINUX) and run 'make config' !!"	@echo	@echo "Exception: if you're using a stock RedHat/Fedora kernel..."	@echo "  (1) Install the appropriate kernel-source RPM."	@echo "  (2) Copy the appropriate config..."	@echo "      from $(LINUX)/configs/<...>"	@echo "      to $(LINUX)/.config"	@echo "  (3) Do *NOT* 'make dep' or 'make config'."	@echo	@exit 1# Here, we define all implicit rules we want to use..SUFFIXES:# We need to create dependency files. Tricky. We sed rule puts dir/file.d and# dir/file.c in front of the dependency file rule.# .o files are used for modules# depend on the kernel config file!%.o: %.c $(LINUX)/.config	$(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@%.d: %.c $(LINUX)/.config	$(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \	sed -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -