build: make libdrm a hard build-time dependency

Libdrm provides headers that are useful even without libdrm.so itself,
particularly drm_fourcc.h. Therefore promote libdrm as a hard build-time
dependency of libweston core so that we can always rely on libdrm
headers.

This does not affect any runtime dependencies. Specifically, no runtime
dependency to libdrm.so is added in any build configuration.

Currently only gl-renderer is using drm_fourcc.h. Now we can drop the
GL_RENDERER check from configure.ac and just use LIBDRM_CFLAGS.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[Pekka, from Quentin: just drop have_libdrm var completely]
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
diff --git a/Makefile.am b/Makefile.am
index ff927c1..8ecc90c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -324,7 +324,7 @@
 gl_renderer_la_CFLAGS =				\
 	$(COMPOSITOR_CFLAGS)			\
 	$(EGL_CFLAGS)				\
-	$(GL_RENDERER_CFLAGS)			\
+	$(LIBDRM_CFLAGS)			\
 	$(AM_CFLAGS)
 gl_renderer_la_SOURCES =			\
 	libweston/gl-renderer.h			\
diff --git a/configure.ac b/configure.ac
index 39c0531..db757f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,6 +105,14 @@
 
 AC_CHECK_FUNCS([mkostemp strchrnul initgroups posix_fallocate])
 
+# check for libdrm as a build-time dependency only
+# libdrm 2.4.30 introduced drm_fourcc.h.
+PKG_CHECK_MODULES(LIBDRM, [libdrm >= 2.4.30], [], [AC_MSG_ERROR([
+     libdrm is a hard build-time dependency for libweston core,
+     but a sufficient version was not found. However, libdrm
+     is not a runtime dependency unless you have features
+     enabled that require it.])])
+
 COMPOSITOR_MODULES="wayland-server >= $WAYLAND_PREREQ_VERSION pixman-1 >= 0.25.2"
 
 AC_CONFIG_FILES([doc/doxygen/tools.doxygen doc/doxygen/tooldev.doxygen])
@@ -133,7 +141,6 @@
 	AC_DEFINE([ENABLE_EGL], [1], [Build Weston with EGL support])
 	PKG_CHECK_MODULES(EGL, [egl glesv2])
         PKG_CHECK_MODULES([EGL_TESTS], [egl glesv2 wayland-client wayland-egl])
-	PKG_CHECK_MODULES([GL_RENDERER], [libdrm])
 fi
 
 AC_ARG_ENABLE(xkbcommon,
@@ -177,8 +184,6 @@
   fi
 fi
 
-PKG_CHECK_MODULES(LIBDRM, [libdrm], have_libdrm=yes, have_libdrm=no)
-
 AC_ARG_ENABLE(x11-compositor, [  --enable-x11-compositor],,
 	      enable_x11_compositor=yes)
 AM_CONDITIONAL(ENABLE_X11_COMPOSITOR, test x$enable_x11_compositor = xyes)