#!/usr/bin/env bash # build_only.sh - Automates build for 42sh with pretty output (no tests) set -e # Colors GREEN="\033[1;32m" RED="\033[1;31m" YELLOW="\033[1;33m" RESET="\033[0m" VERBOSE=0 if [[ "$1" == "--verbose" ]]; then VERBOSE=1 fi run_cmd() { local desc="$1" shift if [[ $VERBOSE -eq 1 ]]; then echo -e "${YELLOW}${desc}...${RESET}" "$@" else echo -ne "${YELLOW}${desc}...${RESET}" "$@" &> /dev/null && echo -e " ${GREEN}done${RESET}" || { echo -e " ${RED}failed${RESET}"; exit 1; } fi } run_cmd "Running autoreconf" autoreconf --force --verbose --install if [[ "$(uname)" == "Darwin" ]]; then run_cmd "Configuring for MacOS" ./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -I/opt/homebrew/include' LDFLAGS='-L/opt/homebrew/lib' else run_cmd "Configuring for Linux" ./configure CFLAGS='-std=c99 -Werror -Wall -Wextra -Wvla -g -fsanitize=address' fi run_cmd "Cleaning build" make clean if [[ $VERBOSE -eq 1 ]]; then echo -e "${YELLOW}Building...${RESET}" make else echo -ne "${YELLOW}Building...${RESET}" echo make fi