Ubuntu//make小筆記

  1. Ubuntu//make小筆記

Ubuntu//make小筆記

原文連結: https://darkblack01.blogspot.com/2013/05/ubuntumake.html
移植時的最後更新日期: 2013-05-19T23:27:34.080+08:00

makefile
在gcc一堆檔案時,需要用到的makefile腳本檔。

格式如下:
(target): (objFiles)
(tab)gcc…


Sample Code:

exeFile = main
objAll = main.o hello.o
main: ${objAll}
gcc -c main.c
gcc -c hello.c
gcc -o ${exeFile} ${objAll}

clean:
rm ${objAll} {exeFile}

「main:」和「clean:」是target,它們的以下的幾行都是以tab鍵開頭,才開始輸入bash指令的。
「objAll」和「main」是變數,目前是當作文字替代的功能,使用變數必須要用{(變數)}的方式。


參考資料:
[1] 鳥哥的 Linux 私房菜 – makefile 的基本語法與變 數