make.sh (1620B)
1 #!/bin/sh 2 3 # Copyright (C) 2018, 2020-2023 |Méso|Star> (contact@meso-star.com) 4 # Copyright (C) 2018 Centre National de la Recherche Scientifique 5 # Copyright (C) 2018 Université Paul Sabatier 6 # 7 # This program is free software: you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation, either version 3 of the License, or 10 # (at your option) any later version. 11 # 12 # This program is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 19 20 set -e 21 22 config_test() 23 { 24 for i in "$@"; do 25 test=$(basename "${i}" ".c") 26 test_list="${test_list} ${test}" 27 printf "%s: %s\n" "${test}" "src/${test}.o" 28 done 29 printf "test_bin: %s\n" "${test_list}" 30 } 31 32 check() 33 { 34 name="$1" 35 prog="$2" 36 shift 2 37 38 printf "%s " "${name}" 39 if ./"${prog}" "$@" > /dev/null 2>&1; then 40 printf "\033[1;32mOK\033[m\n" 41 else 42 printf "\033[1;31mError\033[m\n" 43 fi 2> /dev/null 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 "$@"