1VERSION = 2 2PATCHLEVEL = 1 3SUBLEVEL = 57 4 5ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/) 6 7# 8# For SMP kernels, set this. We don't want to have this in the config file 9# because it makes re-config very ugly and too many fundamental files depend 10# on "CONFIG_SMP" 11# 12# NOTE! SMP is experimental. See the file Documentation/SMP.txt 13# 14SMP = 1 15# 16# SMP profiling options 17# SMP_PROF = 1 18 19.EXPORT_ALL_VARIABLES: 20 21CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 22 else if [ -x /bin/bash ]; then echo /bin/bash; \ 23 else echo sh; fi ; fi) 24TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) 25 26HPATH = $(TOPDIR)/include 27FINDHPATH = $(HPATH)/asm $(HPATH)/linux $(HPATH)/scsi $(HPATH)/net 28 29HOSTCC =gcc 30HOSTCFLAGS =-O2 -fomit-frame-pointer 31 32CROSS_COMPILE = 33 34AS =$(CROSS_COMPILE)as 35LD =$(CROSS_COMPILE)ld 36CC =$(CROSS_COMPILE)gcc -D__KERNEL__ -I$(HPATH) 37CPP =$(CC) -E 38AR =$(CROSS_COMPILE)ar 39NM =$(CROSS_COMPILE)nm 40STRIP =$(CROSS_COMPILE)strip 41MAKE =make 42GENKSYMS=/sbin/genksyms 43 44all: do-it-all 45 46# 47# Make "config" the default target if there is no configuration file or 48# "depend" the target if there is no top-level dependency information. 49# 50ifeq (.config,$(wildcard .config)) 51include .config 52ifeq (.depend,$(wildcard .depend)) 53include .depend 54do-it-all: Version vmlinux 55else 56CONFIGURATION = depend 57do-it-all: depend 58endif 59else 60CONFIGURATION = config 61do-it-all: config 62endif 63 64# 65# ROOT_DEV specifies the default root-device when making the image. 66# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case 67# the default of FLOPPY is used by 'build'. 68# 69 70ROOT_DEV = CURRENT 71 72# 73# INSTALL_PATH specifies where to place the updated kernel and system map 74# images. Uncomment if you want to place them anywhere other than root. 75 76#INSTALL_PATH=/boot 77 78# 79# If you want to preset the SVGA mode, uncomment the next line and 80# set SVGA_MODE to whatever number you want. 81# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode. 82# The number is the same as you would ordinarily press at bootup. 83# 84 85SVGA_MODE= -DSVGA_MODE=NORMAL_VGA 86 87# 88# standard CFLAGS 89# 90 91CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 92 93ifdef CONFIG_CPP 94CFLAGS := $(CFLAGS) -x c++ 95endif 96 97ifdef SMP 98CFLAGS += -D__SMP__ 99AFLAGS += -D__SMP__ 100 101ifdef SMP_PROF 102CFLAGS += -D__SMP_PROF__ 103AFLAGS += -D__SMP_PROF__ 104endif 105endif 106 107# 108# if you want the ram-disk device, define this to be the 109# size in blocks. 110# 111 112#RAMDISK = -DRAMDISK=512 113 114# Include the make variables (CC, etc...) 115# 116 117CORE_FILES =kernel/kernel.o mm/mm.o fs/fs.o ipc/ipc.o 118FILESYSTEMS =fs/filesystems.a 119NETWORKS =net/network.a 120DRIVERS =drivers/block/block.a \ 121 drivers/char/char.a \ 122 drivers/misc/misc.a 123LIBS =$(TOPDIR)/lib/lib.a 124SUBDIRS =kernel drivers mm fs net ipc lib 125 126ifeq ($(CONFIG_ISDN),y) 127DRIVERS := $(DRIVERS) drivers/isdn/isdn.a 128endif 129 130DRIVERS := $(DRIVERS) drivers/net/net.a 131 132ifeq ($(CONFIG_SCSI),y) 133DRIVERS := $(DRIVERS) drivers/scsi/scsi.a 134endif 135 136ifneq ($(CONFIG_CD_NO_IDESCSI)$(CONFIG_BLK_DEV_IDECD)$(CONFIG_BLK_DEV_SR),) 137DRIVERS := $(DRIVERS) drivers/cdrom/cdrom.a 138endif 139 140ifeq ($(CONFIG_SOUND),y) 141DRIVERS := $(DRIVERS) drivers/sound/sound.a 142endif 143 144ifdef CONFIG_PCI 145DRIVERS := $(DRIVERS) drivers/pci/pci.a 146endif 147 148ifdef CONFIG_SBUS 149DRIVERS := $(DRIVERS) drivers/sbus/sbus.a 150endif 151 152ifdef CONFIG_PPC 153DRIVERS := $(DRIVERS) drivers/macintosh/macintosh.a 154endif 155 156ifdef CONFIG_PNP 157DRIVERS := $(DRIVERS) drivers/pnp/pnp.a 158endif 159 160include arch/$(ARCH)/Makefile 161 162ifdef SMP 163 164.S.s: 165 $(CC) -D__ASSEMBLY__ $(AFLAGS) -traditional -E -o $*.s $< 166.S.o: 167 $(CC) -D__ASSEMBLY__ $(AFLAGS) -traditional -c -o $*.o $< 168 169else 170 171.S.s: 172 $(CC) -D__ASSEMBLY__ -traditional -E -o $*.s $< 173.S.o: 174 $(CC) -D__ASSEMBLY__ -traditional -c -o $*.o $< 175 176endif 177 178Version: dummy 179 @rm -f include/linux/compile.h 180 181boot: vmlinux 182 @$(MAKE) -C arch/$(ARCH)/boot 183 184vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs 185 $(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \ 186 $(CORE_FILES) \ 187 $(FILESYSTEMS) \ 188 $(NETWORKS) \ 189 $(DRIVERS) \ 190 $(LIBS) \ 191 -o vmlinux 192 $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aU] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map 193 194symlinks: 195 rm -f include/asm 196 ( cd include ; ln -sf asm-$(ARCH) asm) 197 @if [ ! -d modules ]; then \ 198 mkdir modules; \ 199 fi 200 @if [ ! -d include/linux/modules ]; then \ 201 mkdir include/linux/modules; \ 202 fi 203 204oldconfig: symlinks 205 $(MAKE) -C drivers/sound mkscript 206 $(CONFIG_SHELL) scripts/Configure -d arch/$(ARCH)/config.in 207 208xconfig: symlinks 209 $(MAKE) -C scripts kconfig.tk 210 wish -f scripts/kconfig.tk 211 212menuconfig: include/linux/version.h symlinks 213 $(MAKE) -C scripts/lxdialog all 214 $(CONFIG_SHELL) scripts/Menuconfig arch/$(ARCH)/config.in 215 216config: symlinks 217 $(CONFIG_SHELL) scripts/Configure arch/$(ARCH)/config.in 218 219linuxsubdirs: dummy 220 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done 221 222$(TOPDIR)/include/linux/version.h: include/linux/version.h 223$(TOPDIR)/include/linux/compile.h: include/linux/compile.h 224 225newversion: 226 @if [ ! -f .version ]; then \ 227 echo 1 > .version; \ 228 else \ 229 expr 0`cat .version` + 1 > .version; \ 230 fi 231 232include/linux/compile.h: $(CONFIGURATION) include/linux/version.h newversion 233 @if [ -f .name ]; then \ 234 echo \#define UTS_VERSION \"\#`cat .version`-`cat .name` `date`\"; \ 235 else \ 236 echo \#define UTS_VERSION \"\#`cat .version` `date`\"; \ 237 fi >> .ver 238 @echo \#define LINUX_COMPILE_TIME \"`date +%T`\" >> .ver 239 @echo \#define LINUX_COMPILE_BY \"`whoami`\" >> .ver 240 @echo \#define LINUX_COMPILE_HOST \"`hostname`\" >> .ver 241 @if [ -x /bin/dnsdomainname ]; then \ 242 echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname`\"; \ 243 elif [ -x /bin/domainname ]; then \ 244 echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\"; \ 245 else \ 246 echo \#define LINUX_COMPILE_DOMAIN ; \ 247 fi >> .ver 248 @echo \#define LINUX_COMPILER \"`$(CC) -v 2>&1 | tail -1`\" >> .ver 249 @mv -f .ver $@ 250 251include/linux/version.h: ./Makefile 252 @echo \#define UTS_RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)\" > .ver 253 @echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver 254 @mv -f .ver $@ 255 256init/version.o: init/version.c include/linux/compile.h 257 $(CC) $(CFLAGS) -DUTS_MACHINE='"$(ARCH)"' -c -o init/version.o init/version.c 258 259init/main.o: init/main.c 260 $(CC) $(CFLAGS) $(PROFILING) -c -o $*.o $< 261 262fs: dummy 263 $(MAKE) linuxsubdirs SUBDIRS=fs 264 265lib: dummy 266 $(MAKE) linuxsubdirs SUBDIRS=lib 267 268mm: dummy 269 $(MAKE) linuxsubdirs SUBDIRS=mm 270 271ipc: dummy 272 $(MAKE) linuxsubdirs SUBDIRS=ipc 273 274kernel: dummy 275 $(MAKE) linuxsubdirs SUBDIRS=kernel 276 277drivers: dummy 278 $(MAKE) linuxsubdirs SUBDIRS=drivers 279 280net: dummy 281 $(MAKE) linuxsubdirs SUBDIRS=net 282 283MODFLAGS = -DMODULE 284ifdef CONFIG_MODULES 285ifdef CONFIG_MODVERSIONS 286MODFLAGS += -DMODVERSIONS -include $(HPATH)/linux/modversions.h 287endif 288 289modules: include/linux/version.h 290 @set -e; \ 291 for i in $(SUBDIRS); \ 292 do $(MAKE) -C $$i CFLAGS="$(CFLAGS) $(MODFLAGS)" MAKING_MODULES=1 modules; \ 293 done 294 295modules_install: 296 @( \ 297 MODLIB=/lib/modules/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL); \ 298 cd modules; \ 299 MODULES=""; \ 300 inst_mod() { These="`cat $$1`"; MODULES="$$MODULES $$These"; \ 301 mkdir -p $$MODLIB/$$2; cp -p $$These $$MODLIB/$$2; \ 302 echo Installing modules under $$MODLIB/$$2; \ 303 }; \ 304 \ 305 if [ -f BLOCK_MODULES ]; then inst_mod BLOCK_MODULES block; fi; \ 306 if [ -f NET_MODULES ]; then inst_mod NET_MODULES net; fi; \ 307 if [ -f IPV4_MODULES ]; then inst_mod IPV4_MODULES ipv4; fi; \ 308 if [ -f IPV6_MODULES ]; then inst_mod IPV6_MODULES ipv6; fi; \ 309 if [ -f SCSI_MODULES ]; then inst_mod SCSI_MODULES scsi; fi; \ 310 if [ -f FS_MODULES ]; then inst_mod FS_MODULES fs; fi; \ 311 if [ -f CDROM_MODULES ]; then inst_mod CDROM_MODULES cdrom; fi; \ 312 \ 313 ls *.o > .allmods; \ 314 echo $$MODULES | tr ' ' '\n' | sort | comm -23 .allmods - > .misc; \ 315 if [ -s .misc ]; then inst_mod .misc misc; fi; \ 316 rm -f .misc .allmods; \ 317 ) 318 319# modules disabled.... 320 321else 322modules modules_install: dummy 323 @echo 324 @echo "The present kernel configuration has modules disabled." 325 @echo "Type 'make config' and enable loadable module support." 326 @echo "Then build a kernel with module support enabled." 327 @echo 328 @exit 1 329endif 330 331clean: archclean 332 rm -f kernel/ksyms.lst include/linux/compile.h 333 rm -f core `find . -name '*.[oas]' ! -regex '.*lxdialog/.*' -print` 334 rm -f core `find . -type f -name 'core' -print` 335 rm -f vmlinux System.map 336 rm -f .tmp* drivers/sound/configure 337 rm -f drivers/char/consolemap_deftbl.c drivers/char/conmakehash 338 rm -f `find modules/ -type f -print` 339 rm -f submenu* 340 341mrproper: clean 342 rm -f include/linux/autoconf.h include/linux/version.h 343 rm -f drivers/sound/local.h drivers/sound/.defines 344 rm -f drivers/net/soundmodem/sm_tbl_{afsk1200,afsk2666,fsk9600}.h 345 rm -f drivers/net/soundmodem/sm_tbl_{hapn4800,psk4800}.h 346 rm -f drivers/net/soundmodem/sm_tbl_{afsk2400_7,afsk2400_8}.h 347 rm -f drivers/net/soundmodem/gentbl 348 rm -f drivers/char/hfmodem/gentbl drivers/char/hfmodem/tables.h 349 rm -f .version .config* config.in config.old 350 rm -f scripts/tkparse scripts/kconfig.tk scripts/kconfig.tmp 351 rm -f scripts/lxdialog/*.o scripts/lxdialog/lxdialog 352 rm -f .menuconfig .menuconfig.log 353 rm -f include/asm 354 rm -f .depend `find . -name .depend -print` 355 rm -f .hdepend scripts/mkdep 356 rm -f $(TOPDIR)/include/linux/modversions.h 357 rm -rf $(TOPDIR)/include/linux/modules 358 rm -rf modules 359 360distclean: mrproper 361 rm -f core `find . \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ 362 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ 363 -o -name '.*.rej' -o -name '.SUMS' -o -size 0 \) -print` TAGS 364 rm -f drivers/sound/Config.in 365 cp drivers/sound/Config.std drivers/sound/Config.in 366 367backup: mrproper 368 cd .. && tar cf - linux/ | gzip -9 > backup.gz 369 sync 370 371sums: 372 find . -type f -print | sort | xargs sum > .SUMS 373 374dep-files: scripts/mkdep archdep include/linux/version.h 375 scripts/mkdep init/*.c > .tmpdepend 376 scripts/mkdep `find $(FINDHPATH) -follow -name \*.h ! -name modversions.h -print` > .hdepend 377 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep; done 378 mv .tmpdepend .depend 379 380MODVERFILE := 381 382ifdef CONFIG_MODVERSIONS 383MODVERFILE := $(TOPDIR)/include/linux/modversions.h 384endif 385 386depend dep: dep-files $(MODVERFILE) 387 388ifdef CONFIGURATION 389..$(CONFIGURATION): 390 @echo 391 @echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'" 392 @echo 393 $(MAKE) $(CONFIGURATION) 394 @echo 395 @echo "Successful. Try re-making (ignore the error that follows)" 396 @echo 397 exit 1 398 399#dummy: ..$(CONFIGURATION) 400dummy: 401 402else 403 404dummy: 405 406endif 407 408include Rules.make 409 410# 411# This generates dependencies for the .h files. 412# 413 414scripts/mkdep: scripts/mkdep.c 415 $(HOSTCC) $(HOSTCFLAGS) -o scripts/mkdep scripts/mkdep.c 416

