※ 引述《littleboypis.bbs@ptt.cc (littleboypis)》之銘言:
> 請教一下
> 如果我有一程式的目錄結構如下
> main.c
> network/
> --/function.c
> --/function.h
> fileio/
> --/iofunction.c
> --/iofunction.h
> main.c有呼叫一些function所以
> main.c include function.h and iofunction.h
> 我在編譯時都是這麼編譯的(在 Makefile中)
> all:
> gcc -o run main.c function.c iofunction.c
> 這是在檔案少,目錄結構簡單時這樣用還可以接受
> 如果檔案多且目錄結構複雜的話,可能就不是那麼容易維護
> 有沒有比較聰明的方法呢?
> 像是把 network 及 fileio 獨立編成一個檔案
> 之後在跟main.c一起編
> 那這樣要怎麼樣下指令呢
> 謝謝各位
比較複雜的, 每個目錄都寫一個Makefile
最外頭的make 裡會執行下面的動作
make -C network
make -C fileio
這樣以結構方式的 make 會比較好處理
我建議不要一開始就用automation 的make
有了基本的know how 再自動化會比較好
--
If thou wouldst make progress, be content to seem foolish and void of
understanding with respect to outward things. Care not to be thought
to know anything. If any should make account of thee, distrust thyself.
Epictetus
--
★ Origin: 清華電機星星站 <bbs.ee.nthu.edu.tw>
※ Author: Sand From:220-132-117-169.HINET-IP.hinet.net