root/i2c/trunk/Makefile @ 3545

Revision 3545, 6.3 KB (checked in by mds, 12 years ago)

alpha arch. recognition from Oleg Vdovikin <vdovikin@…>

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