From: Roy Marples Date: Sun, 8 Apr 2007 17:35:22 +0000 (+0000) Subject: We should now compile on OpenBSD. Also, we check we can use some gcc flags before... X-Git-Tag: v3.2.3~286 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=000ad4a5ccc4e82557e8252a928afc0fc79b2c74;p=thirdparty%2Fdhcpcd.git We should now compile on OpenBSD. Also, we check we can use some gcc flags before blindly erroring. --- diff --git a/ChangeLog b/ChangeLog index 52a204a1..6619da8b 100644 --- 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. diff --git a/Makefile b/Makefile index 9a58169f..047ea398 100644 --- 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 diff --git a/socket.c b/socket.c index cfd00417..0618a4ac 100644 --- a/socket.c +++ b/socket.c @@ -26,10 +26,12 @@ #include #include #include +#ifndef __OpenBSD__ #include -#include #include #include +#endif +#include #ifndef __linux__ #include #endif