I need help with comparing two files in makefile. I need something like this:
if [cmp $(FILE1) $(FILE2)] !=0; than
echo "OK"
else
echo "WRONG"
fi
But I am not sure how exactly to do that, Thanks
I need help with comparing two files in makefile. I need something like this:
if [cmp $(FILE1) $(FILE2)] !=0; than
echo "OK"
else
echo "WRONG"
fi
But I am not sure how exactly to do that, Thanks
Edit: corrected mistaken use of -z
to -eq 0
and added Makefile context help.
It's really a shell question, not specific to makefiles, but this code would work:
cmp -s $(FILE1) $(FILE2)
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo "SAME"
else
echo "NOT SAME"
fi
In a makefile rule, that would look like:
my_compare:
cmp -s $(FILE1) $(FILE2); \
RETVAL=$$?; \
if [ $$RETVAL -eq 0 ]; then \
echo "SAME"; \
else \
echo "NOT SAME"; \
fi
Return code from diff
command will be 0 if files are identical, and 1 if files differs.