From 5194fe489d667d2e51807ebc237726e1ec06b411 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 8 Nov 2011 17:17:45 +1100 Subject: [PATCH] desktop: make desktop build more portable this should help on MacOS thanks to MikeS for his assistance --- libraries/Desktop/Desktop.mk | 29 +++++++++++++++++------- libraries/Desktop/support/FastSerial.cpp | 7 ++++-- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/libraries/Desktop/Desktop.mk b/libraries/Desktop/Desktop.mk index 16a9e52e22..a7bef73127 100644 --- a/libraries/Desktop/Desktop.mk +++ b/libraries/Desktop/Desktop.mk @@ -24,6 +24,14 @@ # SUCH DAMAGE. # +# +# Save the system type for later use. +# +SYSTYPE := $(shell uname) + +# force LANG to C so awk works sanely on MacOS +export LANG=C + # # Locate the sketch sources based on the initial Makefile's path # @@ -85,13 +93,18 @@ ifneq ($(MAKECMDGOALS),configure) HARDWARE=desktop BOARD=desktop -CXX := g++ -CC := gcc -AS := gcc -AR := ar -LD := g++ -GDB := gdb -OBJCOPY := objcopy +ifeq ($(SYSTYPE),Darwin) + CXX := c++ + CC := cc + AS := cc + AR := ar +endif + +CXX ?= g++ +CC ?= gcc +AS ?= gcc +AR ?= ar +LD := $(CXX) # Find awk AWK ?= gawk @@ -114,7 +127,7 @@ ASOPTS = -assembler-with-cpp CXXFLAGS = -g $(DEFINES) $(OPTFLAGS) $(DEPFLAGS) $(CXXOPTS) CFLAGS = -g $(DEFINES) $(OPTFLAGS) $(DEPFLAGS) $(COPTS) ASFLAGS = -g $(DEFINES) $(DEPFLAGS) $(ASOPTS) -LDFLAGS = -g $(OPTFLAGS) -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP) +LDFLAGS = -g $(OPTFLAGS) LIBS = -lm diff --git a/libraries/Desktop/support/FastSerial.cpp b/libraries/Desktop/support/FastSerial.cpp index 79dbc1a78a..9f0795c5f7 100644 --- a/libraries/Desktop/support/FastSerial.cpp +++ b/libraries/Desktop/support/FastSerial.cpp @@ -33,7 +33,6 @@ #include "FastSerial.h" #include "WProgram.h" #include -#include #include #include @@ -62,6 +61,10 @@ # define FS_MAX_PORTS 1 #endif +#ifndef MSG_NOSIGNAL +# define MSG_NOSIGNAL 0 +#endif + static struct tcp_state { bool connected; // true if a client has connected int listen_fd; // socket we are listening on @@ -132,7 +135,7 @@ static void tcp_start_connection(unsigned int serial_port, bool wait_for_connect fprintf(stderr, "accept() error - %s", strerror(errno)); exit(1); } - setsockopt(s->fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one)); + setsockopt(s->fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); s->connected = true; } }