참고

https://casys-kaist.github.io/pintos-kaist/introduction/grading.html

테스트를 어떻게 진행할지 모르겠다

가장 처음에 실해하고 싶은건, 일단 테스트가 가능한지였다. 어떻게 테스트를 실행하는지를 모르니, 작성해도 제대로 동작하는지 확인할 방법이 없었다.

build 디렉토리가 안보인다

build 디렉토리에서 테스트를 실행해야하지만, 처음에는 없다. make 명령어를 이용해 만들어주어야한다.

make 명령어

make 명령어는 Makefile에 적힌 규칙을 읽고, 자동으로 실행하는 도구다. 사용하는 우분투 환경에서는 make 명령어가 등록되어있다.

jungle@d1a5a50b8fc0:/workspaces/code/pintos$ which make
/usr/bin/make

thread 디렉토리에서 make를 입력

결과는 아래와 같이 빌드 디렉토리가 생성된다.

34+0 records out
139264 bytes (139 kB, 136 KiB) copied, 0.0503643 s, 2.8 MB/s
rm kernel.bin.tmp
gcc -c ../../threads/loader.S -o threads/loader.o -Wa,--gstabs -mcmodel=large -nostdinc -I../.. -I../../include/lib -I../../include -I../../include/lib/kernel -I../../lib/kernel  -DKERNEL_LOAD_PAGES=`perl -e 'print +(-s "kernel.bin") / 4096;'`
ld --no-relax -N -e start -Ttext 0x7c00 --oformat binary -o loader.bin threads/loader.o
cat loader.bin kernel.bin > os.dsk
make[1]: Leaving directory '/workspaces/code/pintos/threads/build'

어떻게 동작하는걸까?

0. Makefile 문법

target: dependency
	cammand (여기서는 반드시 tab 사용)
	
target을 사용할때는 dependecy가 필요하다.
depencency를 만들거 내기 위해 command를 실행하라.

$(make)
Makefile 내에서 make를 실행하라는 표현

1. make 명령어로 thread 디렉토리 안에 있는 Makefile이 실행된다

include ../Makefile.kernel

파일 안에는 상위 디렉토리에 있는 makefile을 언급하고 있다.