X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=Makefile;h=f922b7edd11ae99d33cbe2d68b84a1c02d708003;hb=bc3a373a2926e34352018677bfb5ed2eacede2a8;hp=63a1feb9ef37b349e8d951b8c7d65d654894d03f;hpb=cae082fd57d2612384893a46c46c523a200075b8;p=smdp.git diff --git a/Makefile b/Makefile index 63a1feb..f922b7e 100644 --- a/Makefile +++ b/Makefile @@ -18,29 +18,43 @@ # along with this program. If not, see . # -CFLAGS = -O3 -Wall +OSTYPE := $(shell uname -o) +CURSES = ncursesw +ifeq (Windows_NT, $(OS)) +ifneq (Cygwin, $(OSTYPE)) +CURSES := pdcurses +endif +endif + LDFLAGS = -s -LDLIBS = -lncurses -OBJECTS = cstring.o cstack.o markdown.o parser.o viewer.o mdp.o -DESTDIR ?= /usr/bin +LDLIBS = -l$(CURSES) +SOURCES = $(wildcard src/*.c) +OBJECTS = $(SOURCES:.c=.o) +TARGET = mdp +DESTDIR = /usr/bin ifeq ($(DEBUG),1) -CFLAGS := -Wall -g -O0 LDFLAGS := endif -all: mdp +all: $(TARGET) + +$(TARGET): src + $(CC) $(OBJECTS) $(LDLIBS) $(LDFLAGS) -o $(TARGET) -mdp: $(OBJECTS) +src: + $(MAKE) $(MFLAGS) -C src clean: - $(RM) $(OBJECTS) mdp + $(MAKE) -C src clean + $(RM) $(TARGET) -install: mdp - install -Dm755 mdp $(PREFIX)$(DESTDIR)/mdp +install: + install -d $(PREFIX)$(DESTDIR) + install -m 755 mdp $(PREFIX)$(DESTDIR)/$(TARGET) uninstall: - rm -f $(PREFIX)$(DESTDIR)/mdp + $(RM) $(PREFIX)$(DESTDIR)/$(TARGET) -.PHONY: all clean install uninstall +.PHONY: all clean install src uninstall