color config for code blocks
[smdp.git] / Makefile
index 5801f84..1d47fa0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 #
 # Makefile
-# Copyright (C) 2014 Michael Goehler
+# Copyright (C) 2018 Michael Goehler
 #
 # This file is part of mdp.
 #
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
 
-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 = $(sort $(wildcard src/*.c))
+OBJECTS = $(SOURCES:.c=.o)
+TARGET  = smdp
+DESTDIR =
+PREFIX  ?= /usr/local
+
+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
@@ -50,11 +59,13 @@ clean:
        $(RM) $(TARGET)
 
 install:
-       install -d $(PREFIX)$(DESTDIR)
-       install -m 755 mdp $(PREFIX)$(DESTDIR)/$(TARGET)
+       install -d $(DESTDIR)$(PREFIX)/bin
+       install -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/$(TARGET)
+       install -d $(DESTDIR)$(PREFIX)/share/man/man1
+       install -m 644 smdp.1 $(DESTDIR)$(PREFIX)/share/man/man1/$(TARGET).1
 
 uninstall:
-       $(RM) $(PREFIX)$(DESTDIR)/$(TARGET)
+       $(RM) $(DESTDIR)$(PREFIX)/bin/$(TARGET)
+       $(RM) $(DESTDIR)$(PREFIX)/share/man/man1/$(TARGET).1
 
 .PHONY: all clean install src uninstall
-