X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=Makefile;h=0db1ec6f693cc66ae0edb768e8ba50b2e673be07;hb=354cf2e07ccd0d7900f96bffc279093997cbe203;hp=f0cf1ec3c3ca31a3f948d0053397cd5c9e928170;hpb=1137e63ffbb08abc0daea19e32aa37e96afb0770;p=smdp.git diff --git a/Makefile b/Makefile index f0cf1ec..0db1ec6 100644 --- 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. # @@ -18,38 +18,53 @@ # along with this program. If not, see . # -CFLAGS = -O3 -Wall +UNAME_S := $(shell uname -s 2>/dev/null || echo not) -ifeq ($(DEBUG),1) -CFLAGS := -O0 -Wall -g -LDFLAGS := +SOURCES = $(sort $(wildcard src/*.c)) +OBJECTS = $(SOURCES:.c=.o) +TARGET = mdp +DESTDIR = +PREFIX ?= /usr/local + +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 (Windows_NT, $(OS)) -CURSES = pdcurses -CFLAGS += -DWIN32=1 -else -CURSES = ncursesw +ifeq ($(DEBUG),1) + LDFLAGS := endif -LDFLAGS = -s LDLIBS = -l$(CURSES) -OBJECTS = cstring.o cstack.o markdown.o parser.o viewer.o mdp.o -DESTDIR = /usr/bin -all: mdp +all: $(TARGET) -mdp: $(OBJECTS) +$(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 - 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 uninstall: - $(RM) $(PREFIX)$(DESTDIR)/mdp - -.PHONY: all clean install uninstall + $(RM) $(DESTDIR)$(PREFIX)/$(TARGET) +.PHONY: all clean install src uninstall