-
Notifications
You must be signed in to change notification settings - Fork 2
/
configure
executable file
·119 lines (102 loc) · 2.44 KB
/
configure
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
#!/bin/sh
# hewwo's configure script
# somewhat inspired by oksh's configure
warn() {
echo $0: "$@"
}
Makefile() {
cat <<EOF >Makefile
# generated by ./configure
CFLAGS = -Wall -Wextra -g -O2
LIBS = -lm
OBJS := main.o net.o xdg.o linenoise/linenoise.o linenoise/encodings/utf8.o
BINDIR = $PREFIX/bin
LUADIR = $PREFIX/share/hewwo/$BRANCH
hewwo: \$(OBJS) lua/liblua.a
\$(CC) \$(LDFLAGS) -o \$@ \$^ \$(LIBS)
lua/liblua.a:
cd lua; make liblua.a
main.o: main.c hewwo.h
net.o: net.c hewwo.h
xdg.o: xdg.c hewwo.h config.h
.PHONY: clean install uninstall
clean:
rm -f hewwo \$(OBJS)
EOF
if [ -z "$DEVEL" ]; then
cat <<EOF >>Makefile
.PHONY: install uninstall
install: hewwo
install -d \${DESTDIR}\${BINDIR}
install -d \${DESTDIR}\${LUADIR}
install -c hewwo \${DESTDIR}\${BINDIR}
install -c *.lua \${DESTDIR}\${LUADIR}
uninstall:
rm -f \${DESTDIR}\${BINDIR}/hewwo
@echo Leaving behind \${DESTDIR}\${LUADIR}
@echo If you don\\'t have any local changes there, feel free to rm -rf that.
EOF
cat <<EOF >config.h
/* generated by ./configure */
#define LUADIR_LOCAL "/hewwo/$BRANCH"
#define LUADIR_GLOBAL "$PREFIX/share/hewwo/$BRANCH"
EOF
else
cat <<EOF >>Makefile
install:
@echo Not letting you install the development build. See ./configure --help.
@false
uninstall:
@echo Not letting you uninstall the development build. See ./configure --help.
@false
EOF
cat <<EOF >config.h
/* generated by ./configure */
#define LUADIR_LOCAL "/hewwo/$BRANCH"
#define LUADIR_GLOBAL "$PWD"
EOF
fi
}
help() {
cat <<EOF
Usage: ./configure [options]
Options:
--help or -h Display this help message
--prefix=PREFIX Prepare for installation in PREFIX [$PREFIX]
--branch=BRANCH Change the Lua branch [$BRANCH]
--devel Look for Lua files in the source directory (here) instead
of in PREFIX. If you're hacking on hewwo, this is what you
want. Otherwise, stay away.
EOF
}
PREFIX="${PREFIX:-/usr/local}"
BRANCH="edge"
task=Makefile
for opt
do
case "$opt" in
--help|-h)
task=help
;;
--prefix=*)
PREFIX=${opt#*=}
PREFIX_SET=1
;;
--branch=*)
BRANCH=${opt#*=}
;;
--devel)
DEVEL=1
;;
*)
warn "unknown option: $opt"
;;
esac
done
if [ -z "$PREFIX_SET" ] && [ -z "$DEVEL" ]; then
warn "No explicit --prefix set. You probably want --devel; see --help."
fi
if [ ! -z "$PREFIX_SET" ] && [ ! -z "$DEVEL" ]; then
warn "specifying a --prefix with --devel doesn't make sense"
fi
$task