--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,19 @@
 AC_CONFIG_SRCDIR([libupnpp/upnpplib.hxx])
 AC_CONFIG_HEADERS([libupnpp/config.h])
 AH_BOTTOM([#include "libupnpp/conf_post.h"])
+
+AC_CANONICAL_HOST
+build_linux=no
+build_mac=no
+# Detect the target system
+case "${host_os}" in
+    linux*) build_linux=yes;;
+    darwin*) build_mac=yes;;
+    *) AC_MSG_ERROR(["OS $host_os is not supported"]);;
+esac
+# Pass the conditionals to automake
+AM_CONDITIONAL([LINUX], [test "$build_linux" = "yes"])
+AM_CONDITIONAL([OSX], [test "$build_mac" = "yes"])
 
 AM_INIT_AUTOMAKE([1.10 no-define subdir-objects foreign])
 AC_DISABLE_STATIC