Makefile 6.76 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1
VERSION = 1
Linus Torvalds's avatar
Linus Torvalds committed
2
PATCHLEVEL = 0
Linus Torvalds's avatar
Linus Torvalds committed
3
SUBLEVEL = 5
4

5
all:	Version zImage
6

7 8
.EXPORT_ALL_VARIABLES:

9
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
10 11 12
	  else if [ -x /bin/bash ]; then echo /bin/bash; \
	  else echo sh; fi ; fi)

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

28 29 30 31
ifdef CONFIGURATION
CONFIGURE = dummy
endif

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

38
ROOT_DEV = CURRENT
39

40 41 42 43 44 45 46
#
# 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
47
SVGA_MODE=	-DSVGA_MODE=NORMAL_VGA
48

49
#
50
# standard CFLAGS
51 52
#

Linus Torvalds's avatar
Linus Torvalds committed
53
CFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe
Linus Torvalds's avatar
Linus Torvalds committed
54 55 56 57

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

59 60
ifdef CONFIG_M486
CFLAGS := $(CFLAGS) -m486
61 62
else
CFLAGS := $(CFLAGS) -m386
63 64
endif

65 66 67 68
#
# if you want the ram-disk device, define this to be the
# size in blocks.
#
69

70
#RAMDISK = -DRAMDISK=512
71

72 73
AS86	=as86 -0 -a
LD86	=ld86 -0
74

75 76
AS	=as
LD	=ld
Linus Torvalds's avatar
Linus Torvalds committed
77
LDFLAGS	=#-qmagic
78
HOSTCC	=gcc
79
CC	=gcc -D__KERNEL__
80
MAKE	=make
81
CPP	=$(CC) -E
82
AR	=ar
83
STRIP	=strip
84

85
ARCHIVES	=kernel/kernel.o mm/mm.o fs/fs.o net/net.o ipc/ipc.o
86
FILESYSTEMS	=fs/filesystems.a
Linus Torvalds's avatar
Linus Torvalds committed
87 88 89
DRIVERS		=drivers/block/block.a \
		 drivers/char/char.a \
		 drivers/net/net.a \
90
		 ibcs/ibcs.o
91
LIBS		=lib/lib.a
Linus Torvalds's avatar
Linus Torvalds committed
92
SUBDIRS		=kernel drivers mm fs net ipc ibcs lib
93 94

KERNELHDRS	=/usr/src/linux/include
95

Linus Torvalds's avatar
Linus Torvalds committed
96 97 98 99 100 101 102 103 104 105 106 107
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

108
.c.s:
109
	$(CC) $(CFLAGS) -S -o $*.s $<
110 111 112
.s.o:
	$(AS) -c -o $*.o $<
.c.o:
113
	$(CC) $(CFLAGS) -c -o $*.o $<
114

115
Version: dummy
116
	rm -f tools/version.h
117

118
config:
119
	$(CONFIG_SHELL) Configure $(OPTS) < config.in
Linus Torvalds's avatar
Linus Torvalds committed
120
	@if grep -s '^CONFIG_SOUND' .tmpconfig ; then \
121 122
		$(MAKE) -C drivers/sound config; \
		else : ; fi
Linus Torvalds's avatar
Linus Torvalds committed
123
	mv .tmpconfig .config
124

125
linuxsubdirs: dummy
126
	set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i; done
127

128 129
tools/./version.h: tools/version.h

130
tools/version.h: $(CONFIGURE) Makefile
131
	@./makever.sh
Linus Torvalds's avatar
Linus Torvalds committed
132
	@echo \#define UTS_RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)\" > tools/version.h
133
	@echo \#define UTS_VERSION \"\#`cat .version` `date`\" >> tools/version.h
134 135 136
	@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
137
	@echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\" >> tools/version.h
138

Linus Torvalds's avatar
Linus Torvalds committed
139 140
tools/build: tools/build.c $(CONFIGURE)
	$(HOSTCC) $(CFLAGS) -o $@ $<
141

142
boot/head.o: $(CONFIGURE) boot/head.s
143

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

147 148
tools/version.o: tools/version.c tools/version.h

149
init/main.o: $(CONFIGURE) init/main.c
150 151
	$(CC) $(CFLAGS) $(PROFILING) -c -o $*.o $<

152
tools/system:	boot/head.o init/main.o tools/version.o linuxsubdirs
Linus Torvalds's avatar
Linus Torvalds committed
153
	$(LD) $(LDFLAGS) -Ttext 1000 boot/head.o init/main.o tools/version.o \
154 155 156 157
		$(ARCHIVES) \
		$(FILESYSTEMS) \
		$(DRIVERS) \
		$(LIBS) \
Linus Torvalds's avatar
Linus Torvalds committed
158 159 160
		-o tools/system
	nm tools/zSystem | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | \
		sort > System.map
161

Linus Torvalds's avatar
Linus Torvalds committed
162 163
boot/setup: boot/setup.o
	$(LD86) -s -o $@ $<
164

Linus Torvalds's avatar
Linus Torvalds committed
165 166
boot/setup.o: boot/setup.s
	$(AS86) -o $@ $<
167

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

Linus Torvalds's avatar
Linus Torvalds committed
171 172 173 174 175 176 177 178
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 $@
179

180
zBoot/zSystem: zBoot/*.c zBoot/*.S tools/zSystem
181
	$(MAKE) -C zBoot
182 183

zImage: $(CONFIGURE) boot/bootsect boot/setup zBoot/zSystem tools/build
184
	tools/build boot/bootsect boot/setup zBoot/zSystem $(ROOT_DEV) > zImage
185 186 187 188 189 190
	sync

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

zlilo: $(CONFIGURE) zImage
191
	if [ -f /vmlinuz ]; then mv /vmlinuz /vmlinuz.old; fi
Linus Torvalds's avatar
Linus Torvalds committed
192
	if [ -f /zSystem.map ]; then mv /zSystem.map /zSystem.old; fi
193
	cat zImage > /vmlinuz
Linus Torvalds's avatar
Linus Torvalds committed
194
	cp zSystem.map /
Linus Torvalds's avatar
Linus Torvalds committed
195
	if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
196 197

tools/zSystem:	boot/head.o init/main.o tools/version.o linuxsubdirs
Linus Torvalds's avatar
Linus Torvalds committed
198
	$(LD) $(LDFLAGS) -Ttext 100000 boot/head.o init/main.o tools/version.o \
199 200 201 202
		$(ARCHIVES) \
		$(FILESYSTEMS) \
		$(DRIVERS) \
		$(LIBS) \
Linus Torvalds's avatar
Linus Torvalds committed
203 204 205
		-o tools/zSystem
	nm tools/zSystem | grep -v '\(compiled\)\|\(\.o$$\)\|\( a \)' | \
		sort > zSystem.map
206

207 208 209
fs: dummy
	$(MAKE) linuxsubdirs SUBDIRS=fs

210 211 212
lib: dummy
	$(MAKE) linuxsubdirs SUBDIRS=lib

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

Linus Torvalds's avatar
Linus Torvalds committed
216 217 218
ipc: dummy
	$(MAKE) linuxsubdirs SUBDIRS=ipc

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

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

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

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

238 239
mrproper: clean
	rm -f include/linux/autoconf.h tools/version.h
240
	rm -f drivers/sound/local.h
241
	rm -f .version .config* config.old
242
	rm -f .depend `find . -name .depend -print`
243

Linus Torvalds's avatar
Linus Torvalds committed
244 245
distclean: mrproper

246
backup: mrproper
247
	cd .. && tar cf - linux | gzip -9 > backup.gz
248 249
	sync

250
depend dep:
251
	touch tools/version.h
Linus Torvalds's avatar
Linus Torvalds committed
252 253
	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
254
	set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i dep; done
255
	rm -f tools/version.h
Linus Torvalds's avatar
Linus Torvalds committed
256
	mv .tmpdepend .depend
257

258 259 260
ifdef CONFIGURATION
..$(CONFIGURATION):
	@echo
261
	@echo "You have a bad or nonexistent" .$(CONFIGURATION) ": running 'make" $(CONFIGURATION)"'"
262 263 264 265 266 267
	@echo
	$(MAKE) $(CONFIGURATION)
	@echo
	@echo "Successful. Try re-making (ignore the error that follows)"
	@echo
	exit 1
268

269
dummy: ..$(CONFIGURATION)
270

271 272 273 274 275
else

dummy:

endif
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299

#
# 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