GNU make copy files to distro directory

时光怂恿深爱的人放手 提交于 2019-12-24 11:45:01

问题


I keep my source html (and images etc.) in separate directories for source control. Part of making the distro is to have make copy files to output folder and set the attributes.

Today my makefile shows (extract):

%.html:
    /usr/bin/install -c -p -m 644 $< $@ 

www: $(HTMLDST)/firmware.html $(HTMLDST)/firmware_status.html $(HTMLDST)/index.html
$(HTMLDST)/firmware.html: $(HTMLSRC)/firmware.html 
$(HTMLDST)/firmware_status.html: $(HTMLSRC)/firmware_status.html 
$(HTMLDST)/index.html: $(HTMLSRC)/index.html 

This is shown with only three html files, but in reality, there are lots.

I would like to just list the filenames (without paths) and have make do the comparison between source and destination and copy the files that have been updated.

Thank you in advance Søren


回答1:


This should do it:

$(HTMLDST)/%.html: $(HTMLSRC)/%.html
    /usr/bin/install -c -p -m 644 $< $@ 

www: $(HTMLDST)/firmware.html $(HTMLDST)/firmware_status.html $(HTMLDST)/index.html

Or, for brevity:

HTMLFILES = firmware firmware_status index

DESTFILES = $(patsubst %,$(HTMLDST)/%.html,$(HTMLFILES))

$(HTMLDST)/%.html: $(HTMLSRC)/%.html
    /usr/bin/install -c -p -m 644 $< $@ 

.PHONY: www
www: $(DESTFILES)


来源:https://stackoverflow.com/questions/2543127/gnu-make-copy-files-to-distro-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!