From ec9957b03a66ec7a8656c75bb47f2937f62ff98b Mon Sep 17 00:00:00 2001
From: Alexander von Gluck IV <kallisti5@unixzen.com>
Date: Sat, 21 Jun 2014 22:37:56 +0000
Subject: [PATCH 1/2] library: Link in libnetwork on Haiku

---
 library/CMakeLists.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt
index 86ccee1..1aaa421 100644
--- a/library/CMakeLists.txt
+++ b/library/CMakeLists.txt
@@ -75,6 +75,10 @@ if(WIN32)
 set(libs ws2_32)
 endif(WIN32)
 
+if(HAIKU)
+set(libs network)
+endif(HAIKU)
+
 if(CMAKE_COMPILER_IS_GNUCC)
   set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS_CHECK} -Wmissing-declarations -Wmissing-prototypes")
   set(CMAKE_C_FLAGS_CHECKFULL "${CMAKE_C_FLAGS_CHECK} -Wcast-qual")
-- 
1.8.3.4

From cef46eb4f9ac1eec70439bb2069c32884649ba02 Mon Sep 17 00:00:00 2001
From: Alexander von Gluck IV <kallisti5@unixzen.com>
Date: Sun, 22 Jun 2014 01:17:39 +0000
Subject: [PATCH 2/2] cmake: Detect old gcc and adjust flags

---
 CMakeLists.txt       | 9 ++++++++-
 tests/CMakeLists.txt | 9 +++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index af268e7..1df9002 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,7 +4,14 @@ project(POLARSSL C)
 string(REGEX MATCH "Clang" CMAKE_COMPILER_IS_CLANG "${CMAKE_C_COMPILER_ID}")
 
 if(CMAKE_COMPILER_IS_GNUCC)
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement")
+  execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+    OUTPUT_VARIABLE GCC_VERSION)
+  if(GCC_VERSION VERSION_GREATER 3.0)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -W -Wdeclaration-after-statement")
+  else()
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W")
+  endif()
+    
   set(CMAKE_C_FLAGS_RELEASE "-O2")
   set(CMAKE_C_FLAGS_DEBUG "-g3 -O0")
   set(CMAKE_C_FLAGS_COVERAGE "-g3 -O0 --coverage")
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 0460c63..bac1f74 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -29,8 +29,13 @@ function(add_test_suite suite_name)
     add_test(${data_name}-suite test_suite_${data_name})
 endfunction(add_test_suite)
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-value")
-set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS_CHECK} -Wno-unused-function -Wno-unused-value")
+execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
+  OUTPUT_VARIABLE GCC_VERSION)
+if(GCC_VERSION VERSION_GREATER 3.0)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-unused-value")
+  set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS_CHECK} -Wno-unused-function -Wno-unused-value")
+endif()
+
 if(CMAKE_COMPILER_IS_CLANG)
     set(CMAKE_C_FLAGS_CHECK "${CMAKE_C_FLAGS_CHECK} -Wno-unreachable-code")
 endif(CMAKE_COMPILER_IS_CLANG)
-- 
1.8.3.4

