Bash與Makefile

在認識到Linux以前,我鮮少接觸到CLI(Command Line Interface),也花了些許時間去熟悉。一開始看它也許會感到有些震懾,但並沒有想像中的複雜,單純是將我們習慣使用的GUI(Graphical User Interface)改成CLI,滑鼠改成鍵盤,簡單做了轉換。

1
2
3
4
sudo apt-get install qt6-default #以superuser身份安裝qt6-default
mkdir build/install -p #新增資料夾
cd build/install #切換目錄到build/install
rm –rf build #remove文件, recursively.

makefile

make 以及 makefile讓我們得以自動化我們想執行的command line。比如說modmesh裡面中clean這個target,若是藉由一行一行的command line我們會需要輸入以下的指令,

1
2
rm -f $(MODMESH_ROOT)/modmesh/_modmesh$(pyextsuffix)
make -C $(BUILD_PATH) clean

但如果已經在Makefile中寫好了clean這個target,將一行行的command line寫成了shell script。

1
2
3
4
.PHONY: clean
clean:
rm -f $(MODMESH_ROOT)/modmesh/_modmesh$(pyextsuffix)
make -C $(BUILD_PATH) clean

我們就可以去藉由make,直接輸入 make clean 去執行我們想要去執行的內容,不用逐步命令。

1
make clean