Makefile: refactor CFLAGS and LDFLAGS

CFLAGS and LDFLAGS with default "preferences" the user should override
ALL_CFLAGS and ALL_LDFLAGS for flags that are probably required
replace LDLIBS with ALL_LDFLAGS
SHARED_LDFLAGS for building the shared library
use ALL_CFLAGS everywhere CC is used, including for linking