X-Git-Url: https://git.danieliu.xyz/?p=smdp.git;a=blobdiff_plain;f=Makefile;h=9c63e0a2b6789abc8b4647db57f8d799ebdcc996;hp=9eb3c79455603e54d50f92f9a83d0b38863ab052;hb=e51b855ccbe106c89063653e1f7e79b1a0a03887;hpb=ba4e2eda316700ba429389d25dd2d2239fc91355 diff --git a/Makefile b/Makefile index 9eb3c79..9c63e0a 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,70 @@ -CFLAGS=-g -Wall +# +# Makefile +# Copyright (C) 2015 Michael Goehler +# +# 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# -mdp: mdp.c cstring.o cstack.o markdown.o parser.o viewer.o - cc $(CFLAGS) -o mdp mdp.c cstring.o cstack.o markdown.o parser.o viewer.o -lncurses +UNAME_S := $(shell uname -s 2>/dev/null || echo not) -viewer.o: viewer.c - cc $(CFLAGS) -c viewer.c +SOURCES = $(wildcard src/*.c) +OBJECTS = $(SOURCES:.c=.o) +TARGET = mdp +DESTDIR = +PREFIX = /usr/local -parser.o: parser.c - cc $(CFLAGS) -c parser.c +CURSES = ncursesw +LDFLAGS ?= -s -markdown.o: markdown.c - cc $(CFLAGS) -c markdown.c +ifeq (Windows_NT,$(OS)) + ifeq (,$(findstring CYGWIN,$(UNAME_S))) + CURSES := pdcurses + endif +endif -cstack.o: cstack.c - cc $(CFLAGS) -c cstack.c +ifeq ($(UNAME_S),Darwin) + CURSES := ncurses + LDFLAGS := +endif -cstring.o: cstring.c - cc $(CFLAGS) -c cstring.c +ifeq ($(DEBUG),1) + LDFLAGS := +endif -all: mdp +LDLIBS = -l$(CURSES) + +all: $(TARGET) + +$(TARGET): src + $(CC) $(OBJECTS) $(LDLIBS) $(LDFLAGS) -o $(TARGET) + +src: + $(MAKE) $(MFLAGS) -C src clean: - rm -f mdp *.o + $(MAKE) -C src clean + $(RM) $(TARGET) -.PHONY: test +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 -test: - $(MAKE) -C test +uninstall: + $(RM) $(DESTDIR)$(PREFIX)/$(TARGET) +.PHONY: all clean install src uninstall