forked from ericpruitt/static-glibc-tmux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (120 loc) · 3.76 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Author: Eric Pruitt (http://www.codevat.com)
# License: 2-Clause BSD (http://opensource.org/licenses/BSD-2-Clause)
# Description: This Makefile is designed to create a statically linked tmux
# binary without any dependencies on the host system's version of glibc.
# Directory in which to install tmux.
INSTALLDIR=$(HOME)/tmux
# Folder in $PATH where symlinks to the executables are placed.
BINDIR=$(HOME)/bin
# Extension to use when creating a compressed, distributable archive.
DISTEXTENSION=bz2
# URL of the libevent tarball
LIBEVENT_TARBALL_URL=https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# Git repository URL for tmux
TMUX_GIT_REPOSITORY_URL=https://github.com/tmux/tmux.git
# Basename of the compressed archive
DISTTARGET=tmux.$(DISTEXTENSION)
# Determines whether or not `make` is automatically executed inside $INSTALLDIR
# to create symlinks to the executables. Can be "false" or "true" but should
# generally not be modified by the end-user and only exists to simplify
# creation of distributable archives.
DISTMAKE=true
all: tmux-src/tmux
libevent.tar.gz:
wget $(LIBEVENT_TARBALL_URL) -O $@
libevent: libevent.tar.gz
tar xf $^
mv libevent*/ $@
libevent/configure: libevent
libevent/Makefile: libevent/configure
cd libevent && ./configure --prefix="$$PWD/build" --disable-shared
libevent/build: libevent/Makefile
if ! stat libevent/*.orig > /dev/null 2>&1; then \
cd libevent || exit 1; \
patch -b -p1 < ../libevent-static-build.patch; \
fi
cd libevent && $(MAKE) install
tmux-src:
git clone $(TMUX_GIT_REPOSITORY_URL) $@; \
cd $@; \
git fetch origin --tags; \
git checkout 1.9a; \
update: tmux-src
@set -e; \
cd tmux-src; \
echo 'Checking for updates...'; \
git fetch origin; \
if git diff origin/master HEAD --quiet; then \
echo 'No updates for master branch found.'; \
exit 1; \
else \
(cd .. && $(MAKE) clean-tmux); \
git merge origin/master; \
fi
tmux-src/autogen.sh: tmux-src
tmux-src/configure: tmux-src/autogen.sh
cd tmux-src && ./autogen.sh
tmux-src/Makefile: tmux-src/configure libevent/build
cd tmux-src && \
./configure \
--enable-static \
CFLAGS="-I$$PWD/../libevent/build/include" \
LDFLAGS="-L$$PWD/../libevent/build/lib \
-L$$PWD/../libevent/build/include" \
LIBEVENT_CFLAGS="-I$$PWD/../libevent/build/include" \
LIBEVENT_LIBS="-L$$PWD/../libevent/build/lib -levent"
tmux-src/tmux: tmux-src/Makefile
@if ! stat tmux-src/*.orig > /dev/null 2>&1; then \
cd tmux-src || exit 1; \
patch -b -p1 < ../tmux-static-build.patch; \
fi
cd tmux-src && $(MAKE)
clean-tmux:
@if [ -e tmux-src ]; then \
set -e; \
cd tmux-src; \
git reset --hard; \
git clean -x -f -d -q; \
fi
$(INSTALLDIR): tmux-src/tmux
@echo 'Installing:'
@mkdir $(INSTALLDIR) $(INSTALLDIR)/man1
@cp tmux.sh tmux-src/tmux $(INSTALLDIR)
@cp Makefile.dist $(INSTALLDIR)/Makefile
@cp tmux-src/tmux.1 $(INSTALLDIR)/man1
@echo "- $(INSTALLDIR)"
@if $(DISTMAKE); then \
cd $(INSTALLDIR) || exit 1; \
$(MAKE) -s BINDIR=$(BINDIR) install; \
fi
install: $(INSTALLDIR)
uninstall:
@if [ -e $(INSTALLDIR)/Makefile ]; then \
set -e; \
cd $(INSTALLDIR); \
$(MAKE) -s uninstall; \
echo '- $(INSTALLDIR)'; \
rm -rf $(INSTALLDIR); \
else \
echo 'Nothing to uninstall.'; \
exit 1; \
fi
$(DISTTARGET): tmux-src/tmux
@$(MAKE) -s INSTALLDIR=$(PWD)/tmux DISTMAKE=false install > /dev/null
@tar acf $@ tmux/
@rm -rf tmux/
@echo 'Created distributable, compressed archive: $@'
dist: $(DISTTARGET)
clean: clean-tmux
clean-libevent:
@if [ -e libevent ]; then \
set -e; \
cd libevent; \
rm -rf build; \
$(MAKE) distclean; \
fi
cleaner: clean-tmux clean-libevent
cleanest:
rm -rf libevent tmux-src $(DISTTARGET) libevent.tar.gz
.PHONY: all clean-tmux clean clean-libevent cleaner cleanest dist install \
uninstall update