Browse Source

Modernize a bit the configure.ac.

Set the name and version directly without using an intermediary
variable (this was breaking autoconf), use AS_CASE and AS_IF instead of
the shell versions, use AC_CONFIG_FILES, use the same [default=no|yes]
format as GNU’s software, and fix two --enable that should have been
--disable instead.
Emmanuel Gil Peyrot 9 years ago
parent
commit
f76a88cb95
1 changed files with 27 additions and 32 deletions
  1. 27 32
      configure.ac

+ 27 - 32
configure.ac

@@ -3,16 +3,16 @@ version='0.0.1'
 library_interface_version='0:0:0'
 email='noname@nurd.se'
 
-m4_define([OH_VERSION_STRING], [0.0.1])
-m4_define([OH_NAME], [openhmd])
-
 AC_PREREQ([2.13])
-AC_INIT([OH_NAME], [OH_VERSION_STRING], [noname@nurd.se])
+AC_INIT([openhmd], [0.0.1], [noname@nurd.se])
 AM_INIT_AUTOMAKE([foreign -Wall])
 m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
 LT_INIT
 AC_CANONICAL_HOST
 
+# 0.24 automatically calls AC_SUBST() in PKG_CHECK_MODULES()
+PKG_PROG_PKG_CONFIG([0.24])
+
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
 hidapi="hidapi"
@@ -21,23 +21,20 @@ AC_SUBST(PKG_CONFIG_EXTRA_PATH, "")
 AC_SUBST(EXTRA_LD_FLAGS, "")
 
 AC_MSG_CHECKING([operating system])
-case "$host" in
-*-linux*)
-	AC_MSG_RESULT([$host (Linux)])
-	hidapi="hidapi-libusb"
-
-	#link with realtime lib on linux for clock_gettime
-	AC_SUBST(EXTRA_LD_FLAGS, "-lrt -lpthread")
-	;;
-*-freebsd*)
-	AC_SUBST(PKG_CONFIG_EXTRA_PATH, "libdata/")
-	;;
-esac
+AS_CASE(["$host"],
+	[*-linux*],
+		[AC_MSG_RESULT([$host (Linux)])
+		hidapi="hidapi-libusb"
+
+		#link with realtime lib on linux for clock_gettime
+		AC_SUBST(EXTRA_LD_FLAGS, "-lrt -lpthread")],
+	[*-freebsd*],
+		[AC_SUBST(PKG_CONFIG_EXTRA_PATH, "libdata/")])
 
 # Oculus Rift Driver
 AC_ARG_ENABLE([driver-oculus-rift],
-        [AS_HELP_STRING([--enable-driver-oculus-rift],
-                [enable building of Oculus Rift driver (default y)])],
+        [AS_HELP_STRING([--disable-driver-oculus-rift],
+                [disable building of Oculus Rift driver [default=yes]])],
         [driver_oculus_rift_enabled=$enableval],
         [driver_oculus_rift_enabled='yes'])
 
@@ -45,8 +42,8 @@ AM_CONDITIONAL([BUILD_DRIVER_OCULUS_RIFT], [test "x$driver_oculus_rift_enabled"
 
 # External Driver
 AC_ARG_ENABLE([driver-external],
-        [AS_HELP_STRING([--enable-driver-external],
-                [enable building of External driver (default y)])],
+        [AS_HELP_STRING([--disable-driver-external],
+                [disable building of External driver [default=yes]])],
         [driver_external_enabled=$enableval],
         [driver_external_enabled='yes'])
 
@@ -55,37 +52,36 @@ AM_CONDITIONAL([BUILD_DRIVER_EXTERNAL], [test "x$driver_external_enabled" != "xn
 # Android Driver
 AC_ARG_ENABLE([driver-android],
         [AS_HELP_STRING([--enable-driver-android],
-                [enable building of Android driver (default n)])],
+                [enable building of Android driver [default=no]])],
         [driver_android_enabled=$enableval],
         [driver_android_enabled='no'])
 
 AM_CONDITIONAL([BUILD_DRIVER_ANDROID], [test "x$driver_android_enabled" != "xno"])
 
 # Libs required by Oculus Rift Driver
-if test "x$driver_oculus_rift_enabled" != "xno"; then
-	PKG_CHECK_MODULES([hidapi], [$hidapi] >= 0.0.5)
-fi
+AS_IF([test "x$driver_oculus_rift_enabled" != "xno"],
+	[PKG_CHECK_MODULES([hidapi], [$hidapi] >= 0.0.5)])
 
 # Do we build OpenGL example?
 AC_ARG_ENABLE([openglexample],
         [AS_HELP_STRING([--enable-openglexample],
-                [enable building of OpenGL example (default n)])],
+                [enable building of OpenGL example [default=no]])],
         [openglexample_enabled=$enableval],
         [openglexample_enabled='no'])
 
 AM_CONDITIONAL([BUILD_OPENGL_EXAMPLE], [test "x$openglexample_enabled" != "xno"])
 
 # Libs required by OpenGL test
-if test "x$openglexample_enabled" != "xno"; then
+AS_IF([test "x$openglexample_enabled" != "xno"], [
 	PKG_CHECK_MODULES([sdl], [sdl])
 
 	# Try to find OpenGL with pkg-config
-	PKG_CHECK_MODULES([GL], [gl], [], 
+	PKG_CHECK_MODULES([GL], [gl], [],
 			# and try to find which lib to link to, -lGL first
-			[AC_CHECK_LIB(GL, glBegin, [GL_LIBS=-lGL], 
+			[AC_CHECK_LIB(GL, glBegin, [GL_LIBS=-lGL],
 
 				# if that fails, try -lopengl32 (win32)
-				[AC_CHECK_LIB(opengl32, main, [GL_LIBS=-lopengl32], 
+				[AC_CHECK_LIB(opengl32, main, [GL_LIBS=-lopengl32],
 					AC_MSG_ERROR([GL not found])
 				)]
 			)]
@@ -101,12 +97,11 @@ if test "x$openglexample_enabled" != "xno"; then
 
 	AC_SUBST(GLEW_LIBS)
 	AC_SUBST(GLEW_CFLAGS)
-fi
+])
 
 AC_PROG_CC
 AC_PROG_CC_C99
 
 AC_CONFIG_HEADERS([config.h])
-
-AC_OUTPUT([Makefile src/Makefile tests/Makefile tests/unittests/Makefile examples/Makefile examples/opengl/Makefile examples/simple/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile tests/unittests/Makefile examples/Makefile examples/opengl/Makefile examples/simple/Makefile])
 AC_OUTPUT