有 global 的 Makefile 嗎? - Linux

Table of Contents


現在寫報告,會寫成 html 再印成 pdf 。

我的 Makefile 是這樣:

%.pdf: %.html style.css
wkhtmltopdf --print-media-type $< $@


但各科在不同的資料夾,

要每個資料夾都放一個一樣的 Makefile 很麻煩。


Makefile 有 implicit rule ,

像 make foo 就會自動執行

gcc -o foo foo.c

可以不用寫在 Makefile 裡。


有辦法加入自訂的 implicit rule 嗎?

目前想加的有 html to pdf

和 coffee script to javascript 吧。

%.js: %.coffee
coffee $<

--

篋ゆ√忨䓻篋醇掩젊
‰¸€¯ēƼåØ‧
°ä百äꂠ
跔茛ﴱ é—′ç1 2 ç￿跔슠゚돿ﶠ怴見gè¯*
--

All Comments

Eartha avatarEartha2016-11-22
alias + make -f 不行嗎?
Quintina avatarQuintina2016-11-23
就 alias makepdf='make -f /path/to/Makefile'
用的時候就 makepdf xxx.pdf
Mia avatarMia2016-11-24
好像不錯
Dorothy avatarDorothy2016-11-27
gmake 看起來沒有這功能,bmake 似乎有 /etc/make.conf
Edwina avatarEdwina2016-11-30
看錯了,bmake 應該是 /usr/share/mk/sys.mk 才對