Makefile 想要寫的更精簡 - Linux

Callum avatar
By Callum
at 2017-12-09T15:43

Table of Contents

各位大大好,小弟想再這裡請問一下
下方是我專案makefile,裡面有大量重複的部份

utAtom: utAtom.o term.o
g++ -o $@ $^ -lgtest -lpthread
utAtom.o: utAtom.h atom.h
touch $*.cpp && echo "#include \"$*.h\"" > $*.cpp && cat utTemplate.h >>
$*.cpp
g++ -c $*.cpp

utTerm: utTerm.o term.o
g++ -o $@ $^ -lgtest -lpthread
utTerm.o: utTerm.h atom.h number.h variable.h
touch $*.cpp && echo "#include \"$*.h\"" > $*.cpp && cat utTemplate.h >>
$*.cpp
g++ -c $*.cpp

兩組之間只差了ut****不一樣而已,請問我該何把它縮短,用變數在執行的時候去讀$@
好像是不能讀的,感謝各位了ꨊ
--
Tags: Linux

All Comments

Andrew avatar
By Andrew
at 2017-12-09T16:50
ut%m: ut%m.o term.o
wild card 可以在中間嗎?
Edward Lewis avatar
By Edward Lewis
at 2017-12-11T05:07
什麼中間!?
Jacob avatar
By Jacob
at 2017-12-14T02:19
一般都是 %.html: %.md 之類的放頭或尾,中間好像也行
Emma avatar
By Emma
at 2017-12-15T17:06
看懂了 可以放中間 %就是匹配1~n個字元
Cara avatar
By Cara
at 2017-12-17T23:34
大致看懂了,謝謝各位的幫忙

tar 多不同路徑檔,並移除絕對路徑

Heather avatar
By Heather
at 2017-12-08T16:05
Linux 板的棒油大家好。 在寫 script 中,取得了想要處理的檔案清單: ./01.txt /tmp/02.txt /home/user/03.txt ... 想要將其打包壓成 tar 檔, 不過若是直接下指令如下的話: tar -zcvf test.tar.gz ./01.txt /tmp/02 ...

centos 5有類似timeout指令嗎?

Doris avatar
By Doris
at 2017-12-08T14:23
目前是用centos 7 直接使用內建timeout就可以自動中斷指令 但有and#34;一部份and#34;舊server是centos 5如果用timeout還要另裝套件 請問centos 5 有辦法在不額外裝套件的方式下 一樣達到timeout的功能嗎? 感謝 - ...

啟動icfb遇到問題

Erin avatar
By Erin
at 2017-12-08T12:09
請問出現這個錯誤是在 X console 還是 remote 端呢? (XRDP 那應該是remote?) 可以試著起 xvnc then vnc viewer with -depth 24 再起 ic5141 看看? ※ 引述《yis000000 (口口口tall)》之銘言: : 小弟是用CentOS7 ...

啟動icfb遇到問題

Kama avatar
By Kama
at 2017-12-07T18:19
小弟是用CentOS7 今天灌了IC5141 啟動icfb時遇到了這個問題 failed to find either 24-bit true color or 8-bit pseudocolor visual 自己找了一下好像是色辨率的問題 我用的是XRDP的遠端連線 也把/etc/X11/xrdp/xor ...

spyder安裝 遇到lzh_tw 問題

Lily avatar
By Lily
at 2017-12-07T15:26
os:ubunto 17.10 Q.terminal執行spyder時報錯 (只擷取最尾端資訊) File and#34;/home/jack/anaconda3/lib/python3.6/_strptime.pyand#34;, line 31, in _getlang return loca ...