factorize config.h/config.mak writing