2015-08-05 14:05:15 +02:00
|
|
|
##
|
|
|
|
## Tupfile for kakoune
|
|
|
|
## by lenormf
|
|
|
|
##
|
|
|
|
## How to use:
|
|
|
|
## Initialize a tup database in the main directory with `tup init`
|
|
|
|
## Create a symlink from `contrib/Tupfile` to `src/Tupfile`
|
|
|
|
## Start the build with the `tup` command
|
|
|
|
##
|
|
|
|
|
|
|
|
.gitignore
|
|
|
|
|
2016-12-22 08:06:57 +01:00
|
|
|
debug = yes
|
|
|
|
static = no
|
2015-08-05 14:05:15 +02:00
|
|
|
|
2016-12-22 08:06:57 +01:00
|
|
|
CXX = g++
|
2020-11-01 09:51:26 +01:00
|
|
|
CXXFLAGS = -pedantic -std=c++17 -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-address
|
2015-08-05 14:05:15 +02:00
|
|
|
CPPFLAGS =
|
2016-12-22 08:06:57 +01:00
|
|
|
LDFLAGS =
|
|
|
|
LIBS =
|
2015-08-05 14:05:15 +02:00
|
|
|
|
|
|
|
ifeq ($(debug),yes)
|
2020-11-01 09:51:26 +01:00
|
|
|
CPPFLAGS += -DKAK_DEBUG
|
|
|
|
CXXFLAGS += -g
|
|
|
|
suffix = .debug
|
2015-08-05 14:05:15 +02:00
|
|
|
else
|
2020-11-01 09:51:26 +01:00
|
|
|
ifeq ($(debug),no)
|
|
|
|
CXXFLAGS += -O3
|
|
|
|
suffix = .opt
|
|
|
|
else
|
|
|
|
error debug should be either yes or no
|
|
|
|
endif
|
2015-08-05 14:05:15 +02:00
|
|
|
endif
|
|
|
|
|
2016-12-22 08:06:57 +01:00
|
|
|
ifeq ($(static),yes)
|
2020-11-01 09:51:26 +01:00
|
|
|
PKG_CONFIG_FLAGS += --static
|
|
|
|
LDFLAGS += -static -pthread
|
2016-12-22 08:06:57 +01:00
|
|
|
endif
|
|
|
|
|
2015-08-05 14:05:15 +02:00
|
|
|
ifeq (@(TUP_PLATFORM),macosx)
|
2020-11-01 09:51:26 +01:00
|
|
|
LIBS += -lncurses
|
|
|
|
CPPFLAGS += -I/usr/local/opt/ncurses/include
|
|
|
|
LDFLAGS += -L/usr/local/opt/ncurses/lib
|
2015-08-05 14:05:15 +02:00
|
|
|
else
|
2020-11-01 09:51:26 +01:00
|
|
|
ifeq (@(TUP_PLATFORM),win32)
|
|
|
|
LIBS += -lncursesw -ldbghelp
|
|
|
|
CPPFLAGS += -D_XOPEN_SOURCE=700
|
|
|
|
else
|
|
|
|
LIBS += `pkg-config --libs ncursesw $(PKG_CONFIG_FLAGS)`
|
|
|
|
CPPFLAGS += `pkg-config --cflags ncursesw $(PKG_CONFIG_FLAGS)`
|
|
|
|
LDFLAGS += -rdynamic
|
|
|
|
endif
|
2015-08-05 14:05:15 +02:00
|
|
|
endif
|
|
|
|
|
2016-12-22 08:06:57 +01:00
|
|
|
ifeq ($(CXX),clang++)
|
2020-11-01 09:51:26 +01:00
|
|
|
CXXFLAGS += -frelaxed-template-template-args
|
|
|
|
endif
|
|
|
|
ifeq ($(CXX),g++)
|
|
|
|
CXXFLAGS += -Wno-init-list-lifetime
|
2016-12-22 08:06:57 +01:00
|
|
|
endif
|
|
|
|
|
2020-11-01 09:51:26 +01:00
|
|
|
!cxx = |> ^ CC %f^ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF %O.d -c %f -o %o |>
|
|
|
|
!ld = |> ^ LD %o^ $(CXX) $(LDFLAGS) %f $(LIBS) -o %o |>
|
|
|
|
!ln = |> ^ LN %o^ ln -sf %f %o |>
|
2015-08-05 14:05:15 +02:00
|
|
|
|
2020-11-01 09:51:26 +01:00
|
|
|
: foreach *.cc |> !cxx |> .%B$(suffix).o | .%B$(suffix).d {objs}
|
|
|
|
: |> ^ MK %o^ printf "%%s" "namespace Kakoune { const char* version = \"`if [ -f .version ]; then cat .version; elif [ -d ../.git ]; then git describe --tags HEAD; else echo \"unknown\"; fi`\"; }" > .version.cc.tmp; if cmp -s .version.cc.tmp .version.cc; then rm .version.cc.tmp; else mv .version.cc.tmp .version.cc; fi |> .version.cc
|
|
|
|
: .version.cc |> ^ CC %f^ $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c %f -o %o |> %B.o
|
|
|
|
: {objs} .version.o |> !ld |> kak$(suffix)
|
|
|
|
: kak$(suffix) |> !ln |> kak
|