X-Git-Url: https://git.danieliu.xyz/?p=smdp.git;a=blobdiff_plain;f=Makefile;h=1d47fa0c086e38569b66444877bd8235b8851503;hp=7c0cbe75dbe3127ebef3951decc3c0a1bda419f1;hb=HEAD;hpb=3da34e1957b3484506b5f0f79f84f64a4cff2f1b diff --git a/Makefile b/Makefile index 7c0cbe7..1d47fa0 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ # # Makefile -# Copyright (C) 2014 Michael Goehler +# Copyright (C) 2018 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 @@ -18,27 +18,54 @@ # along with this program. If not, see . # -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 +UNAME_S := $(shell uname -s 2>/dev/null || echo not) -%.o: %.c - $(CC) $(CFLAGS) -c $< +SOURCES = $(sort $(wildcard src/*.c)) +OBJECTS = $(SOURCES:.c=.o) +TARGET = smdp +DESTDIR = +PREFIX ?= /usr/local -mdp: $(OBJECTS) - $(CC) $(CFLAGS) -o mdp $(OBJECTS) $(LDFLAGS) +CURSES = ncursesw +LDFLAGS ?= -s -all: mdp +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 -f $(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 smdp.1 $(DESTDIR)$(PREFIX)/share/man/man1/$(TARGET).1 -.PHONY: clean install +uninstall: + $(RM) $(DESTDIR)$(PREFIX)/bin/$(TARGET) + $(RM) $(DESTDIR)$(PREFIX)/share/man/man1/$(TARGET).1 +.PHONY: all clean install src uninstall