1VERSION = 1 2PATCHLEVEL = 3 3SUBLEVEL = 0 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 103ifdef CONFIG_PCI 104DRIVERS := $(DRIVERS) drivers/pci/pci.a 105endif 106 107include arch/$(ARCH)/Makefile 108 109.c.s: 110 $(CC) $(CFLAGS) -S -o $*.s $< 111.s.o: 112 $(AS) -o $*.o $< 113.c.o: 114 $(CC) $(CFLAGS) -c -o $*.o $< 115.S.s: 116 $(CC) -D__ASSEMBLY__ -traditional -E -o $*.o $< 117.S.o: 118 $(CC) -D__ASSEMBLY__ -traditional -c -o $*.o $< 119 120Version: dummy 121 rm -f include/linux/version.h 122 123boot: vmlinux 124 @$(MAKE) -C arch/$(ARCH)/boot 125 126vmlinux: $(CONFIGURATION) init/main.o init/version.o linuxsubdirs 127 $(LD) $(LINKFLAGS) $(HEAD) init/main.o init/version.o \ 128 $(ARCHIVES) \ 129 $(FILESYSTEMS) \ 130 $(DRIVERS) \ 131 $(LIBS) -o vmlinux 132 $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | sort > System.map 133 134symlinks: 135 rm -f include/asm 136 ( cd include ; ln -sf asm-$(ARCH) asm) 137 138oldconfig: symlinks 139 $(CONFIG_SHELL) Configure -d arch/$(ARCH)/config.in 140 141config: symlinks 142 $(CONFIG_SHELL) Configure arch/$(ARCH)/config.in 143 144linuxsubdirs: dummy 145 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done 146 147$(TOPDIR)/include/linux/version.h: include/linux/version.h 148 149newversion: 150 @if [ ! -f .version ]; then \ 151 echo 1 > .version; \ 152 else \ 153 expr `cat .version` + 1 > .version; \ 154 fi 155 156include/linux/version.h: $(CONFIGURATION) Makefile newversion 157 @echo \#define UTS_RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)\" > include/linux/version.h 158 @if [ -f .name ]; then \ 159 echo \#define UTS_VERSION \"\#`cat .version`-`cat .name` `date`\"; \ 160 else \ 161 echo \#define UTS_VERSION \"\#`cat .version` `date`\"; \ 162 fi >> include/linux/version.h 163 @echo \#define LINUX_COMPILE_TIME \"`date +%T`\" >> include/linux/version.h 164 @echo \#define LINUX_COMPILE_BY \"`whoami`\" >> include/linux/version.h 165 @echo \#define LINUX_COMPILE_HOST \"`hostname`\" >> include/linux/version.h 166 @if [ -x /bin/dnsdomainname ]; then \ 167 echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname`\"; \ 168 else \ 169 echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\"; \ 170 fi >> include/linux/version.h 171 @echo \#define LINUX_COMPILER \"`$(HOSTCC) -v 2>&1 | tail -1`\" >> include/linux/version.h 172 @echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> include/linux/version.h 173 174init/version.o: init/version.c include/linux/version.h 175 $(CC) $(CFLAGS) -DUTS_MACHINE='"$(ARCH)"' -c -o init/version.o init/version.c 176 177init/main.o: init/main.c 178 $(CC) $(CFLAGS) $(PROFILING) -c -o $*.o $< 179 180fs: dummy 181 $(MAKE) linuxsubdirs SUBDIRS=fs 182 183lib: dummy 184 $(MAKE) linuxsubdirs SUBDIRS=lib 185 186mm: dummy 187 $(MAKE) linuxsubdirs SUBDIRS=mm 188 189ipc: dummy 190 $(MAKE) linuxsubdirs SUBDIRS=ipc 191 192kernel: dummy 193 $(MAKE) linuxsubdirs SUBDIRS=kernel 194 195drivers: dummy 196 $(MAKE) linuxsubdirs SUBDIRS=drivers 197 198net: dummy 199 $(MAKE) linuxsubdirs SUBDIRS=net 200 201ifdef CONFIG_MODVERSIONS 202MODV = -DCONFIG_MODVERSIONS 203endif 204 205modules: include/linux/version.h 206 @set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i CFLAGS="$(CFLAGS) -DMODULE $(MODV)" modules; done 207 208modules_install: 209 @( \ 210 MODLIB=/lib/modules/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL); \ 211 cd modules; \ 212 MODULES=""; \ 213 inst_mod() { These="`cat $$1`"; MODULES="$$MODULES $$These"; \ 214 mkdir -p $$MODLIB/$$2; cp -p $$These $$MODLIB/$$2; \ 215 echo Installing modules under $$MODLIB/$$2; \ 216 }; \ 217 \ 218 if [ -f NET_MODULES ]; then inst_mod NET_MODULES net; fi; \ 219 if [ -f SCSI_MODULES ]; then inst_mod SCSI_MODULES scsi; fi; \ 220 if [ -f FS_MODULES ]; then inst_mod FS_MODULES fs; fi; \ 221 \ 222 ls *.o > .allmods; \ 223 echo $$MODULES | tr ' ' '\n' | sort | comm -23 .allmods - > .misc; \ 224 if [ -s .misc ]; then inst_mod .misc misc; fi; \ 225 rm -f .misc .allmods; \ 226 ) 227 228clean: archclean 229 rm -f kernel/ksyms.lst 230 rm -f core `find . -name '*.[oas]' -print` 231 rm -f core `find . -type f -name 'core' -print` 232 rm -f vmlinux System.map 233 rm -f .tmp* drivers/sound/configure 234 rm -fr modules/* 235 236mrproper: clean 237 rm -f include/linux/autoconf.h include/linux/version.h 238 rm -f drivers/sound/local.h 239 rm -f .version .config* config.in config.old 240 rm -f include/asm 241 rm -f .depend `find . -name .depend -print` 242ifdef CONFIG_MODVERSIONS 243 rm -f $(TOPDIR)/include/linux/modversions.h 244 rm -f $(TOPDIR)/include/linux/modules/* 245endif 246 247distclean: mrproper 248 249backup: mrproper 250 cd .. && tar cf - linux | gzip -9 > backup.gz 251 sync 252 253depend dep: archdep 254 touch include/linux/version.h 255 for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done > .tmpdepend 256 set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i dep; done 257 rm -f include/linux/version.h 258 mv .tmpdepend .depend 259ifdef CONFIG_MODVERSIONS 260 @echo updating $(TOPDIR)/include/linux/modversions.h 261 @(cd $(TOPDIR)/include/linux/modules; for f in *.ver;\ 262 do echo "#include <linux/modules/$${f}>"; done) \ 263 > $(TOPDIR)/include/linux/modversions.h 264endif 265 266ifdef CONFIGURATION 267..$(CONFIGURATION): 268 @echo 269 @echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'" 270 @echo 271 $(MAKE) $(CONFIGURATION) 272 @echo 273 @echo "Successful. Try re-making (ignore the error that follows)" 274 @echo 275 exit 1 276 277dummy: ..$(CONFIGURATION) 278 279else 280 281dummy: 282 283endif 284

