Edgar Simo
So basically the issue is that:
AC_PATH_PROG(SDL_CONFIG, sdl2-config, no, [$PATH])
in sdl2.m4 shares the same variable (SDL_CONFIG) as sdl.m4:
AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
What happens is if you run the AM_PATH_SDL2 and then AM_PATH_SDL to say fall back on SDL if SDL2 isn't found, the AM_PATH_PROG command gets cached (ac_cv_path_SDL_CONFIG) so that unless you unset this cache variable, the result for AM_PATH_SDL will be EXACTLY the same as for AM_PATH_SDL2.
To fix I would recommend renaming SDL_CONFIG to SDL2_CONFIG in sdl2.m4, replacing all instances so it won't cache to the same variable.