If condition inside a target in a Makefile -
i want this, want run svn commit if file has changed. file has timestamp changes. if more timestamp changes , want commit file.
the makefile have similar this. if condition not working properly. getting executed when if not satisfied. can me out problem in if here.
update_state_file : $(eval no_lines_changes_in_state = $(shell svn di state/build.state --diff-cmd=diff -x --normal | grep "^[<>]" | wc -l)) @echo $(no_lines_changes_in_state) ifneq ($(strip $(no_lines_changes_in_state)), 2) ifneq ($(strip $(no_lines_changes_in_state)), 0) @echo $(no_lines_changes_in_state) $(svn) commit; $(svn) update; endif endif
you cannot mix make conditionals inside command rules. make conditionals preprocessor statements in c or c++; handled file read in, before processing (like running rules) performed.
if want conditionals inside rules have write rule using shell conditionals, not make conditionals:
update_state_file : @no_lines_changes_in_state=`svn di state/build.state --diff-cmd=diff -x --normal | grep "^[<>]" | wc -l`; \ echo $$no_lines_changes_in_state; \ if [ $$no_lines_changes_in_state -ne 2 ] && [ $$no_lines_changes_in_state -ne 0 ]; \ echo $$no_lines_changes_in_state; \ $(svn) commit; \ $(svn) update; \ fi
Comments
Post a Comment