gcc -o gpsd.o -c -D_GNU_SOURCE -Wmissing-prototypes -Wextra -Wall -Wno-uninitialized -Wno-missing-field-initializers -Wcast-align -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith -Wreturn-type -pthread -Wmissing-declarations -O2 -pthread gpsd.c
gpsd.c: In function 'main':
gpsd.c:1894:32: error: 'control_socket' undeclared (first use in this function)
gpsd.c:1894:32: note: each undeclared identifier is reported only once for each function it appears in
gpsd.c:1925:9: error: 'csock' undeclared (first use in this function)
scons: *** [gpsd.o] Error 1
scons: building terminated because of errors.
The attached patch does fix the build errors but I'm not quite sure if it stacks correctly.