Search code examples
makefilecygwin

Why doesn't this makefile take effect


I wanna use Google Closure Compiler to compile my js codes.I write a makefile to do the job but it never takes effect. What I want is to compile each file listed in filelist and output it to ../js/

filelist = thermometer.js logic.combat.js analyse.js logic.js

wp := $(foreach k, $(filelist), ../js/$(k))

$(wp) : $(filelist)
    java -jar compiler.jar --js=$< --js_output_file=../js/$<

Solution

  • In the current formulation, all of the wp objects depend on all js files, and only the first source file is ever compiled (thermometer.js).

    You should rather formulate the last two lines in the Makefile with pattern rules:

    all : $(wp)
    ../js/%.js : %.js
        java -jar compiler.jar --js=$< --js_output_file=$@