Autoconf macros AX_CHECK_GL, AX_CHECK_GLU, and AX_CHECK_GLUT, which check for libGL, libGLU, and libglut, respectively.
These macros are designed to work in the presence or absence of X11 and to play nicely with the --with-x option added by Autoconf's AC_PATH_X macro. That is, where an OpenGL implementation that does not require X11 is available, passing --without-x to configure should cause these macros to find it an set the appropriate compiler and linker flags.