Make the unix-adapter work on MSYS.

- In my MSYS environment, gcc/g++ are the MinGW compilers that target
   Win32.  We really need compilers that target the MSYS environment.
   Add a config-unix.mk for building the unix-adapter.

 - My MSYS environment lacks a pipe2 function, but I can get the same
   effect using pipe and fcntl, so do that instead.
This commit is contained in:
Ryan Prichard 2012-02-20 03:34:14 -08:00
parent 00a6c3b90e
commit e7c5342479
3 changed files with 24 additions and 3 deletions

13
config-unix.mk Normal file
View File

@ -0,0 +1,13 @@
UNAME_S = $(shell uname -s)
ifneq (,$(findstring MINGW,$(UNAME_S)))
# MSYS/MINGW environment
CC = i686-pc-msys-gcc
CXX = i686-pc-msys-g++
else ifneq (,$(findstring CYGWIN,$(UNAME_S)))
# Cygwin environment
CC = gcc
CXX = g++
else
$(error Could not detect CYGWIN or MSYS/MINGW environment)
endif

View File

@ -1,4 +1,5 @@
include ../config.mk
include ../config-unix.mk
PROGRAM = pconsole
OBJECTS = main.o Shared.o

View File

@ -195,6 +195,11 @@ void *InputHandler::threadProc(void *pvthis)
return NULL;
}
static void setFdNonBlock(int fd)
{
int status = fcntl(fd, F_GETFL);
fcntl(fd, F_SETFL, status | O_NONBLOCK);
}
int main()
{
@ -223,12 +228,14 @@ int main()
{
int pipeFd[2];
if (pipe2(pipeFd, O_NONBLOCK) != 0) {
if (pipe(pipeFd) != 0) {
perror("Could not create pipe");
exit(1);
}
signalReadFd = pipeFd[0];
signalWriteFd = pipeFd[1];
setFdNonBlock(pipeFd[0]);
setFdNonBlock(pipeFd[1]);
signalReadFd = pipeFd[0];
signalWriteFd = pipeFd[1];
}
OutputHandler outputHandler(pconsole_get_data_pipe(pconsole));