Makefile 7.05 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1
VERSION = 1
Linus Torvalds's avatar
Linus Torvalds committed
2
PATCHLEVEL = 1
Linus Torvalds's avatar
Linus Torvalds committed
3
SUBLEVEL = 25
4

5
all:	Version zImage
6

7 8
.EXPORT_ALL_VARIABLES:

9
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
10 11
	  else if [ -x /bin/bash ]; then echo /bin/bash; \
	  else echo sh; fi ; fi)
Linus Torvalds's avatar
Linus Torvalds committed
12
TOPDIR	:= $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
13

14
#
15 16
# Make "config" the default target if there is no configuration file or
# "depend" the target if there is no top-level dependency information.
17 18
#
ifeq (.config,$(wildcard .config))
19
include .config
20 21 22 23 24
ifeq (.depend,$(wildcard .depend))
include .depend
else
CONFIGURATION = depend
endif
25 26 27
else
CONFIGURATION = config
endif
28

29 30 31 32
ifdef CONFIGURATION
CONFIGURE = dummy
endif

33
#
34
# ROOT_DEV specifies the default root-device when making the image.
35 36
# This can be either FLOPPY, CURRENT, /dev/xxxx or empty, in which case
# the default of FLOPPY is used by 'build'.
37 38
#

39
ROOT_DEV = CURRENT
40

Linus Torvalds's avatar
Linus Torvalds committed
41 42 43 44 45 46
#
# INSTALL_PATH specifies where to place the updated kernel and system map
# images.  Uncomment if you want to place them anywhere other than root.

#INSTALL_PATH=/boot

47 48 49 50 51 52 53
#
# If you want to preset the SVGA mode, uncomment the next line and
# set SVGA_MODE to whatever number you want.
# Set it to -DSVGA_MODE=NORMAL_VGA if you just want the EGA/VGA mode.
# The number is the same as you would ordinarily press at bootup.
#

Linus Torvalds's avatar
Linus Torvalds committed
54
SVGA_MODE=	-DSVGA_MODE=NORMAL_VGA
55

56
#
57
# standard CFLAGS
58 59
#

Linus Torvalds's avatar
Linus Torvalds committed
60
CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe
Linus Torvalds's avatar
Linus Torvalds committed
61 62 63 64

ifdef CONFIG_CPP
CFLAGS := $(CFLAGS) -x c++
endif
65

66 67
ifdef CONFIG_M486
CFLAGS := $(CFLAGS) -m486
68 69
else
CFLAGS := $(CFLAGS) -m386
70 71
endif

72 73 74 75
#
# if you want the ram-disk device, define this to be the
# size in blocks.
#
76

77
#RAMDISK = -DRAMDISK=512
78

79 80
AS86	=as86 -0 -a
LD86	=ld86 -0
81

82 83
AS	=as
LD	=ld
Linus Torvalds's avatar
Linus Torvalds committed
84
LDFLAGS	=#-qmagic
85
HOSTCC	=gcc
Linus Torvalds's avatar
Linus Torvalds committed
86
CC	=gcc -D__KERNEL__ -I$(TOPDIR)/include
87
MAKE	=make
88
CPP	=$(CC) -E
89
AR	=ar
90
STRIP	=strip
91

92
ARCHIVES	=kernel/kernel.o mm/mm.o fs/fs.o net/net.o ipc/ipc.o
93
FILESYSTEMS	=fs/filesystems.a
Linus Torvalds's avatar
Linus Torvalds committed
94 95 96
DRIVERS		=drivers/block/block.a \
		 drivers/char/char.a \
		 drivers/net/net.a \
97
		 ibcs/ibcs.o
98
LIBS		=lib/lib.a
Linus Torvalds's avatar
Linus Torvalds committed
99
SUBDIRS		=kernel drivers mm fs net ipc ibcs lib
100 101

KERNELHDRS	=/usr/src/linux/include
102

Linus Torvalds's avatar
Linus Torvalds committed
103 104 105 106 107 108 109 110 111 112 113 114
ifdef CONFIG_SCSI
DRIVERS := $(DRIVERS) drivers/scsi/scsi.a
endif

ifdef CONFIG_SOUND
DRIVERS := $(DRIVERS) drivers/sound/sound.a
endif

ifdef CONFIG_MATH_EMULATION
DRIVERS := $(DRIVERS) drivers/FPU-emu/math.a
endif

115
.c.s:
116
	$(CC) $(CFLAGS) -S -o $*.s $<
