From: Michael Göhler Date: Sun, 28 Sep 2014 11:11:19 +0000 (+0200) Subject: switch to uname -s -- another try on #35 X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=5ee2b6a0c18b0772a1124938f4ccff1123a56b89;p=smdp.git switch to uname -s -- another try on #35 --- diff --git a/Makefile b/Makefile index 5801f84..4e8d489 100644 --- a/Makefile +++ b/Makefile @@ -18,25 +18,33 @@ # along with this program. If not, see . # -CURSES = ncursesw -ifeq (Windows_NT, $(OS)) -OSTYPE := $(shell uname -o) -ifneq (Cygwin, $(OSTYPE)) -CURSES := pdcurses -endif +UNAME_S := $(shell uname -s 2>/dev/null || echo not) + +SOURCES = $(wildcard src/*.c) +OBJECTS = $(SOURCES:.c=.o) +TARGET = mdp +DESTDIR = /usr/bin + +CURSES = ncursesw +LDFLAGS = -s + +ifeq (Windows_NT,$(OS)) + ifeq (,$(findstring CYGWIN,$(UNAME_S))) + CURSES := pdcurses + endif endif -LDFLAGS = -s -LDLIBS = -l$(CURSES) -SOURCES = $(wildcard src/*.c) -OBJECTS = $(SOURCES:.c=.o) -TARGET = mdp -DESTDIR = /usr/bin +ifeq ($(UNAME_S),Darwin) + CURSES := ncurses + LDFLAGS := +endif ifeq ($(DEBUG),1) -LDFLAGS := + LDFLAGS := endif +LDLIBS = -l$(CURSES) + all: $(TARGET) $(TARGET): src diff --git a/include/viewer.h b/include/viewer.h index b790085..7a80eaa 100644 --- a/include/viewer.h +++ b/include/viewer.h @@ -32,10 +32,10 @@ * */ -#if WIN32 == 1 -# include +#if defined( WIN32 ) +#include #else -# include +#include #endif #include "parser.h" diff --git a/src/Makefile b/src/Makefile index 42d5563..f41e99a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,19 +18,20 @@ # along with this program. If not, see . # +UNAME_S := $(shell uname -s 2>/dev/null || echo not) + SOURCES = $(wildcard *.c) OBJECTS = $(SOURCES:.c=.o) +CFLAGS = -O3 -Wall -I../include -CFLAGS = -O3 -Wall -I../include ifeq ($(DEBUG),1) -CFLAGS := -O0 -Wall -g -I../include + CFLAGS := -O0 -Wall -g -I../include endif -ifeq (Windows_NT, $(OS)) -OSTYPE := $(shell uname -o) -ifneq (Cygwin, $(OSTYPE)) -CFLAGS += -DWIN32=1 -endif +ifeq ($(OS),Windows_NT) + ifeq (,$(findstring CYGWIN,$(UNAME_S))) + CFLAGS += -DWIN32 + endif endif all: $(OBJECTS)