145 lines
4.6 KiB
Text
145 lines
4.6 KiB
Text
# This is part of a GNU Makefile, included by the Makefiles in
|
|
# each of the subdirectories.
|
|
#
|
|
# This file includes all of the baseline code provided by Nachos.
|
|
# Whenever you add a .h or .cc file, put it in the appropriate
|
|
# _H,_C, or _O list.
|
|
#
|
|
# The dependency graph between assignments is:
|
|
# 1. THREADS before everything else
|
|
# 2. USERPROG must come before VM
|
|
# 3. USERPROG can come before or after FILESYS, but if USERPROG comes
|
|
# before (as in this distribution), then it must define FILESYS_STUB
|
|
#
|
|
# Other than that, you have complete flexibility.
|
|
#
|
|
|
|
# You might want to play with the CFLAGS, but if you use -O it may
|
|
# break the thread system. You might want to use -fno-inline if
|
|
# you need to call some inline functions from the debugger.
|
|
|
|
# Copyright (c) 1992 The Regents of the University of California.
|
|
# All rights reserved. See copyright.h for copyright notice and limitation
|
|
# of liability and disclaimer of warranty provisions.
|
|
|
|
###########################################################################
|
|
# RN: Sets of objects file to be linked for each nachos flavor. This
|
|
# is the only section you may need to modify when adding files in nachos.
|
|
#
|
|
THREAD_O := main.o list.o scheduler.o synch.o synchlist.o \
|
|
system.o thread.o utility.o threadtest.o interrupt.o \
|
|
stats.o sysdep.o timer.o
|
|
|
|
USERPROG_O := addrspace.o bitmap.o exception.o progtest.o console.o \
|
|
consoledriver.o machine.o mipssim.o translate.o userthread.o
|
|
|
|
VM_O :=
|
|
|
|
FILESYS_O := directory.o filehdr.o filesys.o fstest.o openfile.o \
|
|
synchdisk.o disk.o
|
|
|
|
NETWORK_O := nettest.o post.o network.o
|
|
#
|
|
###########################################################################
|
|
|
|
S_OFILES := switch.o
|
|
|
|
CFLAGS = -g -Wall -Wextra -Wshadow $(INCPATH) $(DEFINES) $(HOST) -DCHANGED
|
|
LDFLAGS = -g
|
|
ASFLAGS = -g
|
|
|
|
# These definitions may change as the software is updated.
|
|
# Some of them are also system dependent
|
|
CPP= gcc -E -P
|
|
CC = g++
|
|
LD = g++
|
|
AS = gcc -c
|
|
|
|
PROGRAM := nachos
|
|
|
|
MAKEFILES := Makefile \
|
|
../Makefile.common \
|
|
../Makefile.dep
|
|
|
|
OFILES := $(strip $(C_OFILES) $(S_OFILES))
|
|
|
|
# RN: Dependency files start with a '.' to avoid annoying completion
|
|
# confusion under shell, emacs, etc.
|
|
|
|
C_DFILES := $(patsubst %.o,.%.d,$(C_OFILES))
|
|
S_DFILES := $(patsubst %.o,.%.d,$(S_OFILES))
|
|
DFILES := $(strip $(C_DFILES) $(S_DFILES))
|
|
|
|
# RN: Hummm... There's a lot to tell about the story of the two
|
|
# following lines. Essentially, it allows 'make' to implicitely search
|
|
# for source/header files in various directories. The original Nachos
|
|
# Makefile was not using this 'vpath' feature, although it was using
|
|
# the aforementioned implicit search policy! The problem came from
|
|
# the rule:
|
|
# $(C_OFILES): %.o:
|
|
# $(CC) blabla...
|
|
# which is correct if .o files have no extra dependency rules. In this
|
|
# case, 'make' finds the associated .cc file in the directories it
|
|
# knows of (because they were listed in some macros!). However, if we add
|
|
# a rule such as
|
|
# $(C_OFILES): toto
|
|
# then 'make' tries to compile 'toto' each time it rebuilds a ".o"
|
|
# file. As a result, the former rule was modified as follows
|
|
# $(C_OFILES): %.o: %.cc
|
|
# As you may guess, it did'nt work because 'make' was no longer using
|
|
# its @#!^# implicit policy in this case. Crazy, isn't it? Fortunately,
|
|
# there's a GNU extension that requires 'make' to use a "search path" for
|
|
# files that match a given pattern: this is the vpath directive...
|
|
# Well, I guess you should stop wondering why these two lines are here: you'd
|
|
# better concentrate on your exercise! ;-)
|
|
|
|
vpath %.cc ../machine:../threads:../userprog:../filesys:../network:../vm:../
|
|
vpath %.S ../machine:../threads:../userprog:../filesys:../network:../vm:../
|
|
|
|
# Must be the first rule
|
|
.PHONY: default
|
|
default: $(PROGRAM)
|
|
|
|
$(OFILES): $(MAKEFILES)
|
|
|
|
$(PROGRAM): $(OFILES)
|
|
$(LD) $(OFILES) $(LDFLAGS) -o $(PROGRAM)
|
|
|
|
$(C_OFILES): %.o: %.cc
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
switch.o: ../threads/switch.S
|
|
$(CPP) $(INCPATH) $(HOST) ../threads/switch.S > swtch.s
|
|
$(AS) $(ASFLAGS) -o switch.o swtch.s
|
|
rm swtch.s
|
|
|
|
# RN: Rules to generate dependency files. We can no longer rely on a
|
|
# single '.depend' file if we want to avoid a global recompilation each
|
|
# time a file is modified! Thus, each %.cc file is associated with its own
|
|
# .%.d dependency file...
|
|
|
|
.PHONY: depend
|
|
depend: $(DFILES)
|
|
|
|
$(DFILES): $(MAKEFILES)
|
|
|
|
$(C_DFILES): .%.d: %.cc
|
|
$(CC) $(CFLAGS) -MM $< | \
|
|
sed -e 's|\(.*\)\.o:|.\1.d \1.o:|g' > $@
|
|
|
|
$(S_DFILES): .%.d: %.S
|
|
$(CC) $(CFLAGS) -MM $< | \
|
|
sed -e 's|\(.*\)\.o:|.\1.d \1.o:|g' > $@
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
-include $(DFILES)
|
|
endif
|
|
|
|
# Cleaning rules
|
|
.PHONY: clean
|
|
clean:
|
|
rm -f core nachos DISK *.o *.s .*.d coff2noff out disassemble
|
|
|
|
.PHONY: distclean
|
|
distclean: clean
|
|
rm -f *\~ \#*\#
|