Checking file size in makefile, stopping if file is too short

compilation, makefile

Solution

Put this in your rule, somewhere before the compilation:

 test -n "$$(find filename -a -size +NNNc)"

where `filename` is the filename and `NNN` is the size in octets. This returns false and halts `make` when the size is less than or equal to `NNN`.

Problem

Is there a way to check if the size of a particular file is less than some constant? I'm assuming things about size in the makefile and want to make sure I'll get an error if my assumptions are not met. Something like assert, but in makefile. ``` if filesize(file) > C then error else continue compilation ```

Original source