| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
KERNELVERSION := $(shell uname -r) |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
LINUX := $(shell if [ -L /lib/modules/$(KERNELVERSION)/build ] ; \ |
|---|
| 34 |
|
|---|
| 35 |
) |
|---|
| 36 |
LINUX_HEADERS := $(LINUX)/include |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
COMPILE_KERNEL := 1 |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
SMP := $(shell if grep -q '^SMP[[:space:]]*=' $(LINUX)/Makefile || \ |
|---|
| 47 |
|
|---|
| 48 |
) |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
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) |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
CC := gcc |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
KERNELVERSION := $(shell $(CC) -I$(LINUX_HEADERS) -E etc/config.c | grep uts_release | cut -f 2 -d'"') |
|---|
| 65 |
MODPREF := /lib/modules/$(KERNELVERSION) |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
ifeq (,$(findstring /2.4., $(MODPREF))) |
|---|
| 69 |
ifeq (, $(MAKECMDGOALS)) |
|---|
| 70 |
$(error For 2.6 kernels and later, you do not need this package) |
|---|
| 71 |
endif |
|---|
| 72 |
ifeq (install, $(MAKECMDGOALS)) |
|---|
| 73 |
$(error For 2.6 kernels and later, you do not need this package) |
|---|
| 74 |
endif |
|---|
| 75 |
endif |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
|
|---|
| 80 |
LINUX_INCLUDE_DIR := /usr/local/include/linux |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 |
DESTDIR := |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
WARN := 0 |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
MACHINE := $(shell uname -m) |
|---|
| 93 |
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
.PHONY: all clean install patch |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
|
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
SRCDIRS := mkpatch |
|---|
| 113 |
ifeq ($(COMPILE_KERNEL),1) |
|---|
| 114 |
SRCDIRS += kernel |
|---|
| 115 |
endif |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
MKDIR := mkdir -p |
|---|
| 119 |
RMDIR := rmdir |
|---|
| 120 |
RM := rm -f |
|---|
| 121 |
BISON := bison |
|---|
| 122 |
FLEX := flex |
|---|
| 123 |
AR := ar |
|---|
| 124 |
INSTALL := install |
|---|
| 125 |
LN := ln -sfn |
|---|
| 126 |
GREP := grep |
|---|
| 127 |
|
|---|
| 128 |
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
CPPFLAGS := -I$(LINUX_HEADERS) |
|---|
| 132 |
CFLAGS := -Wall -O2 |
|---|
| 133 |
|
|---|
| 134 |
ifeq ($(WARN),1) |
|---|
| 135 |
CFLAGS += -W -Wstrict-prototypes -Wshadow -Wpointer-arith -Wcast-qual \ |
|---|
| 136 |
-Wcast-align -Wwrite-strings -Wnested-externs -Winline |
|---|
| 137 |
endif |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
MODCFLAGS := $(CFLAGS) -D__KERNEL__ -DMODULE -fomit-frame-pointer \ |
|---|
| 142 |
-DEXPORT_SYMTAB -fno-strict-aliasing |
|---|
| 143 |
|
|---|
| 144 |
ifeq ($(MACHINE),alpha) |
|---|
| 145 |
MODCFLAGS += -ffixed-8 -mno-fp-regs -mcpu=ev56 |
|---|
| 146 |
endif |
|---|
| 147 |
|
|---|
| 148 |
ifeq ($(MACHINE),x86_64) |
|---|
| 149 |
MODCFLAGS += -fno-common -fomit-frame-pointer -mno-red-zone \ |
|---|
| 150 |
-mcmodel=kernel -fno-reorder-blocks -finline-limit=2000 -fno-strength-reduce |
|---|
| 151 |
endif |
|---|
| 152 |
|
|---|
| 153 |
ifeq ($(MACHINE),mips) |
|---|
| 154 |
MODCFLAGS += -mabi=32 -mips3 -Wa,-32 -Wa,-mips3 -Wa,--trap |
|---|
| 155 |
endif |
|---|
| 156 |
|
|---|
| 157 |
ifeq ($(MACHINE),sparc32) |
|---|
| 158 |
MODCFLAGS += -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 |
|---|
| 159 |
endif |
|---|
| 160 |
|
|---|
| 161 |
ifeq ($(MACHINE),sparc64) |
|---|
| 162 |
MODCFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow \ |
|---|
| 163 |
-ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare \ |
|---|
| 164 |
-Wa,--undeclared-regs |
|---|
| 165 |
endif |
|---|
| 166 |
|
|---|
| 167 |
ifeq ($(SMP),1) |
|---|
| 168 |
MODCPPFLAGS += -D__SMP__ |
|---|
| 169 |
endif |
|---|
| 170 |
|
|---|
| 171 |
ifeq ($(MODVER),1) |
|---|
| 172 |
MODCPPFLAGS += -DMODVERSIONS -include $(LINUX_HEADERS)/linux/modversions.h |
|---|
| 173 |
endif |
|---|
| 174 |
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 |
kbuild_2_4_nostdinc := -nostdinc $(shell LC_ALL=C $(CC) -print-search-dirs | sed -ne 's/install: \(.*\)/-I \1include/gp') |
|---|
| 179 |
MODCPPFLAGS += $(CPPFLAGS) $(kbuild_2_4_nostdinc) |
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
all:: |
|---|
| 183 |
|
|---|
| 184 |
|
|---|
| 185 |
INCLUDEFILES := |
|---|
| 186 |
ifneq ($(SRCDIRS),) |
|---|
| 187 |
include $(patsubst %,%/Module.mk,$(SRCDIRS)) |
|---|
| 188 |
endif |
|---|
| 189 |
ifneq ($(MAKECMDGOALS),clean) |
|---|
| 190 |
include $(INCLUDEFILES) |
|---|
| 191 |
endif |
|---|
| 192 |
|
|---|
| 193 |
all :: |
|---|
| 194 |
ifeq ($(shell if grep -q '^CONFIG_I2C=y' $(LINUX)/.config; then echo 1; fi),1) |
|---|
| 195 |
@echo "*************** WARNING *************************** WARNING ***************" |
|---|
| 196 |
@echo "*** ***" |
|---|
| 197 |
@echo "*** You have I2C support built into your kernel (CONFIG_I2C=y). Unless ***" |
|---|
| 198 |
@echo "*** you know what you are doing, installing our version of i2c will not ***" |
|---|
| 199 |
@echo "*** work. Newly built i2c modules probably won't load. Other modules ***" |
|---|
| 200 |
@echo "*** that rely on the i2c layer, such as lm_sensors, will fail to ***" |
|---|
| 201 |
@echo "*** compile. Please consider compiling your kernel again with I2C ***" |
|---|
| 202 |
@echo "*** support enabled as modules or disabled. ***" |
|---|
| 203 |
@echo "*** ***" |
|---|
| 204 |
@echo "*************** WARNING *************************** WARNING ***************" |
|---|
| 205 |
endif |
|---|
| 206 |
|
|---|
| 207 |
install :: all |
|---|
| 208 |
ifeq ($(DESTDIR),) |
|---|
| 209 |
-if [ -x /sbin/depmod ] ; then \ |
|---|
| 210 |
if [ -r $(MODPREF)/build/System.map ] ; then \ |
|---|
| 211 |
/sbin/depmod -a -F $(MODPREF)/build/System.map $(KERNELVERSION) ; \ |
|---|
| 212 |
elif [ "$(KERNELVERSION)" = "`uname -r`" ] ; then \ |
|---|
| 213 |
/sbin/depmod -a ; \ |
|---|
| 214 |
fi \ |
|---|
| 215 |
fi |
|---|
| 216 |
else |
|---|
| 217 |
@echo "*** This is a \`staged' install using \"$(DESTDIR)\" as prefix." |
|---|
| 218 |
@echo "***" |
|---|
| 219 |
@echo "*** Once the modules have been moved to their final destination" |
|---|
| 220 |
@echo "*** you must run the command \"/sbin/depmod -a\"." |
|---|
| 221 |
@echo "***" |
|---|
| 222 |
@echo "*** Alternatively, if you build a package (e.g. rpm), include the" |
|---|
| 223 |
@echo "*** command \"/sbin/depmod -a\" in the post-(un)install procedure." |
|---|
| 224 |
@echo "***" |
|---|
| 225 |
@echo "*** If the depmod command mentioned above generates errors, you should" |
|---|
| 226 |
@echo "*** pay particular attention to the note #1 below." |
|---|
| 227 |
endif |
|---|
| 228 |
@echo "*** Installation successful!" |
|---|
| 229 |
@echo "*** Important notes:" |
|---|
| 230 |
@echo "*** 1* Compatibility with the Linux 2.4 kernel has been restored." |
|---|
| 231 |
@echo "*** 2* The i2c-elektor and i2c-pcf-epp modules were not built. If you" |
|---|
| 232 |
@echo "*** need them, you have to use compilation option 3 as described in" |
|---|
| 233 |
@echo "*** the INSTALL file." |
|---|
| 234 |
|
|---|
| 235 |
clean:: |
|---|
| 236 |
|
|---|
| 237 |
$(LINUX)/.config: |
|---|
| 238 |
@echo |
|---|
| 239 |
@echo "Error - missing file $(LINUX)/.config !! " |
|---|
| 240 |
@echo " Verify kernel source is in $(LINUX) and then" |
|---|
| 241 |
@echo " cd to $(LINUX) and run 'make config' !!" |
|---|
| 242 |
@echo |
|---|
| 243 |
@echo "Exception: if you're using a stock RedHat/Fedora kernel..." |
|---|
| 244 |
@echo " (1) Install the appropriate kernel-source RPM." |
|---|
| 245 |
@echo " (2) Copy the appropriate config..." |
|---|
| 246 |
@echo " from $(LINUX)/configs/<...>" |
|---|
| 247 |
@echo " to $(LINUX)/.config" |
|---|
| 248 |
@echo " (3) Do *NOT* 'make dep' or 'make config'." |
|---|
| 249 |
@echo |
|---|
| 250 |
@exit 1 |
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
.SUFFIXES: |
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
%.o: %.c $(LINUX)/.config |
|---|
| 262 |
$(CC) $(MODCPPFLAGS) $(MODCFLAGS) -c $< -o $@ |
|---|
| 263 |
|
|---|
| 264 |
%.d: %.c $(LINUX)/.config |
|---|
| 265 |
$(CC) -M -MG $(MODCPPFLAGS) $(MODCFLAGS) $< | \ |
|---|
| 266 |
sed -e 's@^\(.*\)\.o:@$*.d $*.o: Makefile '`dirname $*.d`/Module.mk' @' > $@ |
|---|
| 267 |
|
|---|