1VERSION = 2 2PATCHLEVEL = 2 3SUBLEVEL = 26 4EXTRAVERSION = 5 6ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) 7 8.EXPORT_ALL_VARIABLES: 9 10CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 11 else if [ -x /bin/bash ]; then echo /bin/bash; \ 12 else echo sh; fi ; fi) 13TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) 14 15HPATH = $(TOPDIR)/include 16FINDHPATH = $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net 17 18HOSTCC =gcc 19HOSTCFLAGS =-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 20 21CROSS_COMPILE = 22 23AS =$(CROSS_COMPILE)as 24LD =$(CROSS_COMPILE)ld 25# 26# foo-bar-gcc for cross builds 27# gcc272 for Debian's old compiler for kernels 28# kgcc for Conectiva, Mandrake and Red Hat 7 29# otherwise 'cc' 30# 31CC =$(shell if [ -n "$(CROSS_COMPILE)" ]; then echo $(CROSS_COMPILE)gcc; else \ 32 $(CONFIG_SHELL) scripts/kwhich gcc272 2>/dev/null || $(CONFIG_SHELL) scripts/kwhich kgcc 2>/dev/null || echo cc; fi) \ 33 -D__KERNEL__ -I$(HPATH) 34CPP =$(CC) -E 35AR =$(CROSS_COMPILE)ar 36NM =$(CROSS_COMPILE)nm 37STRIP =$(CROSS_COMPILE)strip 38OBJCOPY =$(CROSS_COMPILE)objcopy 39OBJDUMP =$(CROSS_COMPILE)objdump 40MAKE =make 41GENKSYMS=/sbin/genksyms 42 43all: do-it-all 44 45# 46# Make "config" the default target if there is no configuration file or 47# "depend" the target if there is no top-level dependency information. 48# 49ifeq (.config,$(wildcard .config)) 50include .config 51ifeq (.depend,$(wildcard .depend)) 52include .depend 53do-it-all: Version vmlinux 54else 55CONFIGURATION = depend 56do-it-all: depend 57endif 58else 59CONFIGURATION = config 60do-it-all: config 61endif 62 63# 64# ROOT_DEV specifies the default root-device when making the image. 65# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case 66# the default of FLOPPY is used by 'build'. 67# 68 69ROOT_DEV = CURRENT 70 71KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) 72 73# 74# INSTALL_PATH specifies where to place the updated kernel and system map 75# images. Uncomment if you want to place them anywhere other than root. 76 77#INSTALL_PATH=/boot 78 79# 80# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory 81# relocations required by build roots. This is not defined in the 82# makefile but the argument can be passed to make if needed. 83# 84 85# 86# If you want to preset the SVGA mode, uncomment the next line and 87# set SVGA_MODE to whatever number you want. 88# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode. 89# The number is the same as you would ordinarily press at bootup. 90# 91 92SVGA_MODE= -DSVGA_MODE=NORMAL_VGA 93 94# 95# standard CFLAGS 96# 97 98CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 99 100# use '-fno-strict-aliasing', but only if the compiler can take it 101CFLAGS += $(shell if $(CC) -fno-strict-aliasing -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-fno-strict-aliasing"; fi) 102 103ifdef CONFIG_SMP 104CFLAGS += -D__SMP__ 105AFLAGS += -D__SMP__ 106endif 107 108# 109# if you want the RAM disk device, define this to be the 110# size in blocks. 111# 112 113#RAMDISK = -DRAMDISK=512 114 115# Include the make variables (CC, etc...) 116# 117 118CORE_FILES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o 119FILESYSTEMS =fs/filesystems.a 120NETWORKS =net/network.a 121DRIVERS =drivers/block/block.a \ 122 drivers/char/char.o \ 123 drivers/misc/misc.a 124LIBS =$(TOPDIR)/lib/lib.a 125SUBDIRS =kernel drivers mm fs net ipc lib 126 127ifdef CONFIG_NUBUS 128DRIVERS := $(DRIVERS) drivers/nubus/nubus.a 129endif 130 131ifeq ($(CONFIG_ISDN),y) 132DRIVERS := $(DRIVERS) drivers/isdn/isdn.a 133endif 134 135DRIVERS := $(DRIVERS) drivers/net/net.a 136 137ifeq ($(CONFIG_SCSI),y) 138DRIVERS := $(DRIVERS) drivers/scsi/scsi.a 139endif 140 141ifneq ($(CONFIG_CD_NO_IDESCSI)$(CONFIG_BLK_DEV_IDECD)$(CONFIG_BLK_DEV_SR)$(CONFIG_PARIDE_PCD),) 142DRIVERS := $(DRIVERS) drivers/cdrom/cdrom.a 143endif 144 145ifeq ($(CONFIG_SOUND),y) 146DRIVERS := $(DRIVERS) drivers/sound/sounddrivers.o 147endif 148 149ifdef CONFIG_PCI 150DRIVERS := $(DRIVERS) drivers/pci/pci.a 151endif 152 153ifdef CONFIG_DIO 154DRIVERS := $(DRIVERS) drivers/dio/dio.a 155endif 156 157ifdef CONFIG_SBUS 158DRIVERS := $(DRIVERS) drivers/sbus/sbus.a 159endif 160 161ifdef CONFIG_ZORRO 162DRIVERS := $(DRIVERS) drivers/zorro/zorro.a 163endif 164 165ifeq ($(CONFIG_FC4),y) 166DRIVERS := $(DRIVERS) drivers/fc4/fc4.a 167endif 168 169ifeq ($(CONFIG_NET_FC),y) 170DRIVERS := $(DRIVERS) drivers/net/fc/fc.a 171endif 172 173ifdef CONFIG_PPC 174DRIVERS := $(DRIVERS) drivers/macintosh/macintosh.o 175endif 176 177ifdef CONFIG_PNP 178DRIVERS := $(DRIVERS) drivers/pnp/pnp.a 179endif 180 181ifdef CONFIG_SGI 182DRIVERS := $(DRIVERS) drivers/sgi/sgi.a 183endif 184 185ifdef CONFIG_VT 186DRIVERS := $(DRIVERS) drivers/video/video.a 187endif 188 189ifeq ($(CONFIG_PARIDE),y) 190DRIVERS := $(DRIVERS) drivers/block/paride/paride.a 191endif 192 193ifdef CONFIG_HAMRADIO 194DRIVERS := $(DRIVERS) drivers/net/hamradio/hamradio.a 195endif 196 197ifeq ($(CONFIG_TC),y) 198DRIVERS := $(DRIVERS) drivers/tc/tc.a 199endif 200 201ifeq ($(CONFIG_USB),y) 202DRIVERS := $(DRIVERS) drivers/usb/usbdrv.o 203else 204 ifdef CONFIG_INPUT_ADBHID 205 DRIVERS := $(DRIVERS) drivers/usb/usbdrv.o 206 endif 207endif 208 209ifeq ($(CONFIG_I2O),y) 210DRIVERS := $(DRIVERS) drivers/i2o/i2o.a 211endif 212 213ifeq ($(CONFIG_IRDA),y) 214DRIVERS := $(DRIVERS) drivers/net/irda/irda_drivers.a 215endif 216 217ifeq ($(CONFIG_I2O),y) 218DRIVERS := $(DRIVERS) drivers/i2o/i2o.a 219endif 220 221ifeq ($(CONFIG_PHONE),y) 222DRIVERS := $(DRIVERS) drivers/telephony/telephony.a 223endif 224 225include arch/$(ARCH)/Makefile 226 227.S.s: 228 $(CC) -D__ASSEMBLY__ $(AFLAGS) -traditional -E -o $*.s $< 229.S.o: 230 $(CC) -D__ASSEMBLY__ $(AFLAGS) -traditional -c -o $*.o $< 231 232Version: dummy 233 @rm -f include/linux/compile.h 234 235boot: vmlinux 236 @$(MAKE) -C arch/$(ARCH)/boot 237 238vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs 239 $(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \ 240 --start-group \ 241 $(CORE_FILES) \ 242 $(FILESYSTEMS) \ 243 $(NETWORKS) \ 244 $(DRIVERS) \ 245 $(LIBS) \ 246 --end-group \ 247 -o vmlinux 248 $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aU] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map 249 250symlinks: 251 rm -f include/asm 252 ( cd include ; ln -sf asm-$(ARCH) asm) 253 @if [ ! -d modules ]; then \ 254 mkdir modules; \ 255 fi 256 @if [ ! -d include/linux/modules ]; then \ 257 mkdir include/linux/modules; \ 258 fi 259 260oldconfig: symlinks 261 $(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in 262 263xconfig: symlinks 264 $(MAKE) -C scripts kconfig.tk 265 wish -f scripts/kconfig.tk 266 267menuconfig: include/linux/version.h symlinks 268 $(MAKE) -C scripts/lxdialog all 269 $(CONFIG_SHELL) scripts/Menuconfig arch/$(ARCH)/config.in 270 271config: symlinks 272 $(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in 273 274include/config/MARKER: scripts/split-include include/linux/autoconf.h 275 scripts/split-include include/linux/autoconf.h include/config 276 @ touch include/config/MARKER 277 278linuxsubdirs: $(patsubst %, _dir_%, $(SUBDIRS)) 279 280$(patsubst %, _dir_%, $(SUBDIRS)) : dummy include/config/MARKER 281 $(MAKE) -C $(patsubst _dir_%, %, $@) 282 283$(TOPDIR)/include/linux/version.h: include/linux/version.h 284$(TOPDIR)/include/linux/compile.h: include/linux/compile.h 285 286newversion: 287 @if [ ! -f .version ]; then \ 288 echo 1 > .version; \ 289 else \ 290 expr 0`cat .version` + 1 > .version; \ 291 fi 292 293include/linux/compile.h: $(CONFIGURATION) include/linux/version.h newversion 294 @echo -n \#define UTS_VERSION \"\#`cat .version` > .ver 295 @if [ -n "$(CONFIG_SMP)" ] ; then echo -n " SMP" >> .ver; fi 296 @if [ -f .name ]; then echo -n \-`cat .name` >> .ver; fi 297 @echo ' '`LANG=C date`'"' >> .ver 298 @echo \#define LINUX_COMPILE_TIME \"`LANG=C date +%T`\" >> .ver 299 @echo \#define LINUX_COMPILE_BY \"`whoami`\" >> .ver 300 @echo \#define LINUX_COMPILE_HOST \"`hostname`\" >> .ver 301 @if [ -x /bin/dnsdomainname ]; then \ 302 echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname`\"; \ 303 elif [ -x /bin/domainname ]; then \ 304 echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\"; \ 305 else \ 306 echo \#define LINUX_COMPILE_DOMAIN ; \ 307 fi >> .ver 308 @echo \#define LINUX_COMPILER \"`$(CC) $(CFLAGS) -v 2>&1 | tail -1`\" >> .ver 309 @mv -f .ver $@ 310 311include/linux/version.h: ./Makefile 312 @echo \#define UTS_RELEASE \"$(KERNELRELEASE)\" > .ver 313 @echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver 314 @echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' >>.ver 315 @mv -f .ver $@ 316 317init/version.o: init/version.c include/linux/compile.h include/config/MARKER 318 $(CC) $(CFLAGS) -DUTS_MACHINE='"$(ARCH)"' -c -o init/version.o init/version.c 319 320init/main.o: init/main.c include/config/MARKER 321 $(CC) $(CFLAGS) $(PROFILING) -c -o $*.o $< 322 323fs lib mm ipc kernel drivers net: dummy 324 $(MAKE) $(subst $@, _dir_$@, $@) 325 326MODFLAGS += -DMODULE 327ifdef CONFIG_MODULES 328ifdef CONFIG_MODVERSIONS 329MODFLAGS += -DMODVERSIONS -include $(HPATH)/linux/modversions.h 330endif 331 332modules: include/config/MARKER $(patsubst %, _mod_%, $(SUBDIRS)) 333 334$(patsubst %, _mod_%, $(SUBDIRS)) : include/linux/version.h 335 $(MAKE) -C $(patsubst _mod_%, %, $@) CFLAGS="$(CFLAGS) $(MODFLAGS)" MAKING_MODULES=1 modules 336 337modules_install: 338 @( \ 339 MODLIB=$(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE); \ 340 mkdir -p $$MODLIB; \ 341 rm -f $$MODLIB/build; \ 342 [ `/sbin/insmod -V 2>&1 | head -1 | awk '/^insmod version /{split($$3, a, /\./); printf "%d%03d%03d\n", a[1], a[2], a[3];}'`0 -ge 20030140 ] && \ 343 ln -s `pwd` $$MODLIB/build; \ 344 cd modules; \ 345 MODULES=""; \ 346 inst_mod() { These="`cat $$1`"; MODULES="$$MODULES $$These"; \ 347 mkdir -p $$MODLIB/$$2; cp $$These $$MODLIB/$$2; \ 348 echo Installing modules under $$MODLIB/$$2; \ 349 }; \ 350 \ 351 if [ -f BLOCK_MODULES ]; then inst_mod BLOCK_MODULES block; fi; \ 352 if [ -f NET_MODULES ]; then inst_mod NET_MODULES net; fi; \ 353 if [ -f IPV4_MODULES ]; then inst_mod IPV4_MODULES ipv4; fi; \ 354 if [ -f IPV6_MODULES ]; then inst_mod IPV6_MODULES ipv6; fi; \ 355 if [ -f SCSI_MODULES ]; then inst_mod SCSI_MODULES scsi; fi; \ 356 if [ -f FS_MODULES ]; then inst_mod FS_MODULES fs; fi; \ 357 if [ -f NLS_MODULES ]; then inst_mod NLS_MODULES fs; fi; \ 358 if [ -f CDROM_MODULES ]; then inst_mod CDROM_MODULES cdrom; fi; \ 359 if [ -f HAM_MODULES ]; then inst_mod HAM_MODULES net; fi; \ 360 if [ -f SOUND_MODULES ]; then inst_mod SOUND_MODULES sound; fi; \ 361 if [ -f VIDEO_MODULES ]; then inst_mod VIDEO_MODULES video; fi; \ 362 if [ -f FC4_MODULES ]; then inst_mod FC4_MODULES fc4; fi; \ 363 if [ -f IRDA_MODULES ]; then inst_mod IRDA_MODULES net; fi; \ 364 if [ -f USB_MODULES ]; then inst_mod USB_MODULES usb; fi; \ 365 if [ -f USB_SERIAL_MODULES ]; then inst_mod USB_SERIAL_MODULES usb; fi; \ 366 if [ -f SK98LIN_MODULES ]; then inst_mod SK98LIN_MODULES net; fi; \ 367 if [ -f SKFP_MODULES ]; then inst_mod SKFP_MODULES net; fi; \ 368 \ 369 for f in *.o; do [ -r $$f ] && echo $$f; done | sort > $$MODLIB/.allmods; \ 370 echo $$MODULES | tr ' ' '\n' | sort | comm -23 $$MODLIB/.allmods - > $$MODLIB/.misc; \ 371 if [ -s $$MODLIB/.misc ]; then inst_mod $$MODLIB/.misc misc; fi; \ 372 rm -f $$MODLIB/.misc $$MODLIB/.allmods; \ 373 ) 374 375# modules disabled.... 376 377else 378modules modules_install: dummy 379 @echo 380 @echo "The present kernel configuration has modules disabled." 381 @echo "Type 'make config' and enable loadable module support." 382 @echo "Then build a kernel with module support enabled." 383 @echo 384 @exit 1 385endif 386 387clean: archclean 388 rm -f kernel/ksyms.lst include/linux/compile.h 389 rm -f core `find . -name '*.[oas]' ! \( -regex '.*lxdialog/.*' \ 390 -o -regex '.*ksymoops/.*' \) -print` 391 rm -f core `find . -type f -name 'core' -print` 392 rm -f core `find . -name '.*.flags' -print` 393 rm -f vmlinux System.map 394 rm -f .tmp* 395 rm -f drivers/char/consolemap_deftbl.c drivers/video/promcon_tbl.c 396 rm -f drivers/char/conmakehash 397 rm -f drivers/sound/bin2hex drivers/sound/hex2hex 398 if [ -d modules ]; then \ 399 rm -f core `find modules/ -type f -print`; \ 400 fi 401 rm -f submenu* 402 403mrproper: clean archmrproper 404 rm -f include/linux/autoconf.h include/linux/version.h 405 rm -f drivers/net/hamradio/soundmodem/sm_tbl_{afsk1200,afsk2666,fsk9600}.h 406 rm -f drivers/net/hamradio/soundmodem/sm_tbl_{hapn4800,psk4800}.h 407 rm -f drivers/net/hamradio/soundmodem/sm_tbl_{afsk2400_7,afsk2400_8}.h 408 rm -f drivers/net/hamradio/soundmodem/gentbl 409 rm -f drivers/char/hfmodem/gentbl drivers/char/hfmodem/tables.h 410 rm -f drivers/sound/*_boot.h drivers/sound/.*.boot 411 rm -f drivers/sound/msndinit.c 412 rm -f drivers/sound/msndperm.c 413 rm -f drivers/sound/pndsperm.c 414 rm -f drivers/sound/pndspini.c 415 rm -f .version .config* config.in config.old 416 rm -f scripts/tkparse scripts/kconfig.tk scripts/kconfig.tmp 417 rm -f scripts/lxdialog/*.o scripts/lxdialog/lxdialog 418 rm -f scripts/ksymoops/*.o scripts/ksymoops/ksymoops 419 rm -f .menuconfig.log 420 rm -f include/asm 421 rm -rf include/config 422 rm -f .depend `find . -name .depend -print` 423 rm -f core `find . -size 0 -print` 424 rm -f .hdepend scripts/mkdep scripts/split-include 425 rm -f $(TOPDIR)/include/linux/modversions.h 426 rm -rf $(TOPDIR)/include/linux/modules 427 rm -rf modules 428 429distclean: mrproper 430 rm -f core `find . \( -not -type d \) -and \ 431 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ 432 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ 433 -o -name '.*.rej' -o -name '.SUMS' -o -size 0 \) -print` TAGS 434 435backup: mrproper 436 cd .. && tar cf - linux/ | gzip -9 > backup.gz 437 sync 438 439sums: 440 find . -type f -print | sort | xargs sum > .SUMS 441 442dep-files: scripts/mkdep archdep include/linux/version.h new-genksyms 443 scripts/mkdep init/*.c > .depend 444 scripts/mkdep `find $(FINDHPATH) -follow -name \*.h ! -name modversions.h -print` > .hdepend 445# set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep ;done 446# let this be made through the fastdep rule in Rules.make 447 $(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)" 448ifdef CONFIG_MODVERSIONS 449 $(MAKE) update-modverfile 450endif 451 452MODVERFILE := 453 454ifdef CONFIG_MODVERSIONS 455 456MODVERFILE := $(TOPDIR)/include/linux/modversions.h 457 458new-genksyms: 459 @$(GENKSYMS) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) </dev/null \ 460 2>/dev/null || ( echo -e "\nYou need a new version of the genksyms\ 461 program, which is part of\nthe modutils package. Please read the file\ 462 Documentation/Changes\nfor more information.\n"; exit 1 ) 463 464else 465 466new-genksyms: 467 468endif 469 470depend dep: dep-files $(MODVERFILE) 471 472# make checkconfig: Prune 'scripts' directory to avoid "false positives". 473checkconfig: 474 perl -w scripts/checkconfig.pl `find * -path 'scripts' -prune -o -name '*.[hcS]' -print | sort` 475 476checkhelp: 477 perl -w scripts/checkhelp.pl `find * -name [cC]onfig.in -print` 478 479ifdef CONFIGURATION 480..$(CONFIGURATION): 481 @echo 482 @echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'" 483 @echo 484 $(MAKE) $(CONFIGURATION) 485 @echo 486 @echo "Successful. Try re-making (ignore the error that follows)" 487 @echo 488 exit 1 489 490#dummy: ..$(CONFIGURATION) 491dummy: 492 493else 494 495dummy: 496 497endif 498 499include Rules.make 500 501# 502# This generates dependencies for the .h files. 503# 504 505scripts/mkdep: scripts/mkdep.c 506 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c 507 508scripts/split-include: scripts/split-include.c 509 $(HOSTCC) $(HOSTCFLAGS) -o scripts/split-include scripts/split-include.c 510