117 118 119
.s.o:
	$(AS) -c -o $*.o $<
.c.o:
120
	$(CC) $(CFLAGS) -c -o $*.o $<
121

122
Version: dummy
123
	rm -f tools/version.h
124

Linus Torvalds's avatar
Linus Torvalds committed
125 126 127
oldconfig:
	$(CONFIG_SHELL) Configure -d $(OPTS)

128
config:
Linus Torvalds's avatar
Linus Torvalds committed
129
	$(CONFIG_SHELL) Configure $(OPTS)
130

131
linuxsubdirs: dummy
132
	set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
133

134 135
tools/./version.h: tools/version.h

136
tools/version.h: $(CONFIGURE) Makefile
137
	@./makever.sh
Linus Torvalds's avatar
Linus Torvalds committed
138
	@echo \#define UTS_RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)\" > tools/version.h
139
	@echo \#define UTS_VERSION \"\#`cat .version` `date`\" >> tools/version.h
140 141 142
	@echo \#define LINUX_COMPILE_TIME \"`date +%T`\" >> tools/version.h
	@echo \#define LINUX_COMPILE_BY \"`whoami`\" >> tools/version.h
	@echo \#define LINUX_COMPILE_HOST \"`hostname`\" >> tools/version.h
143
	@echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\" >> tools/version.h
144

Linus Torvalds's avatar
Linus Torvalds committed
145 146
tools/build: tools/build.c $(CONFIGURE)
	$(HOSTCC) $(CFLAGS) -o $@ $<
147

148
boot/head.o: $(CONFIGURE) boot/head.s
149

Linus Torvalds's avatar
Linus Torvalds committed
150 151
boot/head.s: boot/head.S $(CONFIGURE) include/linux/tasks.h
	$(CPP) -traditional $< -o $@
152

153 154
tools/version.o: tools/version.c tools/version.h

155
init/main.o: $(CONFIGURE) init/main.c
156 157
	$(CC) $(CFLAGS) $(PROFILING) -c -o $*.o $<

158
tools/system:	boot/head.o init/main.o tools/version.o linuxsubdirs
Linus Torvalds's avatar
Linus Torvalds committed
159
	$(LD) $(LDFLAGS) -Ttext 1000 boot/head.o init/main.o tools/version.o \
160 161 162 163
		$(ARCHIVES) \
		$(FILESYSTEMS) \
		$(DRIVERS) \
		$(LIBS) \
Linus Torvalds's avatar
Linus Torvalds committed
164 165 166
		-o tools/system
	nm tools/zSystem | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | \
		sort > System.map
167

Linus Torvalds's avatar
Linus Torvalds committed
168 169
boot/setup: boot/setup.o
	$(LD86) -s -o $@ $<
170

Linus Torvalds's avatar
Linus Torvalds committed
171 172
boot/setup.o: boot/setup.s
	$(AS86) -o $@ $<
173

Linus Torvalds's avatar
Linus Torvalds committed
174 175
boot/setup.s: boot/setup.S $(CONFIGURE) include/linux/config.h Makefile
	$(CPP) -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@
176

Linus Torvalds's avatar
Linus Torvalds committed
177 178 179 180 181 182 183 184
boot/bootsect: boot/bootsect.o
	$(LD86) -s -o $@ $<

boot/bootsect.o: boot/bootsect.s
	$(AS86) -o $@ $<

boot/bootsect.s: boot/bootsect.S $(CONFIGURE) include/linux/config.h Makefile
	$(CPP) -traditional $(SVGA_MODE) $(RAMDISK) $< -o $@
185

