X-Git-Url: https://git.danieliu.xyz/?a=blobdiff_plain;f=Makefile;h=1231bde2e119f78603b978944c013ada9f827fea;hb=698e2f33adf0ca6ada826a61b1db0c2dfce3bc3a;hp=46ed432bd48bc76a0d0b2a5714ebd190bcf2481d;hpb=3abe61887adc463e2d00c000012d1e2cff15f56f;p=smdp.git diff --git a/Makefile b/Makefile index 46ed432..1231bde 100644 --- a/Makefile +++ b/Makefile @@ -18,40 +18,50 @@ # 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 = $(wildcard src/*.c) +OBJECTS = $(SOURCES:.c=.o) +TARGET = mdp +DESTDIR = /usr/bin + +CURSES = ncursesw +LDFLAGS = -s + +ifeq (Windows_NT,$(OS)) + ifeq (,$(findstring CYGWIN,$(UNAME_S))) + CURSES := pdcurses + endif endif -OSTYPE := $(shell uname -o) -CURSES = ncursesw -ifeq (Windows_NT, $(OS)) -ifneq (Cygwin, $(OSTYPE)) -CURSES := pdcurses -CFLAGS += -DWIN32=1 +ifeq ($(UNAME_S),Darwin) + CURSES := ncurses + LDFLAGS := endif + +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) + +$(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: install -d $(PREFIX)$(DESTDIR) - install -m 755 mdp $(PREFIX)$(DESTDIR)/mdp + install -m 755 mdp $(PREFIX)$(DESTDIR)/$(TARGET) uninstall: - $(RM) $(PREFIX)$(DESTDIR)/mdp - -.PHONY: all clean install uninstall + $(RM) $(PREFIX)$(DESTDIR)/$(TARGET) +.PHONY: all clean install src uninstall