Update comments, put LOADER_PHYS_BASE back at 3 GB.
[pintos-anon] / src / Makefile.inc
1 # -*- makefile -*-
2
3 SHELL = /bin/sh
4
5 CC = gcc
6 CPP = $(CC) -E
7
8 VPATH := $(TOP_SRCDIR)/threads
9 VPATH := $(VPATH):$(TOP_SRCDIR)/devices
10 VPATH := $(VPATH):$(TOP_SRCDIR)/lib
11 VPATH := $(VPATH):$(TOP_SRCDIR)/filesys
12 VPATH := $(VPATH):$(TOP_SRCDIR)/userprog
13
14 WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes
15 CFLAGS = -g -O3 -MMD $(WARNINGS) $(INCLUDES) $(DEFINES)
16 ASFLAGS = -Wa,--gstabs+ $(INCLUDES) $(DEFINES)
17
18 # Core kernel.
19 THREADS_SRC  = start.S          # Must be linked first.
20 THREADS_SRC += init.c           # Start-up code.
21 THREADS_SRC += thread.c         # Thread management core.
22 THREADS_SRC += switch.S         # Thread switch routine.
23 THREADS_SRC += interrupt.c      # Interrupt core.
24 THREADS_SRC += intr-stubs.S     # Interrupt stubs.
25 THREADS_SRC += synch.c          # Synchronization.
26 THREADS_SRC += paging.c         # Page tables.
27 THREADS_SRC += palloc.c         # Page allocator.
28 THREADS_SRC += malloc.c         # Subpage allocator.
29
30 # Device driver code.
31 DEVICES_SRC  = timer.c          # Timer device.
32 DEVICES_SRC += kbd.c            # Keyboard device.
33 DEVICES_SRC += vga.c            # Video device.
34 DEVICES_SRC += serial.c         # Serial port device.
35 DEVICES_SRC += disk.c           # IDE disk device.
36
37 # Library code.
38 LIB_SRC  = debug.c              # Debug helpers.
39 LIB_SRC += lib.c                # Standard C library.
40 LIB_SRC += random.c             # Pseudo-random numbers.
41 LIB_SRC += list.c               # Doubly-linked lists.
42 LIB_SRC += bitmap.c             # Bitmaps.
43
44 # Filesystem code.
45 FILESYS_SRC  = filesys.c        # Filesystem core.
46 FILESYS_SRC += file.c           # Files.
47 FILESYS_SRC += directory.c      # Directories.
48 FILESYS_SRC += filehdr.c        # File headers (inodes).
49
50 # User process code.
51 USERPROG_SRC  = addrspace.c     # Address spaces.
52
53 # Objects.
54 OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES)))
55
56 all: diskimage.bin
57
58 intr-stubs.S: $(TOP_SRCDIR)/threads/intr-stubs.pl
59         $< > $@
60
61 kernel.lds: $(TOP_SRCDIR)/threads/kernel.lds.in
62         $(CPP) -x assembler-with-cpp -P $< -o $@
63
64 kernel.o: $(OBJECTS) kernel.lds
65         ld -T kernel.lds -o $@ $(OBJECTS) `$(CC) -print-libgcc-file-name`
66
67 kernel.bin: kernel.o
68         objcopy -O binary -R .note -R .comment -S $< $@.tmp
69         $(TOP_SRCDIR)/pad 4096 < $@.tmp > $@
70
71 loader.bin: loader.S kernel.bin
72         gcc -c $< -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'`
73         ld -N -e start -Ttext 0x7c00 --oformat binary -o $@ loader.o
74
75 diskimage.bin: loader.bin kernel.bin
76         cat loader.bin kernel.bin > diskimage.bin
77
78 clean:
79         rm -f *.o *.d *.bin
80         rm -f kernel.bin.data kernel.bin.pad intr-stubs.S kernel.lds
81
82 -include *.d