-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·78 lines (65 loc) · 1.51 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
#!/bin/bash
# Default values
PREFIX="/usr/local"
# Parse command line arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--prefix=*)
PREFIX="${1#*=}"
;;
--help)
echo "Usage: ./configure [--prefix=PATH] [--help]"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information."
exit 1
;;
esac
shift
done
# Generate Makefile
cat > Makefile <<EOF
NAME = hina
PREFIX = $PREFIX
MAN_DIR = man
MAN_FILES = \$(wildcard \$(MAN_DIR)/*.man)
GZ_FILES = \$(patsubst \$(MAN_DIR)/%.man,\$(MAN_DIR)/%.1,\$(MAN_FILES))
default: build man
clean:
@echo "Cleaning build dir"
@rm -rf target/*
@echo "Cleaning using cargo"
@cargo clean
@echo "Cleaning man dir"
@rm man/*.1
check:
@echo "Checking \$(NAME)"
@cargo check
run:
@echo "Running debug"
@cargo run
build:
@echo "Building release"
@cargo build --release
man: \$(GZ_FILES)
@echo "Manual generated"
\$(MAN_DIR)/%.1: \$(MAN_DIR)/%.man
gzip -c \$< > \$@
@echo "Compressed: \$@"
install:
@echo "Installing executable target"
@cp target/release/\$(NAME) \$(PREFIX)/bin
@echo "Executable file installed to \$(PREFIX)/bin/\$(NAME)"
@echo "Installing manual"
@cp man/*.1 \$(PREFIX)/share/man/man1
@echo "Manual installed to \$(PREFIX)/share/man/man1"
uninstall:
@echo "Removing executable target"
@rm \$(PREFIX)/bin/\$(NAME)
@echo "Removing manual"
@rm \$(PREFIX)/share/man/man1/hina*
@echo "Successfully uninstalled Hina."
EOF
echo "Makefile generated, use make && sudo make install to install Hina"