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

Support --with-cxx option #133

Merged
merged 8 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install GNU Getopt on macOS
if: ${{ matrix.os == 'macos-latest' }}
run: |
brew install gnu-getopt
- name: configure
run: ./configure
- name: build
Expand Down
67 changes: 53 additions & 14 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,86 @@

set -o nounset

PROJECT=procfetch
VERSION="$(cat VERSION)"
CONFIG_BREW=OFF
CXX=g++
unset PREFIX
BIN_DIR=/bin
LIB_DIR=/share/procfetch

if [[ -d "/usr/local/opt/gnu-getopt/bin" ]]; then
PATH="/usr/local/opt/gnu-getopt/bin:$PATH"
fi

function show_usage {
echo "Usage: $0 [--prefix=<prefix>]"
echo " $0 --help"
cat <<-EOF
\`$0' configures $PROJECT $VERSION to adapt to many kinds of systems.

Usage: $0 [OPTION]...

Options:
-h, --help display this help and exit.
-v, --versoin display version information and exit.
--prefix=PREFIX install files in PREFIX.
--with-cxx=CXX use CXX to compile (default=gcc).

Some influential environment variables:
CXX C++ compiler command
EOF
exit $1
}

#
# parse options
#

if [[ $# -ge 1 ]]; then
if [[ ${1%%=*} == --prefix ]]; then
PREFIX="${1##*=}"
shift
elif [[ $1 == --help || $1 = -h ]]; then
show_usage
exit 0
fi
help_option=0
version_option=0

parsed_arguments=$(getopt -n $0 -o hv --long help,version,prefix:,with-cxx: -- "$@")
if [[ $? != 0 ]]; then
show_usage 1
fi

eval set -- "$parsed_arguments"
while true; do
case "$1" in
-h | --help ) help_option=1 ; shift ;;
-v | --version ) version_option=1 ; shift ;;
--prefix ) PREFIX="$2" ; shift 2 ;;
--with-cxx ) CXX="$2" ; shift 2 ;;
--) shift; break;;
*) echo "Error: Unknown option: $1"
show_usage 1;;
esac
done

if [[ $# -ne 0 ]]; then
echo "Error: Invalid options or arguments"
show_usage
exit 1
echo "Error: Invalid argument: $@"
show_usage 1
fi

#
# main process
#

if [[ $help_option == 1 ]]; then
show_usage 0
fi

if [[ $version_option == 1 ]]; then
echo "$PROJECT configure $VERSION"
exit 0
fi

BIN_DIR="${PREFIX:-}${BIN_DIR}"
LIB_DIR="${PREFIX:-/usr}${LIB_DIR}"

for f in Makefile ascii/Makefile src/Makefile src/config.h Doxyfile
do
echo "creating $f"
sed -e "s/@VERSION@/${VERSION}/g" \
-e "s/@CXX@/${CXX}/g" \
-e "s:@BIN_DIR@:${BIN_DIR}:g" \
-e "s:@LIB_DIR@:${LIB_DIR}:g" "$f.in" > "$f"
done
1 change: 1 addition & 0 deletions src/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ TARGET = procfetch
SRCS = fetch.cpp main.cpp util.cpp
OBJS = $(SRCS:.cpp=.o)

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

ifeq ($(COVERAGE_TEST), 1)
Expand Down