desktop: make desktop build more portable

this should help on MacOS

thanks to MikeS for his assistance
This commit is contained in:
Andrew Tridgell 2011-11-08 17:17:45 +11:00
parent 0e447b12a2
commit 5194fe489d
2 changed files with 26 additions and 10 deletions

View File

@ -24,6 +24,14 @@
# SUCH DAMAGE. # 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 # Locate the sketch sources based on the initial Makefile's path
# #
@ -85,13 +93,18 @@ ifneq ($(MAKECMDGOALS),configure)
HARDWARE=desktop HARDWARE=desktop
BOARD=desktop BOARD=desktop
CXX := g++ ifeq ($(SYSTYPE),Darwin)
CC := gcc CXX := c++
AS := gcc CC := cc
AR := ar AS := cc
LD := g++ AR := ar
GDB := gdb endif
OBJCOPY := objcopy
CXX ?= g++
CC ?= gcc
AS ?= gcc
AR ?= ar
LD := $(CXX)
# Find awk # Find awk
AWK ?= gawk AWK ?= gawk
@ -114,7 +127,7 @@ ASOPTS = -assembler-with-cpp
CXXFLAGS = -g $(DEFINES) $(OPTFLAGS) $(DEPFLAGS) $(CXXOPTS) CXXFLAGS = -g $(DEFINES) $(OPTFLAGS) $(DEPFLAGS) $(CXXOPTS)
CFLAGS = -g $(DEFINES) $(OPTFLAGS) $(DEPFLAGS) $(COPTS) CFLAGS = -g $(DEFINES) $(OPTFLAGS) $(DEPFLAGS) $(COPTS)
ASFLAGS = -g $(DEFINES) $(DEPFLAGS) $(ASOPTS) ASFLAGS = -g $(DEFINES) $(DEPFLAGS) $(ASOPTS)
LDFLAGS = -g $(OPTFLAGS) -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP) LDFLAGS = -g $(OPTFLAGS)
LIBS = -lm LIBS = -lm

View File

@ -33,7 +33,6 @@
#include "FastSerial.h" #include "FastSerial.h"
#include "WProgram.h" #include "WProgram.h"
#include <unistd.h> #include <unistd.h>
#include <pty.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
@ -62,6 +61,10 @@
# define FS_MAX_PORTS 1 # define FS_MAX_PORTS 1
#endif #endif
#ifndef MSG_NOSIGNAL
# define MSG_NOSIGNAL 0
#endif
static struct tcp_state { static struct tcp_state {
bool connected; // true if a client has connected bool connected; // true if a client has connected
int listen_fd; // socket we are listening on 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)); fprintf(stderr, "accept() error - %s", strerror(errno));
exit(1); 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; s->connected = true;
} }
} }