X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=Makefile;h=564466fda6f6be786dc02a152ceba96a0677cb73;hb=2aa3c0cd39679dc780199b95c6b5a6e7f39e3660;hp=de3c650376e4f208cb4370e0889d5aa626048440;hpb=6a78a5788120dbae26ee01ddc85d6a014155eba1;p=smdp.git diff --git a/Makefile b/Makefile index de3c650..564466f 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # # Makefile -# Copyright (C) 2014 Michael Goehler +# Copyright (C) 2016 Michael Goehler # # This file is part of mdp. # @@ -18,22 +18,53 @@ # along with this program. If not, see . # -CFLAGS = -Wall -g -LDLIBS = -lncurses -OBJECTS = cstring.o cstack.o markdown.o parser.o viewer.o mdp.o -DESTDIR ?= /usr/bin +UNAME_S := $(shell uname -s 2>/dev/null || echo not) -all: mdp +SOURCES = $(sort $(wildcard src/*.c)) +OBJECTS = $(SOURCES:.c=.o) +TARGET = mdp +DESTDIR = +PREFIX ?= /usr/local -mdp: $(OBJECTS) +CURSES = ncursesw +LDFLAGS ?= -s + +ifeq (Windows_NT,$(OS)) + ifeq (,$(findstring CYGWIN,$(UNAME_S))) + CURSES := pdcurses + endif +endif + +ifeq ($(UNAME_S),Darwin) + CURSES := ncurses + LDFLAGS := +endif + +ifeq ($(DEBUG),1) + LDFLAGS := +endif + +LDLIBS = -l$(CURSES) + +all: $(TARGET) + +$(TARGET): src + $(CC) $(OBJECTS) $(LDLIBS) $(LDFLAGS) -o $(TARGET) + +src: + $(MAKE) $(MFLAGS) -C src clean: - $(RM) $(OBJECTS) mdp + $(MAKE) -C src clean + $(RM) $(TARGET) -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 +install: + install -d $(DESTDIR)$(PREFIX)/bin + install -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/$(TARGET) + install -d $(DESTDIR)$(PREFIX)/share/man/man1 + install -m 644 mdp.1 $(DESTDIR)$(PREFIX)/share/man/man1/$(TARGET).1 -.PHONY: all clean install +uninstall: + $(RM) $(DESTDIR)$(PREFIX)/$(TARGET) +.PHONY: all clean install src uninstall