]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
We should now compile on OpenBSD. Also, we check we can use some gcc flags before...
authorRoy Marples <roy@marples.name>
Sun, 8 Apr 2007 17:35:22 +0000 (17:35 +0000)
committerRoy Marples <roy@marples.name>
Sun, 8 Apr 2007 17:35:22 +0000 (17:35 +0000)
ChangeLog
Makefile
socket.c

index 52a204a151399b7fd6da61044b2314a16b0b7e1b..6619da8b78268e05a8b5554389fcd294557ccece 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+Compile ok on OpenBSD (thanks to icezimm and reb in #gentoo-bsd for testing)
+We check gcc supports -Wextra and friends before using them.
 We now restore the starting MTU value when we exit OR we don't receive a
 a valid MTU value from the dhcp server.
 --nomtu / -M now stops the MTU from being used.
index 9a58169f422dba95beeda579b620bf328ef7ff8d..047ea39846368c6ab6f96c12f0a20a624cd41e03 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,20 @@
+VERSION = 3.0.17_pre2
+CFLAGS ?= -O2 -pipe
+
 # Should work for both GNU make and BSD make
 
-VERSION = 3.0.17_pre2
+# Saying that, this function only works with GNU Make :/
+check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
+         then echo "$(1)"; else echo "$(2)"; fi)
 
-CFLAGS ?= -O2 -pipe
+# Luckily we can do this more long winded thing with pmake used by the BSDs
+# FIXME: Look into making this into a loop
+WAFTST != if $(CC) -Wextra -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
+         then echo "-Wdeclaration-after-statement"; fi
+WSEQ   != if $(CC) -Wextra -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
+         then echo "-Wsequence-point"; fi
+WEXTRA != if $(CC) -Wextra -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
+         then echo "-Wextra"; fi
 
 # Loads of nice flags to ensure our code is good
 # IMPORTANT: We should be using c99 instead of gnu99 but for some reason
@@ -11,11 +23,10 @@ CFLAGS += -pedantic -std=gnu99 \
     -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
     -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
     -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
-    -Wchar-subscripts -Wcast-align -Wno-format-nonliteral
-
-# Early GCC versions don't support these flags, so you may need to comment
-# this line out
-CFLAGS += -Wsequence-point -Wextra -Wdeclaration-after-statement
+    -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
+    $(call check_gcc, -Wdeclaration-after-statement) \
+    $(call check_gcc, -Wsequence-point) \
+    $(call check_gcc, -Wextra) $(WAFTST) $(WSEQ) $(WEXTRA)
 
 # -Werrror is a good flag to use for development, but some platforms may
 #  have buggy headers from time to time, so you may need to comment this out
index cfd0041749a79f66ee06b6be8290eee33f3abf38..0618a4ac2b28ee7ef7d36d38f126706543219de3 100644 (file)
--- a/socket.c
+++ b/socket.c
 #include <sys/uio.h>
 #include <netinet/in_systm.h>
 #include <netinet/in.h>
+#ifndef __OpenBSD__
 #include <netinet/ip.h>
-#include <netinet/udp.h>
 #include <netinet/if_ether.h>
 #include <net/ethernet.h>
+#endif
+#include <netinet/udp.h>
 #ifndef __linux__
 #include <net/if_types.h>
 #endif