Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 01a2bec

Browse files
Merge pull request #133 from youpong/feat-llvm-clang
Support --with-cxx option
2 parents e9a357a + d8eabe8 commit 01a2bec

File tree

3 files changed

+58
-14
lines changed

3 files changed

+58
-14
lines changed

.github/workflows/unit-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ jobs:
1818
runs-on: ${{ matrix.os }}
1919
steps:
2020
- uses: actions/checkout@v3
21+
- name: Install GNU Getopt on macOS
22+
if: ${{ matrix.os == 'macos-latest' }}
23+
run: |
24+
brew install gnu-getopt
2125
- name: configure
2226
run: ./configure
2327
- name: build

configure

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,86 @@
22

33
set -o nounset
44

5+
PROJECT=procfetch
56
VERSION="$(cat VERSION)"
6-
CONFIG_BREW=OFF
7+
CXX=g++
8+
unset PREFIX
79
BIN_DIR=/bin
810
LIB_DIR=/share/procfetch
911

12+
if [[ -d "/usr/local/opt/gnu-getopt/bin" ]]; then
13+
PATH="/usr/local/opt/gnu-getopt/bin:$PATH"
14+
fi
15+
1016
function show_usage {
11-
echo "Usage: $0 [--prefix=<prefix>]"
12-
echo " $0 --help"
17+
cat <<-EOF
18+
\`$0' configures $PROJECT $VERSION to adapt to many kinds of systems.
19+
20+
Usage: $0 [OPTION]...
21+
22+
Options:
23+
-h, --help display this help and exit.
24+
-v, --versoin display version information and exit.
25+
--prefix=PREFIX install files in PREFIX.
26+
--with-cxx=CXX use CXX to compile (default=gcc).
27+
28+
Some influential environment variables:
29+
CXX C++ compiler command
30+
EOF
31+
exit $1
1332
}
1433

1534
#
1635
# parse options
1736
#
1837

19-
if [[ $# -ge 1 ]]; then
20-
if [[ ${1%%=*} == --prefix ]]; then
21-
PREFIX="${1##*=}"
22-
shift
23-
elif [[ $1 == --help || $1 = -h ]]; then
24-
show_usage
25-
exit 0
26-
fi
38+
help_option=0
39+
version_option=0
40+
41+
parsed_arguments=$(getopt -n $0 -o hv --long help,version,prefix:,with-cxx: -- "$@")
42+
if [[ $? != 0 ]]; then
43+
show_usage 1
2744
fi
2845

46+
eval set -- "$parsed_arguments"
47+
while true; do
48+
case "$1" in
49+
-h | --help ) help_option=1 ; shift ;;
50+
-v | --version ) version_option=1 ; shift ;;
51+
--prefix ) PREFIX="$2" ; shift 2 ;;
52+
--with-cxx ) CXX="$2" ; shift 2 ;;
53+
--) shift; break;;
54+
*) echo "Error: Unknown option: $1"
55+
show_usage 1;;
56+
esac
57+
done
58+
2959
if [[ $# -ne 0 ]]; then
30-
echo "Error: Invalid options or arguments"
31-
show_usage
32-
exit 1
60+
echo "Error: Invalid argument: $@"
61+
show_usage 1
3362
fi
3463

3564
#
3665
# main process
3766
#
3867

68+
if [[ $help_option == 1 ]]; then
69+
show_usage 0
70+
fi
71+
72+
if [[ $version_option == 1 ]]; then
73+
echo "$PROJECT configure $VERSION"
74+
exit 0
75+
fi
76+
3977
BIN_DIR="${PREFIX:-}${BIN_DIR}"
4078
LIB_DIR="${PREFIX:-/usr}${LIB_DIR}"
4179

4280
for f in Makefile ascii/Makefile src/Makefile src/config.h Doxyfile
4381
do
4482
echo "creating $f"
4583
sed -e "s/@VERSION@/${VERSION}/g" \
84+
-e "s/@CXX@/${CXX}/g" \
4685
-e "s:@BIN_DIR@:${BIN_DIR}:g" \
4786
-e "s:@LIB_DIR@:${LIB_DIR}:g" "$f.in" > "$f"
4887
done

src/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ TARGET = procfetch
22
SRCS = fetch.cpp main.cpp util.cpp
33
OBJS = $(SRCS:.cpp=.o)
44

5+
CXX = @CXX@
56
CXXFLAGS = -std=c++2a -Wall -Wextra --pedantic-errors
67

78
ifeq ($(COVERAGE_TEST), 1)

0 commit comments

Comments
 (0)