make.sh (1571B)
1 #!/bin/sh 2 3 # Copyright (C) 2022, 2023 |Méso|Star> (contact@meso-star.com) 4 # Copyright (C) 2020, 2021 CNRS 5 # 6 # This program is free software: you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation, either version 3 of the License, or 9 # (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License 17 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 19 set -e 20 21 config_test() 22 { 23 for i in "$@"; do 24 test=$(basename "${i}" ".c") 25 test_list="${test_list} ${test}" 26 printf "%s: %s\n" "${test}" "src/${test}.o" 27 done 28 printf "test_bin: %s\n" "${test_list}" 29 } 30 31 run_test() 32 { 33 for i in "$@"; do 34 test=$(basename "${i}" ".c") 35 36 printf "%s " "${test}" 37 if "./${test}" > /dev/null 2>&1; then 38 printf "\033[1;32mOK\033[m\n" 39 else 40 printf "\033[1;31mError\033[m\n" 41 fi 42 done 2> /dev/null 43 } 44 45 46 clean_test() 47 { 48 for i in "$@"; do 49 rm -f "$(basename "${i}" ".c")" 50 done 51 } 52 53 install() 54 { 55 prefix=$1 56 shift 1 57 58 mkdir -p "${prefix}" 59 60 for i in "$@"; do 61 dst="${prefix}/${i##*/}" 62 63 if cmp -s "${i}" "${dst}"; then 64 printf "Up to date %s\n" "${dst}" 65 else 66 printf "Installing %s\n" "${dst}" 67 cp "${i}" "${prefix}" 68 fi 69 done 70 } 71 72 "$@"