linux源代碼編譯安裝的三個過程:configure, make , make install
1. ./configure
configure 是一個可執行腳本,有很多選項,可以執行 ./configure --help 列出, configure的作用是檢測安裝平台的目標特征,比如檢測編譯器是什么版本,最后生成一個符合目標平台的編譯腳本makefile。
./configure --prefix = /usr/local/xxx 指定是將軟件安裝到指定的目錄/usr/local/xxx下。另外一個額外的好處是方便卸載軟件和移植,卸載只需要刪除xxx文件夾,移植將文件打包烤至目標主機即可。
2. make
編譯過程。根據第一步生成的makefile腳本編譯源代碼、
3. make install (需要root權限,向系統寫文件)
安裝(有些軟件需要先運行 make check 或 make test來進行一些測試),將編譯出來的程序、依賴庫、文檔拷貝至指定的xxx目標。
如果在configure后面沒有指定 --prefix目錄, 默認將可執行文件放到 /usr/loceal/bin , 庫文件/usr/local/lib , 配置文件 /usr/local/etc ,其他資源文件 /usr/local/share
參考: https://thoughtbot.com/blog/the-magic-behind-configure-make-make-install