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