Merge pull request #23 from mattn/win32
[smdp.git] / Makefile
index 7c0cbe7..f0cf1ec 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 # 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)
+ifeq (Windows_NT, $(OS))
+CURSES   = pdcurses
+CFLAGS  += -DWIN32=1
+else
+CURSES   = ncursesw
+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