3 # try to get a tag and hash first
4 GITHASH
= $(shell git log
-1 --format
='%h' 2>/dev
/null
)
5 GITTAG
= $(shell git describe
--abbrev
=0 --tags 2>/dev
/null
)
7 # we have a tag and revcount from there
8 GITREVCOUNT
= $(shell git rev-list
--count
${GITTAG}..
2>/dev
/null
)
9 VERSION
= ${GITTAG}.r
${GITREVCOUNT}.g
${GITHASH}
10 else ifneq ($(GITHASH
),)
11 # we have no tags in git, so just use revision count an hash for now
12 GITREVCOUNT
= $(shell git rev-list
--count HEAD
)
13 VERSION
= 0.r
${GITREVCOUNT}.g
${GITHASH}
16 SRCDIR
= $(realpath
$(dir $(firstword $(MAKEFILE_LIST
))))
18 ALL
= *.c
*.h config.mk Makefile LICENSE README.md vis
.1
20 DEPS_ROOT
= $(SRCDIR
)/dependency
/install
21 DEPS_PREFIX
= $(DEPS_ROOT
)/usr
22 DEPS_BIN
= $(DEPS_PREFIX
)/bin
23 DEPS_LIB
= $(DEPS_PREFIX
)/lib
24 DEPS_INC
= $(DEPS_PREFIX
)/include
27 LIBMUSL_SHA1
= e098ce88e7dd4398c178240b4c380771c5b4fe6b
29 LIBNCURSES
= ncurses-6.0
30 LIBNCURSES_SHA1
= acd606135a5124905da770803c05f1f20dd3b21c
32 LIBTERMKEY
= libtermkey-0.18
33 LIBTERMKEY_SHA1
= 0a78ba7aaa2f3b53f2273268366fef349c9be4ab
36 #LIBLUA_SHA1 = 1676c6a041d90b6982db8cef1e5fb26000ab6dee
38 LIBLUA_SHA1
= ef15259421197e3d85b7d6e4871b8c26fd82c1cf
40 #LIBLUA_SHA1 = b3882111ad02ecc6b972f8c1241647905cb2e3fc
43 LIBLPEG_SHA1
= 64a0920c9243b624a277c987d2219b6c50c43971
45 LIBNCURSES_CONFIG
= --disable-database
--with-fallbacks
=st
,st-256color
,xterm
,xterm-256color
,vt100 \
46 --with-shared
--enable-widec
--enable-ext-colors
--with-termlib
=tinfo \
47 --without-ada
--without-cxx
--without-cxx-binding
--without-manpages
--without-progs \
48 --without-tests
--without-progs
--without-debug
--without-profile \
49 --without-cxx-shared
--without-termlib
--without--ticlib
54 cp config.def.h config.h
56 vis
: config.h config.mk
*.c
*.h
57 @echo
${CC} ${CFLAGS} ${CFLAGS_VIS} *.c
${LDFLAGS} ${LDFLAGS_VIS} -o
$@
58 @
${CC} ${CFLAGS} ${CFLAGS_VIS} *.c
${LDFLAGS} ${LDFLAGS_VIS} -o
$@
61 @
$(MAKE
) CFLAGS_VIS
='${DEBUG_CFLAGS_VIS}'
64 @
$(MAKE
) CFLAGS_VIS
='${DEBUG_CFLAGS_VIS} -pg'
68 @
rm -f vis vis-
${VERSION}.
tar.gz
71 @echo creating
dist tarball
72 @git archive
--prefix=vis-
${VERSION}/ -o vis-
${VERSION}.
tar.gz HEAD
75 @echo stripping executable
77 @echo installing executable file to
${DESTDIR}${PREFIX}/bin
78 @mkdir
-p
${DESTDIR}${PREFIX}/bin
79 @cp
-f vis
${DESTDIR}${PREFIX}/bin
80 @chmod
755 ${DESTDIR}${PREFIX}/bin
/vis
81 @cp
-f vis-open
${DESTDIR}${PREFIX}/bin
82 @chmod
755 ${DESTDIR}${PREFIX}/bin
/vis-open
83 @cp
-f vis-copy
${DESTDIR}${PREFIX}/bin
84 @chmod
755 ${DESTDIR}${PREFIX}/bin
/vis-copy
85 @cp
-f vis-paste
${DESTDIR}${PREFIX}/bin
86 @chmod
755 ${DESTDIR}${PREFIX}/bin
/vis-paste
87 @echo installing support files to
${DESTDIR}${SHAREPREFIX}
88 @mkdir
-p
${DESTDIR}${SHAREPREFIX}
89 @cp
-r visrc.lua lexers
${DESTDIR}${SHAREPREFIX}
90 @echo installing manual page to
${DESTDIR}${MANPREFIX}/man1
91 @mkdir
-p
${DESTDIR}${MANPREFIX}/man1
92 @sed
"s/VERSION/${VERSION}/g" < vis
.1 > ${DESTDIR}${MANPREFIX}/man1
/vis
.1
93 @chmod
644 ${DESTDIR}${MANPREFIX}/man1
/vis
.1
96 @echo removing executable file from
${DESTDIR}${PREFIX}/bin
97 @
rm -f
${DESTDIR}${PREFIX}/bin
/vis
98 @
rm -f
${DESTDIR}${PREFIX}/bin
/vis-open
99 @
rm -f
${DESTDIR}${PREFIX}/bin
/vis-copy
100 @
rm -f
${DESTDIR}${PREFIX}/bin
/vis-paste
101 @echo removing manual page from
${DESTDIR}${MANPREFIX}/man1
102 @
rm -f
${DESTDIR}${MANPREFIX}/man1
/vis
.1
103 @echo removing support files from
${DESTDIR}${SHAREPREFIX}
104 @
[ ! -z
"${SHAREPREFIX}" ] && rm -rf
${DESTDIR}${SHAREPREFIX}
109 dependency
/sources
/musl-
%: | dependency
/sources
110 wget
-c
-O
$@.part http
://www.musl-libc.org
/releases
/$(LIBMUSL
).
tar.gz
112 [ -z
$(LIBMUSL_SHA1
) ] ||
(echo
'$(LIBMUSL_SHA1) $@' | sha1sum
-c
)
114 dependency
/sources
/extract-libmusl
: dependency
/sources
/$(LIBMUSL
).
tar.gz
115 tar xzf
$< -C
$(dir $<)
118 dependency
/sources
/configure-libmusl
: dependency
/sources
/extract-libmusl
119 cd
$(dir $<)/$(LIBMUSL
) && .
/configure
--prefix=$(DEPS_PREFIX
) --syslibdir
=$(DEPS_PREFIX
)/lib
122 dependency
/sources
/build-libmusl
: dependency
/sources
/configure-libmusl
123 $(MAKE
) -C
$(dir $<)/$(LIBMUSL
)
126 dependency
/sources
/install-libmusl
: dependency
/sources
/build-libmusl
127 $(MAKE
) -C
$(dir $<)/$(LIBMUSL
) install
130 dependency
/sources
/ncurses-
%: | dependency
/sources
131 wget
-c
-O
$@.part http
://ftp.gnu.org
/gnu
/ncurses
/$(LIBNCURSES
).
tar.gz
133 [ -z
$(LIBNCURSES_SHA1
) ] ||
(echo
'$(LIBNCURSES_SHA1) $@' | sha1sum
-c
)
135 dependency
/sources
/extract-libncurses
: dependency
/sources
/$(LIBNCURSES
).
tar.gz
136 tar xzf
$< -C
$(dir $<)
139 dependency
/sources
/configure-libncurses
: dependency
/sources
/extract-libncurses
140 cd
$(dir $<)/$(LIBNCURSES
) && .
/configure
--prefix=/usr
--libdir=/usr
/lib
$(LIBNCURSES_CONFIG
)
143 dependency
/sources
/build-libncurses
: dependency
/sources
/configure-libncurses
144 $(MAKE
) -C
$(dir $<)/$(LIBNCURSES
)
147 dependency
/sources
/install-libncurses
: dependency
/sources
/build-libncurses
148 $(MAKE
) -C
$(dir $<)/$(LIBNCURSES
) install.libs DESTDIR
=$(DEPS_ROOT
)
151 dependency
/sources
/libtermkey-
%: | dependency
/sources
152 wget
-c
-O
$@.part http
://www.leonerd.org.uk
/code
/libtermkey
/$(LIBTERMKEY
).
tar.gz
154 [ -z
$(LIBTERMKEY_SHA1
) ] ||
(echo
'$(LIBTERMKEY_SHA1) $@' | sha1sum
-c
)
156 dependency
/sources
/extract-libtermkey
: dependency
/sources
/$(LIBTERMKEY
).
tar.gz
157 tar xzf
$< -C
$(dir $<)
160 dependency
/sources
/build-libtermkey
: dependency
/sources
/extract-libtermkey
161 # TODO no sane way to avoid pkg-config and specify LDFLAGS?
162 sed
-i
's/LDFLAGS+=-lncurses$$/LDFLAGS+=-lncursesw/g' $(dir $<)/$(LIBTERMKEY
)/Makefile
163 $(MAKE
) -C
$(dir $<)/$(LIBTERMKEY
) PREFIX
=$(DEPS_PREFIX
) termkey.h libtermkey.la
166 dependency
/sources
/install-libtermkey
: dependency
/sources
/build-libtermkey
167 $(MAKE
) -C
$(dir $<)/$(LIBTERMKEY
) PREFIX
=$(DEPS_PREFIX
) install-inc install-lib
170 dependency
/sources
/lua-
%: | dependency
/sources
171 wget
-c
-O
$@.part http
://www.lua.org
/ftp
/$(LIBLUA
).
tar.gz
173 [ -z
$(LIBLUA_SHA1
) ] ||
(echo
'$(LIBLUA_SHA1) $@' | sha1sum
-c
)
175 dependency
/sources
/extract-liblua
: dependency
/sources
/$(LIBLUA
).
tar.gz
176 tar xzf
$< -C
$(dir $<)
179 dependency
/sources
/patch-liblua
: dependency
/sources
/extract-liblua
180 cd
$(dir $<) && ([ -e
$(LIBLUA
)-lpeg.patch
] || wget http
://www.brain-dump.org
/projects
/vis
/$(LIBLUA
)-lpeg.patch
)
181 cd
$(dir $<)/$(LIBLUA
) && patch
-p1
< ..
/$(LIBLUA
)-lpeg.patch
184 dependency
/sources
/build-liblua
: dependency
/sources
/patch-liblua dependency
/sources
/install-liblpeg
185 $(MAKE
) -C
$(dir $<)/$(LIBLUA
)/src
all CC
=$(CC
) MYCFLAGS
="-DLUA_COMPAT_5_1 -DLUA_COMPAT_5_2 -DLUA_COMPAT_ALL -DLUA_USE_POSIX -DLUA_USE_DLOPEN -fPIC" MYLIBS
="-Wl,-E -ldl -lncursesw -lm"
186 #$(MAKE) -C $(dir $<)/$(LIBLUA) posix CC=$(CC)
189 dependency
/sources
/install-liblua
: dependency
/sources
/build-liblua
190 $(MAKE
) -C
$(dir $<)/$(LIBLUA
) INSTALL_TOP
=$(DEPS_PREFIX
) install
193 dependency
/sources
/lpeg-
%: | dependency
/sources
194 wget
-c
-O
$@.part http
://www.inf.puc-rio.br
/~roberto
/lpeg
/$(LIBLPEG
).
tar.gz
196 [ -z
$(LIBLPEG_SHA1
) ] ||
(echo
'$(LIBLPEG_SHA1) $@' | sha1sum
-c
)
198 dependency
/sources
/extract-liblpeg
: dependency
/sources
/$(LIBLPEG
).
tar.gz
199 tar xzf
$< -C
$(dir $<)
202 dependency
/sources
/build-liblpeg
: dependency
/sources
/extract-liblpeg
203 $(MAKE
) -C
$(dir $<)/$(LIBLPEG
) LUADIR
=..
/$(LIBLUA
)/src CC
=$(CC
)
206 dependency
/sources
/install-liblpeg
: dependency
/sources
/build-liblpeg dependency
/sources
/extract-liblua
207 cp
$(dir $<)/$(LIBLPEG
)/*.o
$(dir $<)/$(LIBLUA
)/src
210 dependencies
: dependency
/sources
/install-libtermkey dependency
/sources
/install-liblua dependency
/sources
/install-liblpeg
212 dependencies-full
: dependency
/sources
/install-libncurses dependencies
215 CFLAGS
="$(CFLAGS) -I$(DEPS_INC)" LDFLAGS
="$(LDFLAGS) -L$(DEPS_LIB)" $(MAKE
) CFLAGS_LUA
= CFLAGS_TERMKEY
= LDFLAGS_LUA
="-llua -lm" LDFLAGS_TERMKEY
=-ltermkey
216 @echo Run with
: LD_LIBRARY_PATH
=$(DEPS_LIB
) VIS_PATH
=. .
/vis
218 standalone
: dependency
/sources
/install-libmusl
219 PATH
=$(DEPS_BIN
):$$PATH CC
=musl-gcc PKG_CONFIG_PATH
= PKG_CONFIG_LIBDIR
= CFLAGS
=-I
$(DEPS_INC
)/ncursesw
$(MAKE
) dependencies-full
220 PATH
=$(DEPS_BIN
):$$PATH CC
=musl-gcc PKG_CONFIG_PATH
= PKG_CONFIG_LIBDIR
= CFLAGS
="--static -Wl,--as-needed -I$(DEPS_INC)/ncursesw" $(MAKE
) CFLAGS_LIBS
= debug
221 @echo Run with
: VIS_PATH
=. .
/vis
223 .PHONY
: all clean dist install uninstall debug profile standalone dependencies dependencies-full local