-
Notifications
You must be signed in to change notification settings - Fork 3
/
GNUmakefile
179 lines (153 loc) · 4.85 KB
/
GNUmakefile
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#
# $ GNUmakefile $
#
# Author: Tomi Ollila -- too ät iki piste fi
#
# Copyright (c) 2017 Tomi Ollila
# All rights reserved
#
# Created: Wed 16 Aug 2017 21:09:05 EEST too
# Last modified: Fri 29 Apr 2022 16:44:59 +0300 too
SHELL = /bin/sh
BIN := mxtx mxtx-io mxtx-rshd mxtx-rsh mxtx-socksproxy mxtx-dgramtunneld
BIN += ldpreload-i2ubind.so ldpreload-i2uconnect5.so
BIN += ldpreload-vsfa.so ldpreload-moshclienthax.so ldpreload-tcp1271conn.so
# Note: all source file dependencies may not be listed (usually not a problem)
# do `make clean all` at the end of development session...
all: $(BIN)
mxtx: src/mxtx.c libmxtx.a $(wildcard .git/index)
sh $<
mxtx-lib.o: src/mxtx-lib.c src/mxtx-lib.h
sh $<
libmxtx.a: src/mxtx-lib.c src/mxtx-lib.h
perl -x $<
mxtx-io: src/mxtx-io.c libmxtx.a
sh $<
mxtx-rshd: src/mxtx-rshd.c src/lpktread.ch libmxtx.a
sh $<
mxtx-rsh: src/mxtx-rsh.c src/lpktread.ch libmxtx.a
sh $<
mxtx-socksproxy: src/mxtx-socksproxy.c libmxtx.a
sh $<
mxtx-dgramtunneld: src/mxtx-dgramtunneld.c libmxtx.a
sh $<
ldpreload-i2ubind.so ldpreload-i2uconnect5.so: src/ldpreload-i2usocket.c
sh $<
ldpreload-%.so: src/ldpreload-%.c
sh $<
YES ?= NO
install: $(BIN)
sed '1,/^[email protected]:/d;/^#.#eos/q' GNUmakefile | /bin/sh -s YES=$(YES) $(BIN)
install.sh:
test -n "$1" || exit 1 # embedded shell script; not to be made directly
die () { exit 1; }
set -euf
export LC_ALL=C LANG=C
echo
if test "$1" = YES=YES
then mmkdir () { test -d "$1" || mkdir -vp "$1"; }
mmkdir $HOME/bin/
mmkdir $HOME/.local/share/mxtx/
shift
imsg=true
echo strip "$@" >&2; strip "$@"
xcp () { test ! -d "$3" || set -- "$1" 2 "${3%/}/${1##*/}"
cmp "$1" "$3" >/dev/null 2>&1 &&
echo "'$1' and '$3' identical" ||
cp -f -v "$1" "$3"; }
echo Copying:
elif test "$1" = YES=DIFF # "undocumented" option...
then imsg=true
xcp () {
test ! -d "$3" || set -- "$1" 2 "${3%/}/${1##*/}"
test -e "$3" || { echo "'$3': no file"; return; }
cmp "$1" "$3" >/dev/null 2>&1 ||
diff -u "$3" "$1" || :
}
echo Diffing...
else
imsg=false
xcp () { echo '' "$@"; }
echo Would install:
fi
xcp mxtx as $HOME/bin/.mxtx
xcp ioio.pl to $HOME/bin/
xcp mxtx.el to $HOME/.local/share/mxtx/
xcp addhost.sh to $HOME/.local/share/mxtx/
xcp mxtx-rshd to $HOME/.local/share/mxtx/
xcp mxtx-io to $HOME/bin/
xcp mxtx-rsh to $HOME/bin/
xcp mxtx-cp.sh as $HOME/bin/mxtx-cp
xcp mxtx-apu.sh to $HOME/bin/
xcp mxtx-mosh.pl as $HOME/bin/mxtx-mosh
xcp mxtx-dgramtunneld to $HOME/.local/share/mxtx/
xcp mxtx-socksproxy as $HOME/.local/share/mxtx/socksproxy
xcp ldpreload-i2ubind.so to $HOME/.local/share/mxtx/
xcp ldpreload-i2uconnect5.so to $HOME/.local/share/mxtx/
xcp ldpreload-vsfa.so to $HOME/.local/share/mxtx/
xcp ldpreload-moshclienthax.so to $HOME/.local/share/mxtx/
xcp ldpreload-tcp1271conn.so to $HOME/.local/share/mxtx/
echo
$imsg || {
echo Enter '' make install YES=YES '' to do so.
echo
}
# #eos
exit 1 # not reached
# possibly partial uninstall
unin:
cd "$$HOME" && exec rm -f \
.local/share/mxtx/mxtx[.-]* \
.local/share/mxtx/ldpreload-* \
.local/share/mxtx/addhost.sh \
.local/share/mxtx/socksproxy \
./bin/.mxtx bin/mxtx-* bin/ioio.pl
.PHONY: git-head
git-head:
sed '1,/^[email protected]:/d;/^#.#eos/q' GNUmakefile | /bin/sh -s $@
git-head.sh:
test -n "$1" || exit 1 # embedded shell script; not to be made directly
die () { printf %s\\n "$*" >&2; exit 1; }
set -euf
# #test -z "`exec git status --porcelain -uno`" || die changes in working copy
fmt='format:commit %H %h%ntree %T %t%n'
fmt=$fmt'Author: %an <%ae>%nAuthorDate: %aD%n'
fmt=$fmt'Commit: %cn <%ce>%nCommitDate: %cD%n%n% B'
git log --pretty="$fmt" --name-status -1 > "$1"
# #eos
exit 1 # not reached
.PHONY: dist
dist: #git-head
@test -z "`exec git status --porcelain -uno`" || \
echo Note: not taking changes from \'dirty\' working tree!
@set -euf; set x `exec git log -1 --pretty='%h %ci'`; s=$$3-g$$2; \
set -x; exec git archive --prefix=mxtx-$$s/ -o mxtx-$$s.tar.gz HEAD
# convenience helper to update mxtx over an mxtx link
.PHONY: remote-update
remote-update:
sed '1,/^[email protected]:/d;/^#.#eos/q' GNUmakefile | /bin/sh -s "$(MAKE)" "$D"
remote-update.sh:
test -n "$1" || exit 1 # embedded shell script; not to be made directly
die () { printf %s\\n "$*" >&2; exit 1; }
set -euf
export LC_ALL=C LANG=C
test -n "$2" || die Usage':' $1 remote-update D=dest
make=$1 D=$2
set x `exec git log -1 --pretty='%h %ci'`; s=$3-g$2;
die () { exit 1; }
set -x
test -f mxtx-$s.tar.gz || die mxtx-$s.tar.gz not made "($make a)"
mxtx-rsh -n "$D" . /bin/true
set +e
mxtx-rsh "$D" . tar zxvf - < mxtx-$s.tar.gz
mxtx-rsh -n "$D" cd mxtx-$s '&&' make install YES=YES
mxtx-rsh -n "$D" . rm -rf mxtx-$s
# #eos
exit 1 # not reached
clean:
rm -rf $(BIN) mxtx-lib.o libmxtx.a git-head *~ src/*~ _tmp
.SUFFIXES:
MAKEFLAGS += --no-builtin-rules --warn-undefined-variables
# Local variables:
# mode: makefile
# End: