Makefile 6.63 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1
VERSION = 0.99
2
PATCHLEVEL = 15
Linus Torvalds's avatar
Linus Torvalds committed
3
ALPHA = c
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

Linus Torvalds's avatar
Linus Torvalds committed
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

Linus Torvalds's avatar
Linus Torvalds committed
72 73
AS86	=as86 -0 -a
LD86	=ld86 -0
74

75 76
AS	=as
LD	=ld
77
HOSTCC	=gcc
78
CC	=gcc -D__KERNEL__
79
MAKE	=make
80
CPP	=$(CC) -E
81
AR	=ar
82
STRIP	=strip
83

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

KERNELHDRS	=/usr/src/linux/include
94

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

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

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

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

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

127 128
tools/./version.h: tools/version.h

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

204 205 206
fs: dummy
	$(MAKE) linuxsubdirs SUBDIRS=fs

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

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

Linus Torvalds's avatar
Linus Torvalds committed
213 214 215
ipc: dummy
	$(MAKE) linuxsubdirs SUBDIRS=ipc

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

Linus Torvalds's avatar
Linus Torvalds committed
219 220 221
drivers: dummy
	$(MAKE) linuxsubdirs SUBDIRS=drivers

222 223 224
net: dummy
	$(MAKE) linuxsubdirs SUBDIRS=net

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

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

Linus Torvalds's avatar
Linus Torvalds committed
241 242
distclean: mrproper

243
backup: mrproper
244
	cd .. && tar cf - linux | gzip -9 > backup.gz
245 246
	sync

247
depend dep:
248
	touch tools/version.h
249 250
	for i in init/*.c;do echo -n "init/";$(CPP) -M $$i;done > .depend~
	for i in tools/*.c;do echo -n "tools/";$(CPP) -M $$i;done >> .depend~
251
	set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i dep; done
252
	rm -f tools/version.h
253
	mv .depend~ .depend
254

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

266
dummy: ..$(CONFIGURATION)
267

268 269 270 271 272
else

dummy:

endif
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296

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