2015-09-21 15:38:09 +03:00
|
|
|
debug ?= yes
|
2016-11-03 01:28:05 +03:00
|
|
|
static ?= no
|
2017-11-18 07:10:08 +03:00
|
|
|
gzip_man ?= yes
|
|
|
|
|
|
|
|
ifneq ($(gzip_man),yes)
|
|
|
|
ifneq ($(gzip_man),no)
|
|
|
|
$(error gzip_man should be either yes or no)
|
|
|
|
endif
|
|
|
|
endif
|
2015-11-05 19:59:29 +03:00
|
|
|
|
2015-09-21 15:38:09 +03:00
|
|
|
ifeq ($(debug),yes)
|
|
|
|
CPPFLAGS += -DKAK_DEBUG
|
|
|
|
suffix := .debug
|
|
|
|
else
|
|
|
|
ifeq ($(debug),no)
|
|
|
|
CXXFLAGS += -O3
|
|
|
|
suffix := .opt
|
|
|
|
else
|
|
|
|
$(error debug should be either yes or no)
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2017-05-20 23:50:25 +03:00
|
|
|
sources := $(sort $(wildcard *.cc))
|
2015-09-21 15:38:09 +03:00
|
|
|
objects := $(addprefix ., $(sources:.cc=$(suffix).o))
|
|
|
|
deps := $(addprefix ., $(sources:.cc=$(suffix).d))
|
2011-09-02 20:51:20 +04:00
|
|
|
|
2017-11-17 08:32:30 +03:00
|
|
|
PKG_CONFIG ?= pkg-config
|
|
|
|
|
2013-12-24 01:26:07 +04:00
|
|
|
PREFIX ?= /usr/local
|
2014-10-08 23:23:20 +04:00
|
|
|
DESTDIR ?= # root dir
|
2013-12-24 01:26:07 +04:00
|
|
|
|
|
|
|
bindir := $(DESTDIR)$(PREFIX)/bin
|
|
|
|
sharedir := $(DESTDIR)$(PREFIX)/share/kak
|
|
|
|
docdir := $(DESTDIR)$(PREFIX)/share/doc/kak
|
2016-02-04 12:53:41 +03:00
|
|
|
mandir := $(DESTDIR)$(PREFIX)/share/man/man1
|
2013-12-24 01:26:07 +04:00
|
|
|
|
2014-04-03 04:54:27 +04:00
|
|
|
os := $(shell uname)
|
|
|
|
|
|
|
|
ifeq ($(os),Darwin)
|
2017-11-01 09:08:03 +03:00
|
|
|
LIBS += -lncurses
|
|
|
|
CPPFLAGS += -I$(PREFIX)/opt/ncurses/include -I/opt/local/include
|
|
|
|
LDFLAGS += -L$(PREFIX)/opt/ncurses/lib -L/opt/local/lib
|
2015-11-02 23:22:00 +03:00
|
|
|
else ifeq ($(os),FreeBSD)
|
2017-11-01 09:08:03 +03:00
|
|
|
LIBS += -ltinfow -lncursesw
|
2015-11-02 23:22:00 +03:00
|
|
|
CPPFLAGS += -I/usr/local/include
|
|
|
|
LDFLAGS += -L/usr/local/lib
|
2015-09-25 01:36:29 +03:00
|
|
|
else ifeq ($(os),Haiku)
|
2017-11-01 09:08:03 +03:00
|
|
|
LIBS += -lncursesw -lnetwork -lbe
|
2015-11-02 21:14:34 +03:00
|
|
|
else ifeq ($(os),DragonFly)
|
2017-11-01 09:08:03 +03:00
|
|
|
LIBS += -lncursesw
|
2015-11-02 21:14:34 +03:00
|
|
|
CPPFLAGS += -I/usr/local/include
|
|
|
|
LDFLAGS += -L/usr/local/lib
|
2015-06-16 20:49:56 +03:00
|
|
|
else ifneq (,$(findstring CYGWIN,$(os)))
|
2016-10-13 02:19:27 +03:00
|
|
|
CPPFLAGS += -D_XOPEN_SOURCE=700
|
2017-11-01 09:08:03 +03:00
|
|
|
LIBS += -lncursesw -ldbghelp
|
2014-04-03 04:54:27 +04:00
|
|
|
else
|
2017-11-17 08:32:30 +03:00
|
|
|
LIBS += $(shell $(PKG_CONFIG) --libs ncursesw)
|
|
|
|
CPPFLAGS += $(shell $(PKG_CONFIG) --cflags ncursesw)
|
2015-05-27 20:45:52 +03:00
|
|
|
LDFLAGS += -rdynamic
|
2013-11-07 22:49:12 +04:00
|
|
|
endif
|
2011-09-02 20:51:20 +04:00
|
|
|
|
2016-11-03 01:28:05 +03:00
|
|
|
ifeq ($(static),yes)
|
|
|
|
LIBS += -ltinfo -lgpm
|
|
|
|
LDFLAGS += -static -pthread
|
|
|
|
endif
|
|
|
|
|
2016-03-12 18:27:54 +03:00
|
|
|
CXXFLAGS += -pedantic -std=gnu++14 -g -Wall -Wextra -Wno-unused-parameter -Wno-reorder -Wno-sign-compare -Wno-address -Wno-noexcept-type -Wno-unknown-attributes -Wno-unknown-warning-option
|
2015-11-05 19:59:29 +03:00
|
|
|
|
2016-09-25 09:12:37 +03:00
|
|
|
all : kak
|
2017-02-27 23:11:56 +03:00
|
|
|
|
|
|
|
kak : kak$(suffix)
|
|
|
|
ln -sf $< $@
|
|
|
|
|
|
|
|
kak$(suffix) : $(objects)
|
2013-03-15 17:03:12 +04:00
|
|
|
$(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) $(LIBS) -o $@
|
2011-09-02 20:51:20 +04:00
|
|
|
|
2012-08-08 15:39:31 +04:00
|
|
|
-include $(deps)
|
2011-09-02 20:51:20 +04:00
|
|
|
|
2015-09-21 15:38:09 +03:00
|
|
|
.%$(suffix).o: %.cc
|
|
|
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $<
|
2011-09-02 20:51:20 +04:00
|
|
|
|
2016-02-04 16:10:04 +03:00
|
|
|
# Generate the man page
|
2017-11-18 07:10:08 +03:00
|
|
|
ifeq ($(gzip_man),yes)
|
2017-11-18 19:33:13 +03:00
|
|
|
../doc/kak.1.gz: ../doc/kak.1.asciidoc
|
2016-02-11 21:26:08 +03:00
|
|
|
a2x --no-xmllint -f manpage $<
|
2017-05-20 23:49:36 +03:00
|
|
|
gzip -n -9 -f $(basename $<)
|
2017-11-18 07:10:08 +03:00
|
|
|
man: ../doc/kak.1.gz
|
|
|
|
else
|
2017-11-18 19:33:13 +03:00
|
|
|
../doc/kak.1: ../doc/kak.1.asciidoc
|
2017-11-18 07:10:08 +03:00
|
|
|
a2x --no-xmllint -f manpage $<
|
|
|
|
man: ../doc/kak.1
|
|
|
|
endif
|
2016-02-03 22:09:41 +03:00
|
|
|
|
2016-09-25 09:12:37 +03:00
|
|
|
check: test
|
2014-10-11 22:50:30 +04:00
|
|
|
test:
|
|
|
|
cd ../test && ./run
|
2016-09-25 09:12:37 +03:00
|
|
|
|
|
|
|
TAGS: tags
|
2011-09-08 18:28:42 +04:00
|
|
|
tags:
|
|
|
|
ctags -R
|
|
|
|
|
2012-10-11 00:44:06 +04:00
|
|
|
clean:
|
2016-09-25 09:12:37 +03:00
|
|
|
rm -f .*.o .*.d
|
|
|
|
|
|
|
|
distclean: clean
|
2017-03-26 10:38:24 +03:00
|
|
|
rm -f kak kak$(suffix)
|
2017-11-18 07:10:08 +03:00
|
|
|
find ../doc -type f \( -name \*\\.gz -o -name \*\\.1 \) -exec rm -f '{}' +
|
2016-09-25 09:12:37 +03:00
|
|
|
|
|
|
|
installdirs:
|
2017-02-27 23:11:27 +03:00
|
|
|
install -d $(bindir) \
|
|
|
|
$(sharedir)/rc/base \
|
|
|
|
$(sharedir)/rc/core \
|
2016-09-25 09:12:37 +03:00
|
|
|
$(sharedir)/rc/extra \
|
|
|
|
$(sharedir)/colors \
|
2017-08-03 11:00:02 +03:00
|
|
|
$(sharedir)/doc \
|
|
|
|
$(docdir) \
|
2016-09-25 09:12:37 +03:00
|
|
|
$(mandir)
|
|
|
|
|
2017-11-02 05:03:24 +03:00
|
|
|
install: kak man installdirs
|
2017-02-27 23:11:27 +03:00
|
|
|
install -m 0755 kak $(bindir)
|
|
|
|
install -m 0644 ../share/kak/kakrc $(sharedir)
|
2017-11-02 05:03:24 +03:00
|
|
|
install -m 0644 ../doc/pages/*.asciidoc $(sharedir)/doc
|
2017-02-27 23:11:27 +03:00
|
|
|
install -m 0644 ../rc/base/* $(sharedir)/rc/base
|
|
|
|
install -m 0644 ../rc/core/* $(sharedir)/rc/core
|
|
|
|
install -m 0644 ../rc/extra/* $(sharedir)/rc/extra
|
|
|
|
[ -e $(sharedir)/autoload ] || ln -s rc $(sharedir)/autoload
|
|
|
|
install -m 0644 ../colors/* $(sharedir)/colors
|
|
|
|
install -m 0644 ../README.asciidoc $(docdir)
|
2017-11-18 07:10:08 +03:00
|
|
|
ifeq ($(gzip_man),yes)
|
2017-02-27 23:11:27 +03:00
|
|
|
install -m 0644 ../doc/kak.1.gz $(mandir)
|
2017-11-18 07:10:08 +03:00
|
|
|
else
|
|
|
|
install -m 0644 ../doc/kak.1 $(mandir)
|
|
|
|
endif
|
2016-09-25 09:12:37 +03:00
|
|
|
|
|
|
|
install-strip: install
|
|
|
|
strip -s $(bindir)/kak
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm -rf $(bindir)/kak \
|
2017-02-27 23:11:27 +03:00
|
|
|
$(sharedir) \
|
2016-09-25 09:12:37 +03:00
|
|
|
$(docdir) \
|
2017-11-18 07:10:08 +03:00
|
|
|
$(mandir)/kak.1.gz \
|
|
|
|
$(mandir)/kak.1
|
2016-09-25 09:12:37 +03:00
|
|
|
|
|
|
|
.PHONY: check TAGS clean distclean installdirs install install-strip uninstall
|
2017-11-02 05:03:24 +03:00
|
|
|
.PHONY: tags test man kak
|