186
zBoot/zSystem: zBoot/*.c zBoot/*.S tools/zSystem
187
	$(MAKE) -C zBoot
188 189

zImage: $(CONFIGURE) boot/bootsect boot/setup zBoot/zSystem tools/build
190
	tools/build boot/bootsect boot/setup zBoot/zSystem $(ROOT_DEV) > zImage
191 192 193 194 195 196
	sync

zdisk: zImage
	dd bs=8192 if=zImage of=/dev/fd0

zlilo: $(CONFIGURE) zImage
Linus Torvalds's avatar
Linus Torvalds committed
197 198 199 200
	if [ -f $(INSTALL_PATH)/vmlinuz ]; then mv $(INSTALL_PATH)/vmlinuz $(INSTALL_PATH)/vmlinuz.old; fi
	if [ -f $(INSTALL_PATH)/zSystem.map ]; then mv $(INSTALL_PATH)/zSystem.map $(INSTALL_PATH)/zSystem.old; fi
	cat zImage > $(INSTALL_PATH)/vmlinuz
	cp zSystem.map $(INSTALL_PATH)/
Linus Torvalds's avatar
Linus Torvalds committed
201
	if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
202 203

tools/zSystem:	boot/head.o init/main.o tools/version.o linuxsubdirs
Linus Torvalds's avatar
Linus Torvalds committed
204
	$(LD) $(LDFLAGS) -Ttext 100000 boot/head.o init/main.o tools/version.o \
205 206 207 208
		$(ARCHIVES) \
		$(FILESYSTEMS) \
		$(DRIVERS) \
		$(LIBS) \
Linus Torvalds's avatar
Linus Torvalds committed
209 210 211
		-o tools/zSystem
	nm tools/zSystem | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | \
		sort > zSystem.map
212

213 214 215
fs: dummy
	$(MAKE) linuxsubdirs SUBDIRS=fs

216 217 218
lib: dummy
	$(MAKE) linuxsubdirs SUBDIRS=lib

219 220 221
mm: dummy
	$(MAKE) linuxsubdirs SUBDIRS=mm

Linus Torvalds's avatar
Linus Torvalds committed
222 223 224
ipc: dummy
	$(MAKE) linuxsubdirs SUBDIRS=ipc

225 226 227
kernel: dummy
	$(MAKE) linuxsubdirs SUBDIRS=kernel

Linus Torvalds's avatar
Linus Torvalds committed
228 229 230
drivers: dummy
	$(MAKE) linuxsubdirs SUBDIRS=drivers

231 232 233
net: dummy
	$(MAKE) linuxsubdirs SUBDIRS=net

234
clean:
Linus Torvalds's avatar
Linus Torvalds committed
235
	rm -f kernel/ksyms.lst
Linus Torvalds's avatar
Linus Torvalds committed
236
	rm -f core `find . -name '*.[oas]' -print`
237
	rm -f core `find . -name 'core' -print`
Linus Torvalds's avatar
Linus Torvalds committed
238
	rm -f zImage zSystem.map tools/zSystem tools/system
239 240
	rm -f Image System.map boot/bootsect boot/setup
	rm -f zBoot/zSystem zBoot/xtract zBoot/piggyback
Linus Torvalds's avatar
Linus Torvalds committed
241
	rm -f .tmp* drivers/sound/configure
Linus Torvalds's avatar
Linus Torvalds committed
242
	rm -f init/*.o tools/build boot/*.o tools/*.o
243

244 245
mrproper: clean
	rm -f include/linux/autoconf.h tools/version.h
246
	rm -f drivers/sound/local.h
247
	rm -f .version .config* config.old
248
	rm -f .depend `find . -name .depend -print`
249

Linus Torvalds's avatar
Linus Torvalds committed
250 251
distclean: mrproper

252
backup: mrproper
253
	cd .. && tar cf - linux | gzip -9 > backup.gz
254 255
	sync

256
depend dep:
257
	touch tools/version.h
Linus Torvalds's avatar
Linus Torvalds committed
258 259
	for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done > .tmpdepend
	for i in tools/*.c;do echo -n "tools/";$(CPP) -M $$i;done >> .tmpdepend
260
	set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i dep; done
261
	rm -f tools/version.h
Linus Torvalds's avatar
Linus Torvalds committed
262
	mv .tmpdepend .depend
263

264 265 266
ifdef CONFIGURATION
..$(CONFIGURATION):
	@echo
267
	@echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'"
268 269 270 271 272 273
	@echo
	$(MAKE) $(CONFIGURATION)
	@echo
	@echo "Successful. Try re-making (ignore the error that follows)"
	@echo
	exit 1
274

275
dummy: ..$(CONFIGURATION)
276

277 278 279 280 281
else

dummy:

endif
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305

#
# Leave these dummy entries for now to tell people that they are going away..
#
lilo:
	@echo
	@echo Uncompressed kernel images no longer supported. Use
	@echo \"make zlilo\" instead.
	@echo
	@exit 1

Image:
	@echo
	@echo Uncompressed kernel images no longer supported. Use
	@echo \"make zImage\" instead.
	@echo
	@exit 1

disk:
	@echo
	@echo Uncompressed kernel images no longer supported. Use
	@echo \"make zdisk\" instead.
	@echo
	@exit 1