Make debug mode (-g) optional and use -O2 optimization flag

Debug mode is enabled by configure script --enable-debug option