Advertisement
minhkhoi1026

Nachos Makefile

Jan 6th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.41 KB | None | 0 0
  1. # Copyright (c) 1992-1996 The Regents of the University of California.
  2. # All rights reserved. See copyright.h for copyright notice and limitation
  3. # of liability and disclaimer of warranty provisions.
  4. #
  5. # This is a GNU Makefile. It must be used with the GNU make program.
  6. # At UW, the GNU make program is /software/gnu/bin/make.
  7. # In many other places it is known as "gmake".
  8. # You may wish to include /software/gnu/bin/ early in your command
  9. # search path, so that you will be using GNU make when you type "make".
  10. #
  11. # About this Makefile:
  12. # --------------------
  13. #
  14. # This Makefile is used to build the Nachos system, which includes
  15. # the MIPS machine simulation and a simple operating system.
  16. #
  17. # There is a separate Makefile, in the "test" directory, that is
  18. # used to build the Nachos test programs (which run on the
  19. # simulated machine).
  20. #
  21. # There are several "build" directories, one for each type
  22. # of machine in the MFCF computing environment
  23. # (build.solaris, build.sunos, and build.ultrix), as well
  24. # as a build directory for Linux (build.linux) and a generic
  25. # build directory (build.other) for those who wish to try
  26. # building Nachos on other platforms.
  27. #
  28. # This Makefile appears to be located in all of the build directories.
  29. # If you edit it in one directory, the copies in all of the other
  30. # directories appear to change as well. This is the desired behaviour,
  31. # since this file is machine independent. (The file actually lives
  32. # in build.solaris, with symbolic links from the other build directories.)
  33. #
  34. # The platform-dependent parts of make's instructions are located
  35. # in the file Makefile.dep.
  36. # There is a different Makefile.dep in each build directory.
  37. #
  38. # If you are in the MFCF environment, you should not have to edit
  39. # the Makefile.dep files by hand. Any changes to the make instructions
  40. # can be made in this file (see the instructions below) - they will
  41. # apply no matter where you build Nachos.
  42. # If you are not in the MFCF environment, e.g., if you are trying
  43. # to build Nachos on Linux at home, you will probably need
  44. # to edit Makefile.dep (in the appropriate build directory) to
  45. # customize the make procedure to your environment.
  46. #
  47. # How to build Nachos for the first time:
  48. # ---------------------------------------
  49. #
  50. # (1) Make sure than you are in the build directory for the
  51. # type of machine you are logged in to (the "host" machine):
  52. #
  53. # host type examples build directory
  54. # ----------- ----------- ----------------
  55. #
  56. # sparc/SunOS cayley,napier, build.sunos
  57. # (SunOS 4.1.3) descartes
  58. #
  59. # sparc/Solaris picard.math, build.solaris
  60. # (SunOS 5.x) hermite.math,
  61. # markov.math,
  62. # hypatia.math,
  63. # hume.math
  64. #
  65. # mips/ULTRIX cantor.math build.ultrix
  66. # (ULTRIX 4.2) noether.math
  67. #
  68. # If you are not sure what type of machine you are on,
  69. # try the command "uname -a".
  70. #
  71. # (2) Type "make depend"
  72. # - this computes file dependencies and records them
  73. # at the end of the file Makefile.dep in
  74. # your build directory. Have a look...
  75. #
  76. # (3) Type "make nachos" (or just "make").
  77. # - make echos the commands it is executing, so that
  78. # you can observe its progress. When the
  79. # build is finished, you should have an
  80. # executable "nachos" in the build directory.
  81. #
  82. # (4) There is no 4th step. You are done. Try running "./nachos -u".
  83. #
  84. #
  85. # How to Re-build Nachos after you have changed the code:
  86. #--------------------------------------------------------
  87. #
  88. # - The Nachos source code is located in the code subdirectories:
  89. # threads, userprog, filesys, network, and lib. You may
  90. # change the files in any of these directories, and you can
  91. # add new files and/or remove files. The "machine" subdirectory
  92. # contains the hardware simulation (which is also part of
  93. # Nachos. You may look at it, but
  94. # you may not change it, except as noted in machine/machine.h
  95. # - When you want to re-make Nachos, always do it in the
  96. # "build" directory that is appropriate for the machine
  97. # type that you are running on.
  98. # DO NOT TRY TO MAKE NACHOS IN THE SOURCE CODE DIRECTORIES.
  99. #
  100. # - IF all you have done is changed C++ code in existing files
  101. # (since the last time you made Nachos in this build directory),
  102. # THEN all you need to do to re-make Nachos is to type
  103. #
  104. # "make nachos"
  105. #
  106. # in the build directory.
  107. #
  108. # - IF you have done any of the following since the last build in
  109. # this directory:
  110. # added new .cc files or new .h files
  111. # added or deleted #include's from existing files
  112. # THEN
  113. # you must do
  114. # "make depend"
  115. # followed by
  116. # "make nachos"
  117. #
  118. # in the build directory.
  119. #
  120. # Note that is is always safe to do "make depend" followed by
  121. # "make nachos", so if you are not sure what changes you have
  122. # made, do "make depend".
  123. #
  124. # - IF you have added new files (.cc or .h) since the last build,
  125. # you should edit this Makefile before running "make depend"
  126. # and "make nachos".
  127.  
  128. # For new .h files, simply update the appropriate "_H" list below.
  129. # For example, if you create a file called
  130. # "bigfile.h" in the filesys subdirectory, you should add
  131. # "../filesys/bigfile.h" to FILESYS_H, which is defined below
  132.  
  133. # For new .cc files, update the appropriate "_C" and "_O" lists.
  134. # For example, if you create a file called "filetable.cc" in
  135. # the directory "userprog", you should add
  136. # "../userprog/filetable.cc" to USERPROG_C,
  137. # and you should add "filetable.o" to USERPROG_O.
  138. # Note that the entry in the "_C" list includes the subdirectory
  139. # name, while the entry on the "_O" list does not.
  140. #
  141. # Some Important Notes:
  142. # ---------------------
  143. #
  144. # * You can clean up all of the .o and other files left behind
  145. # by make by typeing "make clean" in the build directory.
  146. # * You can clean up .o and other files, as well as the nachos
  147. # executable, DISK, core, SOCKET, and other files by typing
  148. # make "distclean"
  149. #
  150. # These are good ways to save space, but the next build that
  151. # you do after cleaning will take longer than usual, since
  152. # much of the stuff you cleaned will need to be rebuilt.
  153. #
  154. # * When you build Nachos on an ULTRIX machine (in build.ultrix),
  155. # you will get lots of warning messages like this:
  156. #
  157. # openfile.o: does not have gp tables for all it's sectons
  158. #
  159. # from the loader. Ignore them. Or better yet, figure out
  160. # how to make them go away.
  161. #
  162. # The Most Important Note:
  163. # -----------------------
  164. #
  165. # * If "make" is behaving strangely and you cannot figure out
  166. # why, you should REBUILD the program FROM SCRATCH.
  167. # Yes, it is slow.
  168. # But, there are lots of little things that can go wrong, especially
  169. # with all of these different types of machines available.
  170. # Rebuilding from scratch at least gives you a known starting
  171. # place. To rebuild from scratch, go to the appropriate
  172. # build directory and do:
  173. #
  174. # make distclean
  175. # make depend
  176. # make nachos
  177. #
  178. ################################################################
  179. # READ THIS: CONFIGURING NACHOS
  180. #
  181. # Change DEFINES (below) to
  182. # DEFINES = -DUSE_TLB -DFILESYS_STUB
  183. # if you want the simulated machine to use its TLB
  184. #
  185. # If you want to use the real Nachos file system (based on
  186. # the simulated disk), rather than the stub, remove
  187. # the -DFILESYS_STUB from DEFINES.
  188. #
  189. # There is a a fix to the MIPS simulator to enable it to properly
  190. # handle unaligned data access. This fix is enabled by the addition
  191. # of "-DSIM_FIX" to the DEFINES. This should be enabled by default
  192. # and eventually will not require the symbol definition
  193. ################################################################
  194. DEFINES = -DFILESYS_STUB -DRDATA -DSIM_FIX
  195.  
  196.  
  197. #####################################################################
  198. #
  199. # You might want to play with the CFLAGS, but if you use -O it may
  200. # break the thread system. You might want to use -fno-inline if
  201. # you need to call some inline functions from the debugger.
  202.  
  203. CFLAGS = -g -Wall $(INCPATH) $(DEFINES) $(HOSTCFLAGS) -DCHANGED -m32
  204. LDFLAGS = -m32
  205. CPP_AS_FLAGS= -m32
  206.  
  207. #####################################################################
  208. CPP=/lib/cpp
  209. CC = g++
  210. LD = g++
  211. AS = as
  212. RM = /bin/rm
  213.  
  214. INCPATH = -I../network -I../filesys -I../userprog -I../threads -I../machine -I../lib -I-
  215.  
  216. PROGRAM = nachos
  217.  
  218. #
  219. # Edit these lists as if you add files to the source directories.
  220. # See the instructions at the top of the file for more information.
  221. #
  222.  
  223. LIB_H = ../lib/bitmap.h\
  224. ../lib/copyright.h\
  225. ../lib/debug.h\
  226. ../lib/hash.h\
  227. ../lib/libtest.h\
  228. ../lib/list.h\
  229. ../lib/sysdep.h\
  230. ../lib/utility.h
  231.  
  232. LIB_C = ../lib/bitmap.cc\
  233. ../lib/debug.cc\
  234. ../lib/hash.cc\
  235. ../lib/libtest.cc\
  236. ../lib/list.cc\
  237. ../lib/sysdep.cc
  238.  
  239. LIB_O = bitmap.o debug.o libtest.o sysdep.o
  240.  
  241.  
  242. MACHINE_H = ../machine/callback.h\
  243. ../machine/interrupt.h\
  244. ../machine/stats.h\
  245. ../machine/timer.h\
  246. ../machine/console.h\
  247. ../machine/machine.h\
  248. ../machine/mipssim.h\
  249. ../machine/translate.h\
  250. ../machine/network.h\
  251. ../machine/disk.h
  252.  
  253. MACHINE_C = ../machine/interrupt.cc\
  254. ../machine/stats.cc\
  255. ../machine/timer.cc\
  256. ../machine/console.cc\
  257. ../machine/machine.cc\
  258. ../machine/mipssim.cc\
  259. ../machine/translate.cc\
  260. ../machine/network.cc\
  261. ../machine/disk.cc
  262.  
  263. MACHINE_O = interrupt.o stats.o timer.o console.o machine.o mipssim.o\
  264. translate.o network.o disk.o
  265.  
  266. THREAD_H = ../threads/alarm.h\
  267. ../threads/kernel.h\
  268. ../threads/main.h\
  269. ../threads/scheduler.h\
  270. ../threads/pcb.h\
  271. ../threads/ptable.h\
  272. ../threads/stable.h\
  273. ../threads/switch.h\
  274. ../threads/synch.h\
  275. ../threads/synchlist.h\
  276. ../threads/thread.h\
  277.  
  278. THREAD_C = ../threads/alarm.cc\
  279. ../threads/kernel.cc\
  280. ../threads/main.cc\
  281. ../threads/ptable.cc\
  282. ../threads/pcb.cc\
  283. ../threads/scheduler.cc\
  284. ../threads/stable.cc\
  285. ../threads/synch.cc\
  286. ../threads/synchlist.cc\
  287. ../threads/thread.cc\
  288.  
  289. THREAD_O = alarm.o kernel.o main.o scheduler.o synch.o thread.o ptable.o stable.o pcb.o
  290.  
  291. USERPROG_H = ../userprog/addrspace.h\
  292. ../userprog/syscall.h\
  293. ../userprog/synchconsole.h\
  294. ../userprog/noff.h\
  295. ../userprog/errno.h
  296.  
  297. USERPROG_C = ../userprog/addrspace.cc\
  298. ../userprog/exception.cc\
  299. ../userprog/synchconsole.cc
  300.  
  301. USERPROG_O = addrspace.o exception.o synchconsole.o
  302.  
  303. FILESYS_H =../filesys/directory.h \
  304. ../filesys/filehdr.h\
  305. ../filesys/filesys.h \
  306. ../filesys/openfile.h\
  307. ../filesys/pbitmap.h\
  308. ../filesys/synchdisk.h
  309.  
  310. FILESYS_C =../filesys/directory.cc\
  311. ../filesys/filehdr.cc\
  312. ../filesys/filesys.cc\
  313. ../filesys/pbitmap.cc\
  314. ../filesys/openfile.cc\
  315. ../filesys/synchdisk.cc\
  316.  
  317. FILESYS_O =directory.o filehdr.o filesys.o pbitmap.o openfile.o synchdisk.o
  318.  
  319. NETWORK_H = ../network/post.h
  320.  
  321. NETWORK_C = ../network/post.cc
  322.  
  323. NETWORK_O = post.o
  324.  
  325. ##################################################################
  326. # You probably don't want to change anything below this point in
  327. # the file unless you are comfortable with GNU make and know what
  328. # you are doing...
  329. ##################################################################
  330.  
  331. THREAD_S = ../threads/switch.s
  332.  
  333. HFILES = $(LIB_H) $(MACHINE_H) $(THREAD_H) $(USERPROG_H) $(FILESYS_H) $(NETWORK_H)
  334. CFILES = $(LIB_C) $(MACHINE_C) $(THREAD_C) $(USERPROG_C) $(FILESYS_C) $(NETWORK_C)
  335.  
  336. C_OFILES = $(LIB_O) $(MACHINE_O) $(THREAD_O) $(USERPROG_O) $(FILESYS_O) $(NETWORK_O)
  337.  
  338. S_OFILES = switch.o
  339. OFILES = $(C_OFILES) $(S_OFILES)
  340.  
  341. $(PROGRAM): $(OFILES)
  342. $(LD) $(OFILES) $(LDFLAGS) -o $(PROGRAM)
  343.  
  344. $(C_OFILES): %.o:
  345. $(CC) $(CFLAGS) -c $<
  346.  
  347. switch.o: ../threads/switch.S
  348. $(CC) $(CPP_AS_FLAGS) -P $(INCPATH) $(HOSTCFLAGS) -c ../threads/switch.S
  349.  
  350. depend: $(CFILES) $(HFILES)
  351. $(CC) $(INCPATH) $(DEFINES) $(HOSTCFLAGS) -DCHANGED -M $(CFILES) > makedep
  352. @echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep
  353. @echo '$$r makedep' >>eddep
  354. @echo 'w' >>eddep
  355. @echo 'q' >>eddep
  356. ed - Makefile.dep < eddep
  357. rm eddep makedep
  358. @echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile.dep
  359. @echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.dep
  360. @echo '# see make depend above' >> Makefile.dep
  361.  
  362. clean:
  363. $(RM) -f $(OFILES)
  364.  
  365. distclean: clean
  366. $(RM) -f $(PROGRAM)
  367. $(RM) -f DISK_?
  368. $(RM) -f core
  369. $(RM) -f SOCKET_?
  370. @echo '/^# DO NOT DELETE THIS LINE/+1,$$d' >eddep
  371. @echo 'w' >>eddep
  372. @echo 'q' >>eddep
  373. ed - Makefile.dep < eddep
  374. rm eddep
  375. @echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile.dep
  376. @echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile.dep
  377. @echo '# see make depend above' >> Makefile.dep
  378.  
  379. include Makefile.dep
  380.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement