I know we can use cmake or make to control CFLAGS or CXXFLAGS for building release version manually. release version to me means -O2 or -O3 is given at least, it doesn't matter whether -g or strip is performed, whereas debug is given -O0.
However sometimes I want use scripts to decide whether an elf binary was built with optimizations, so I can decide what to do next. I tried objdump or file or readelf, but found no answers. Are there any alternatives that I can do this ?