1VERSION = 1 2PATCHLEVEL = 2 3SUBLEVEL = 13 4 5ARCH = i386 6 7.EXPORT_ALL_VARIABLES: 8 9CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ 10 else if [ -x /bin/bash ]; then echo /bin/bash; \ 11 else echo sh; fi ; fi) 12TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) 13 14AS =as 15LD =ld 16HOSTCC =gcc -I$(TOPDIR)/include 17CC =gcc -D__KERNEL__ -I$(TOPDIR)/include 18MAKE =make 19CPP =$(CC) -E 20AR =ar 21NM =nm 22STRIP =strip 23 24all: do-it-all 25 26# 27# Make "config" the default target if there is no configuration file or 28# "depend" the target if there is no top-level dependency information. 29# 30ifeq (.config,$(wildcard .config)) 31include .config 32ifeq (.depend,$(wildcard .depend)) 33include .depend 34do-it-all: Version vmlinux 35else 36CONFIGURATION = depend 37do-it-all: depend 38endif 39else 40CONFIGURATION = config 41do-it-all: config 42endif 43 44# 45# ROOT_DEV specifies the default root-device when making the image. 46# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case 47# the default of FLOPPY is used by 'build'. 48# 49 50ROOT_DEV = CURRENT 51 52# 53# INSTALL_PATH specifies where to place the updated kernel and system map 54# images. Uncomment if you want to place them anywhere other than root. 55 56#INSTALL_PATH=/boot 57 58# 59# If you want to preset the SVGA mode, uncomment the next line and 60# set SVGA_MODE to whatever number you want. 61# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode. 62# The number is the same as you would ordinarily press at bootup. 63# 64 65SVGA_MODE= -DSVGA_MODE=NORMAL_VGA 66 67# 68# standard CFLAGS 69# 70 71CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer 72 73ifdef CONFIG_CPP 74CFLAGS := $(CFLAGS) -x c++ 75endif 76 77# 78# if you want the ram-disk device, define this to be the 79# size in blocks. 80# 81 82#RAMDISK = -DRAMDISK=512 83 84# Include the make variables (CC, etc...) 85# 86 87ARCHIVES =kernel/kernel.o mm/mm.o fs/fs.o net/net.o ipc/ipc.o 88FILESYSTEMS =fs/filesystems.a 89DRIVERS =drivers/block/block.a \ 90 drivers/char/char.a \ 91 drivers/net/net.a 92LIBS =$(TOPDIR)/lib/lib.a 93SUBDIRS =kernel drivers mm fs net ipc lib 94 95ifdef CONFIG_SCSI 96DRIVERS := $(DRIVERS) drivers/scsi/scsi.a 97endif 98 99ifdef CONFIG_SOUND 100DRIVERS := $(DRIVERS) drivers/sound/sound.a 101endif 102 103include arch/$(ARCH)/Makefile 104 105.c.s: 106 $(CC) $(CFLAGS) -S -o $*.s $< 107.s.o: 108 $(AS) -o $*.o $< 109.c.o: 110 $(CC) $(CFLAGS) -c -o $*.o $< 111.S.s: 112 $(CC) -D__ASSEMBLY__ -traditional -E -o $*.o $< 113.S.o: 114 $(CC) -D__ASSEMBLY__ -traditional -c -o $*.o $< 115 116Version: dummy 117 rm -f include/linux/version.h 118 119boot: vmlinux 120 @$(MAKE) -C arch/$(ARCH)/boot 121 122vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs 123 $(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \ 124 $(ARCHIVES) \ 125 $(FILESYSTEMS) \ 126 $(DRIVERS) \ 127 $(LIBS) -o vmlinux 128 $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | sort > System.map 129 130symlinks: 131 rm -f include/asm 132 ( cd include ; ln -sf asm-$(ARCH) asm) 133 134oldconfig: symlinks 135 $(CONFIG_SHELL) Configure -d arch/$(ARCH)/config.in 136 137config: symlinks 138 $(CONFIG_SHELL) Configure arch/$(ARCH)/config.in 139 140linuxsubdirs: dummy 141 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done 142 143$(TOPDIR)/include/linux/version.h: include/linux/version.h 144 145newversion: 146 @if [ ! -f .version ]; then \ 147 echo 1 > .version; \ 148 else \ 149 expr `cat .version` + 1 > .version; \ 150 fi 151 152include/linux/version.h: $(CONFIGURATION) Makefile newversion 153 @echo \#define UTS_RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)\" > include/linux/version.h 154 @if [ -f .name ]; then \ 155 echo \#define UTS_VERSION \"\#`cat .version`-`cat .name` `date`\"; \ 156 else \ 157 echo \#define UTS_VERSION \"\#`cat .version` `date`\"; \ 158 fi >> include/linux/version.h 159 @echo \#define LINUX_COMPILE_TIME \"`date +%T`\" >> include/linux/version.h 160 @echo \#define LINUX_COMPILE_BY \"`whoami`\" >> include/linux/version.h 161 @echo \#define LINUX_COMPILE_HOST \"`hostname`\" >> include/linux/version.h 162 @if [ -x /bin/dnsdomainname ]; then \ 163 echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname`\"; \ 164 else \ 165 echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\"; \ 166 fi >> include/linux/version.h 167 @echo \#define LINUX_COMPILER \"`$(HOSTCC) -v 2>&1 | tail -1`\" >> include/linux/version.h 168 @echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> include/linux/version.h 169 170init/version.o: init/version.c include/linux/version.h 171 $(CC) $(CFLAGS) -DUTS_MACHINE='"$(ARCH)"' -c -o init/version.o init/version.c 172 173init/main.o: init/main.c 174 $(CC) $(CFLAGS) $(PROFILING) -c -o $*.o $< 175 176fs: dummy 177 $(MAKE) linuxsubdirs SUBDIRS=fs 178 179lib: dummy 180 $(MAKE) linuxsubdirs SUBDIRS=lib 181 182mm: dummy 183 $(MAKE) linuxsubdirs SUBDIRS=mm 184 185ipc: dummy 186 $(MAKE) linuxsubdirs SUBDIRS=ipc 187 188kernel: dummy 189 $(MAKE) linuxsubdirs SUBDIRS=kernel 190 191drivers: dummy 192 $(MAKE) linuxsubdirs SUBDIRS=drivers 193 194net: dummy 195 $(MAKE) linuxsubdirs SUBDIRS=net 196 197ifdef CONFIG_MODVERSIONS 198MODV = -DCONFIG_MODVERSIONS 199endif 200 201modules: include/linux/version.h 202 @set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i CFLAGS="$(CFLAGS) -DMODULE $(MODV)" modules; done 203 204modules_install: 205 @( \ 206 MODLIB=/lib/modules/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL); \ 207 cd modules; \ 208 MODULES=""; \ 209 inst_mod() { These="`cat $$1`"; MODULES="$$MODULES $$These"; \ 210 mkdir -p $$MODLIB/$$2; cp -p $$These $$MODLIB/$$2; \ 211 echo Installing modules under $$MODLIB/$$2; \ 212 }; \ 213 \ 214 if [ -f NET_MODULES ]; then inst_mod NET_MODULES net; fi; \ 215 if [ -f SCSI_MODULES ]; then inst_mod SCSI_MODULES scsi; fi; \ 216 if [ -f FS_MODULES ]; then inst_mod FS_MODULES fs; fi; \ 217 \ 218 ls *.o > .allmods; \ 219 echo $$MODULES | tr ' ' '\n' | sort | comm -23 .allmods - > .misc; \ 220 if [ -s .misc ]; then inst_mod .misc misc; fi; \ 221 rm -f .misc .allmods; \ 222 ) 223 224clean: archclean 225 rm -f kernel/ksyms.lst 226 rm -f core `find . -name '*.[oas]' -print` 227 rm -f core `find . -name 'core' -print` 228 rm -f vmlinux System.map 229 rm -f .tmp* drivers/sound/configure 230 rm -fr modules/* 231 232mrproper: clean 233 rm -f include/linux/autoconf.h include/linux/version.h 234 rm -f drivers/sound/local.h 235 rm -f .version .config* config.in config.old 236 rm -f include/asm 237 rm -f .depend `find . -name .depend -print` 238ifdef CONFIG_MODVERSIONS 239 rm -f $(TOPDIR)/include/linux/modversions.h 240 rm -f $(TOPDIR)/include/linux/modules/* 241endif 242 243distclean: mrproper 244 245backup: mrproper 246 cd .. && tar cf - linux | gzip -9 > backup.gz 247 sync 248 249depend dep: archdep 250 touch include/linux/version.h 251 for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done > .tmpdepend 252 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i dep; done 253 rm -f include/linux/version.h 254 mv .tmpdepend .depend 255ifdef CONFIG_MODVERSIONS 256 @echo updating $(TOPDIR)/include/linux/modversions.h 257 @(cd $(TOPDIR)/include/linux/modules; for f in *.ver;\ 258 do echo "#include <linux/modules/$${f}>"; done) \ 259 > $(TOPDIR)/include/linux/modversions.h 260endif 261 262ifdef CONFIGURATION 263..$(CONFIGURATION): 264 @echo 265 @echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'" 266 @echo 267 $(MAKE) $(CONFIGURATION) 268 @echo 269 @echo "Successful. Try re-making (ignore the error that follows)" 270 @echo 271 exit 1 272 273dummy: ..$(CONFIGURATION) 274 275else 276 277dummy: 278 279endif 280

