root/i2c/branches/lk2-4/Makefile @ 3802

Revision 3802, 6.6 KB (checked in by mds, 10 years ago)

Copy over -nostdinc include method from sensors;

Remove pre-2.4 method of installing in misc;
Remove old gzipped modules;
rmdir misc directory if present and empty

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#  Makefile - Makefile for a Linux module for reading sensor data.
2#  Copyright (c) 1998, 1999, 2000  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# Everything you may want to change is in the top of this file. Usually, you
19# can just use the defaults, fortunately.
20
21# If your /bin/sh is not bash, change the below definition so that make can
22# find bash. Or you can hope your sh-like shell understands all scripts.
23# I think so, but I have not tested it.
24#SHELL := /usr/bin/bash
25
26# The currently running kernel version. This is used right below to
27# determine where the kernel sources can be found.
28KERNELVERSION := $(shell uname -r)
29
30# The location of linux itself. This is used to find the kernel headers
31# and other things.
32#LINUX := /usr/src/linux
33LINUX := $(shell if [ -L /lib/modules/$(KERNELVERSION)/build ] ; \
34        then echo "/lib/modules/$(KERNELVERSION)/build" ; \
35        else echo "/usr/src/linux" ; fi)
36LINUX_HEADERS := $(LINUX)/include
37
38# Determine whether we need to compile the kernel modules, or only the
39# user-space utilities. By default, the kernel modules are compiled.
40#COMPILE_KERNEL := 0
41COMPILE_KERNEL := 1
42
43
44# Uncomment the third line on SMP systems if the magic invocation fails. It
45# is a bit complicated because SMP configuration changed around kernel 2.1.130
46SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \
47                  grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_SMP[[:space:]]*1' $(LINUX_HEADERS)/linux/autoconf.h ; \
48               then echo 1; else echo 0; fi)
49#SMP := 0
50#SMP := 1
51
52# Uncomment the second or third line if the magic invocation fails.
53# We need to know whether CONFIG_MODVERSIONS is defined.
54MODVER := $(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)
55#MODVER := 0
56#MODVER := 1
57
58# This is the directory into which the modules will be installed.
59# The magic invocation will return something like this:
60#   /lib/modules/2.2.15-ac9/misc
61#MODDIR := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`/misc
62#MODPREF := /lib/modules/`grep UTS_RELEASE $(LINUX_HEADERS)/linux/version.h|cut -f 2 -d'"'`
63#MODPREF := /lib/modules/$(KERNELVERSION)
64MODPREF := /lib/modules/$(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release |cut -f 2 -d'"')
65
66# This is the directory into which the header files will be installed.
67# If you want to make sure your current kernel tree is not overwritten,
68# the default should work. This is ignored for the i2c build system.
69LINUX_INCLUDE_DIR := /usr/local/include/linux
70#LINUX_INCLUDE_DIR := $(LINUX_HEADERS)/linux
71
72# If you want to isntall everything at some other place then at which
73# you will run it, DESTDIR defines a prefix used at installation-time.
74DESTDIR :=
75
76# Uncomment the second line if you are a developer. This will enable many
77# additional warnings at compile-time
78WARN := 0
79#WARN := 1
80
81MACHINE := $(shell uname -m)
82
83##################################################
84# Below this, nothing should need to be changed. #
85##################################################
86
87.PHONY: all clean install patch
88
89# Note that this is a monolithic Makefile; it calls no sub-Makefiles,
90# but instead, it compiles everything right from here. Yes, there are
91# some distinct advantages to this; see the following paper for more info:
92#   http://www.tip.net.au/~millerp/rmch/recu-make-cons-harm.html
93# Note that is still uses Makefile fragments in sub-directories; these
94# are called 'Module.mk'.
95
96# Within each Module.mk, rules and dependencies can be added to targets
97# all, install and clean. Use double colons instead of single ones
98# to do this.
99
100# The subdirectories we need to build things in
101SRCDIRS := mkpatch
102ifeq ($(COMPILE_KERNEL),1)
103SRCDIRS += kernel
104endif
105
106# Some often-used commands with default options
107MKDIR := mkdir -p
108RMDIR := rmdir
109RM := rm -f
110CC := gcc
111BISON := bison
112FLEX := flex
113AR := ar
114INSTALL := install
115LN := ln -sfn
116GREP := grep
117
118# Determine the default compiler flags
119# MODCFLAGS is to create in-kernel object files (modules)
120
121CPPFLAGS := -I$(LINUX_HEADERS)
122CFLAGS := -O2 -DLM_SENSORS
123
124ifeq ($(WARN),1)
125CFLAGS += -Wall -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \
126          -Wcast-align -Wwrite-strings -Wnested-externs -Winline
127endif
128
129
130# The -DEXPORT_SYMTAB is to keep the symbol export mechanism quiet.
131MODCFLAGS := $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer \
132             -DEXPORT_SYMTAB
133
134ifeq ($(MACHINE),alpha)
135MODCFLAGS += -ffixed-8
136endif
137
138ifeq ($(MACHINE),x86_64)
139MODCFLAGS += -fno-strict-aliasing -fno-common -fomit-frame-pointer -mno-red-zone\
140             -mcmodel=kernel -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduce
141endif
142
143ifeq ($(SMP),1)
144MODCPPFLAGS += -D__SMP__
145endif
146
147ifeq ($(MODVER),1)
148MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h
149endif
150
151# This magic is from the kernel Makefile.
152# Extra cflags for kbuild 2.4.  The default is to forbid includes by kernel code
153# from user space headers.
154kbuild_2_4_nostdinc := -nostdinc $(shell $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp')
155MODCPPFLAGS += $(CPPFLAGS) $(kbuild_2_4_nostdinc)
156
157.PHONY: dep
158# Make all the default rule
159all::
160
161# Include all makefiles for sub-modules
162INCLUDEFILES :=
163ifneq ($(SRCDIRS),)
164include $(patsubst %,%/Module.mk,$(SRCDIRS))
165endif
166ifneq ($(MAKECMDGOALS),clean)
167ifneq ($(INCLUDEFILES),)
168include $(INCLUDEFILES)
169endif
170endif
171
172# Making the dependency files - done automatically!
173dep :
174
175all ::
176
177install :: all
178
179clean::
180        $(RM) lm_sensors-*
181
182# Here, we define all implicit rules we want to use.
183
184.SUFFIXES:
185
186# We need to create dependency files. Tricky. We sed rule puts dir/file.d and
187# dir/file.c in front of the dependency file rule.
188
189# .o files are used for modules
190%.o: %.c
191        $(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@
192
193%.d: %.c
194        $(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \
195        sed -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@
196
Note: See TracBrowser for help on using the browser.