Rewrite filesystem to support Unix "delete" semantics.
[pintos-anon] / src / Makefile.build
1 # -*- makefile -*-
2
3 include ../Makefile.vars
4
5 SHELL = /bin/sh
6
7 CC = gcc
8
9 VPATH = ../..
10
11 DEFINES += -DKERNEL
12 WARNINGS = -Wall -W -Wstrict-prototypes -Wmissing-prototypes
13 INCLUDES = -nostdinc -I../.. -I- -I../../lib -I../../lib/kernel
14 CFLAGS = -g -O3 -MMD -msoft-float $(INCLUDES) $(WARNINGS) $(DEFINES)
15 ASFLAGS = -Wa,--gstabs -MMD $(INCLUDES) $(DEFINES)
16
17 # Core kernel.
18 threads_SRC  = threads/init.c           # Main program.
19 threads_SRC += threads/thread.c         # Thread management core.
20 threads_SRC += threads/switch.S         # Thread switch routine.
21 threads_SRC += threads/interrupt.c      # Interrupt core.
22 threads_SRC += threads/intr-stubs.S     # Interrupt stubs.
23 threads_SRC += threads/synch.c          # Synchronization.
24 threads_SRC += threads/paging.c         # Page tables.
25 threads_SRC += threads/palloc.c         # Page allocator.
26 threads_SRC += threads/malloc.c         # Subpage allocator.
27 threads_SRC += threads/start.S          # Startup code.
28 threads_SRC += threads/test.c           # Test code.
29
30 # Device driver code.
31 devices_SRC  = devices/timer.c          # Timer device.
32 devices_SRC += devices/kbd.c            # Keyboard device.
33 devices_SRC += devices/vga.c            # Video device.
34 devices_SRC += devices/serial.c         # Serial port device.
35 devices_SRC += devices/disk.c           # IDE disk device.
36 devices_SRC += devices/intq.c           # Interrupt queue.
37
38 # Library code shared between kernel and user programs.
39 lib_SRC  = lib/debug.c          # Debug helpers.
40 lib_SRC += lib/random.c         # Pseudo-random numbers.
41 lib_SRC += lib/stdio.c          # I/O library.
42 lib_SRC += lib/stdlib.c         # Utility functions.
43 lib_SRC += lib/string.c         # String functions.
44
45 # Kernel-specific library code.
46 lib_kernel_SRC += lib/kernel/list.c     # Doubly-linked lists.
47 lib_kernel_SRC += lib/kernel/bitmap.c   # Bitmaps.
48 lib_kernel_SRC += lib/kernel/hash.c     # Hash tables.
49 lib_kernel_SRC += lib/kernel/console.c  # printf(), putchar().
50
51 # Filesystem code.
52 filesys_SRC  = filesys/filesys.c        # Filesystem core.
53 filesys_SRC += filesys/file.c           # Files.
54 filesys_SRC += filesys/directory.c      # Directories.
55 filesys_SRC += filesys/inode.c          # File headers.
56 filesys_SRC += filesys/fsutil.c         # Utilities.
57
58 # User process code.
59 userprog_SRC  = userprog/addrspace.c    # Address spaces.
60 userprog_SRC += userprog/exception.c    # User exception handler.
61 userprog_SRC += userprog/syscall.c      # System call handler.
62 userprog_SRC += userprog/gdt.c          # GDT initialization.
63 userprog_SRC += userprog/tss.c          # TSS management.
64
65 SOURCES = $(foreach dir,$(SUBDIRS),$($(subst /,_,$(dir))_SRC))
66 OBJECTS = $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCES)))
67 DEPENDS = $(patsubst %.o,%.d,$(OBJECTS))
68
69 all: os.dsk
70
71 threads/intr-stubs.S: threads/intr-stubs.pl threads/loader.h
72         $< > $@
73
74 threads/kernel.lds.s: CPPFLAGS += -P -C
75 threads/kernel.lds.s: threads/kernel.lds.S threads/loader.h
76
77 kernel.o: threads/kernel.lds.s $(OBJECTS) 
78         ld -T $< -o $@ $(OBJECTS) `$(CC) -print-libgcc-file-name`
79
80 kernel.bin: kernel.o
81         objcopy -O binary -R .note -R .comment -S $< $@.tmp
82         ../../pad 4096 < $@.tmp > $@
83         rm $@.tmp
84
85 threads/loader.o: threads/loader.S kernel.bin
86         $(CC) -c $< -o $@ $(ASFLAGS) -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'`
87
88 loader.bin: threads/loader.o
89         ld -N -e start -Ttext 0x7c00 --oformat binary -o $@ $<
90
91 os.dsk: loader.bin kernel.bin
92         cat $^ > $@
93
94 clean:
95         rm -f $(OBJECTS) $(DEPENDS) 
96         rm -f threads/intr-stubs.S threads/loader.o
97         rm -f kernel.o kernel.lds.s
98         rm -f kernel.bin loader.bin
99
100 -include $(DEPENDS)