Makefile rebuilds all files even if only one changes -


i writing makefile project large number of js files in complex directory structure. when run needs perform compilation on each file , save results different directory same tree structure (right that's simulated cp). when run make js builds should , when run make js again says there no work do. when modify 1 of files , make js re-builds entire tree instead of modified file.

shell := /bin/bash builddir := build/gui/  rawjsfiles := $(shell find app -name '*.js') built_rawjsfiles := $(patsubst %, $(builddir)%,$(rawjsfiles))  $(builddir):     mkdir -p $(builddir)  $(rawjsfiles): $(builddir)  $(built_rawjsfiles): $(rawjsfiles)     mkdir -p $(@d)     # compile step     cp $(shell python -c "print '$@'.lstrip('${builddir}')") $(@d)  .phony: js js: $(built_rawjsfiles) 

the line $(built_rawjsfiles): $(rawjsfiles) setting prerequisites of each file in $(built_rawjsfiles) all files in $(rawjsfiles).

to one-to-one mapping want need pattern rule or static pattern rule.

also embedded python snippet isn't at all doing intended there. removing longest leading prefix value of $@ contains of characters in builddir namely build/gui/ (only not string characters that's equivalent lstrip('/iugdlb')). (oh, don't need $(shell) here in shell context normal command substitution work ($$(python ...).)

that being said if use pattern or static pattern rule you'll have easier ways source filename messing python that.

something should work (untested):

$(builddir)%.js: %.js         mkdir -p $(@d)         cp $^ $(@d) 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -