1#!/bin/sh 2set -e 3 4# generate list of source files for use in Makefile.am 5# if you add new source files, you must run ./bootstrap again 6src_listvar () { 7 basedir=$1 8 suffix=$2 9 var=$3 10 11 find "${basedir}" -name "${suffix}" | LC_ALL=C sort | tr '\n' ' ' | (printf "${var} = " && cat) 12 echo "" 13} 14 15# remove source files from list if their usage depends on a configure option 16remove_src () { 17 files=$1 18 shift 19 for x in $* 20 do 21 x=$(echo "$x" | sed 's/\//\\\//g') 22 files=$(echo $files | sed -e "s/$x//") 23 done 24 echo $files 25} 26 27# generate list of eys source files for use in Makefile.am 28# if you add new source files, you must run ./bootstrap again 29# files after the var name will be elimenated from list list 30src_esys_listvar () { 31 basedir=$1; 32 shift; 33 suffix=$1 34 shift; 35 var=$1 36 shift; 37 38 files=$(find "${basedir}" -name "${suffix}" | LC_ALL=C sort | tr '\n' ' ') 39 files=$(remove_src "${files}" $*) 40 printf "${var} = ${files}" 41 echo "" 42} 43 44VARS_FILE=src_vars.mk 45AUTORECONF=${AUTORECONF:-autoreconf} 46 47echo "Generating file lists: ${VARS_FILE}" 48( 49 src_listvar "src/util" "*.c" "UTIL_C" 50 src_listvar "src/util" "*.h" "UTIL_H" 51 printf "UTIL_SRC = \$(UTIL_C) \$(UTIL_H)\n" 52 53 src_listvar "src/tss2-sys/" "*.c" "TSS2_SYS_C" 54 src_listvar "src/tss2-sys/" "*.h" "TSS2_SYS_H" 55 printf "TSS2_SYS_SRC = \$(TSS2_SYS_H) \$(TSS2_SYS_C)\n" 56 57 src_esys_listvar "src/tss2-esys/" "*.h" "TSS2_ESYS_H" src/tss2-esys/esys_crypto_ossl.h src/tss2-esys/esys_crypto_gcrypt.h 58 src_esys_listvar "src/tss2-esys/" "*.c" "TSS2_ESYS_C" src/tss2-esys/esys_crypto_ossl.c src/tss2-esys/esys_crypto_gcrypt.c 59 printf "TSS2_ESYS_SRC = \$(TSS2_ESYS_H) \$(TSS2_ESYS_C)\n" 60 61 src_listvar "src/tss2-fapi/" "*.h" "TSS2_FAPI_H" 62 src_listvar "src/tss2-fapi/" "*.c" "TSS2_FAPI_C" 63 printf "TSS2_FAPI_SRC = \$(TSS2_FAPI_H) \$(TSS2_FAPI_C)\n" 64 65 src_listvar "src/tss2-mu" "*.c" "TSS2_MU_C" 66 src_listvar "src/tss2-mu" "*.h" "TSS2_MU_H" 67 printf "TSS2_MU_SRC = \$(TSS2_MU_C) \$(TSS2_MU_H)\n" 68 69 src_listvar "src/tss2-rc" "*.c" "TSS2_RC_C" 70 src_listvar "src/tss2-rc" "*.h" "TSS2_RC_H" 71 printf "TSS2_RC_SRC = \$(TSS2_RC_C) \$(TSS2_RC_H)" 72) > ${VARS_FILE} 73 74# Do not generate fuzz tests unless environment variable GEN_FUZZ is set to 1 75rm -rf Makefile-fuzz-generated.am 76if test "${GEN_FUZZ}0" -eq 10; then 77 echo "Generating fuzz tests" 78 script/gen_fuzz.py 79else 80 touch Makefile-fuzz-generated.am 81fi 82 83${AUTORECONF} --install --sym $@ 84 85if grep "Invalid policy. Valid policies: git-directory, minor-version." configure >/dev/null; then 86 echo "ERROR: ax_is_release.m4 is outdated. ./configure will fail." 87 echo "Please download from http://ftpmirror.gnu.org/autoconf-archive/autoconf-archive-2019.01.06.tar.xz" 88 exit 1 89fi 90