# Makefile
# Copyright (C) 2014 Michael Goehler
#
-# This file is part of mpd.
+# This file is part of mdp.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-CC = /usr/bin/gcc
-CFLAGS = -Wall -g
-LDFLAGS = -lncurses
-OBJECTS = cstring.o cstack.o markdown.o parser.o viewer.o mdp.o
-DESTDIR ?= /usr/bin
+CFLAGS = -O3 -Wall
-%.o: %.c
- $(CC) $(CFLAGS) -c $<
+ifeq ($(DEBUG),1)
+CFLAGS := -O0 -Wall -g
+LDFLAGS :=
+endif
-mdp: $(OBJECTS)
- $(CC) $(CFLAGS) -o mdp $(OBJECTS) $(LDFLAGS)
+OSTYPE := $(shell uname -o)
+CURSES = ncursesw
+ifeq (Windows_NT, $(OS))
+ifneq (Cygwin, $(OSTYPE))
+CURSES := pdcurses
+CFLAGS += -DWIN32=1
+endif
+endif
+
+LDFLAGS = -s
+LDLIBS = -l$(CURSES)
+OBJECTS = cstring.o cstack.o markdown.o parser.o viewer.o mdp.o
+DESTDIR = /usr/bin
all: mdp
+mdp: $(OBJECTS)
+
clean:
- rm -f $(OBJECTS) mdp
+ $(RM) $(OBJECTS) mdp
install: mdp
- if which strip 1>/dev/null 2>&1; then strip mdp; fi
install -d $(PREFIX)$(DESTDIR)
install -m 755 mdp $(PREFIX)$(DESTDIR)/mdp
-.PHONY: clean install
+uninstall:
+ $(RM) $(PREFIX)$(DESTDIR)/mdp
+
+.PHONY: all clean install uninstall