github.com/tri-adam/singularity@v3.1.1+incompatible/mlocal/scripts/config_h.sh (about)

     1  #!/bin/sh -
     2  set -e
     3  
     4  
     5  # this is only useful for C projects
     6  if [ $lang_c -eq 0 ]; then
     7  	return
     8  fi
     9  
    10  
    11  confh=$builddir/config.h
    12  confc=$builddir/config.c
    13  
    14  touch $confh $confc
    15  
    16  config_h_add_char ()
    17  {
    18  	if [ "$1" = "" -o "$2" = "" ]; then
    19  		echo "error: config_h_add_char: not called with <var_name> <var_value>"
    20  		return
    21  	fi
    22  	name=$1
    23  	value=$2
    24  
    25  	echo "char config_h_get_$name(void);" >> $confh
    26  	cat >> $confc << EOF
    27  char
    28  config_h_get_$name(void)
    29  {
    30  	return $value;
    31  }
    32  EOF
    33  }
    34  
    35  config_h_add_short ()
    36  {
    37  	if [ "$1" = "" -o "$2" = "" ]; then
    38  		echo "error: config_h_add_short: not called with <var_name> <var_value>"
    39  		return
    40  	fi
    41  	name=$1
    42  	value=$2
    43  
    44  	echo "short config_h_get_$name(void);" >> $confh
    45  	cat >> $confc << EOF
    46  short
    47  config_h_get_$name(void)
    48  {
    49  	return $value;
    50  }
    51  EOF
    52  }
    53  
    54  config_h_add_int ()
    55  {
    56  	if [ "$1" = "" -o "$2" = "" ]; then
    57  		echo "error: config_h_add_int: not called with <var_name> <var_value>"
    58  		return
    59  	fi
    60  	name=$1
    61  	value=$2
    62  
    63  	echo "int config_h_get_$name(void);" >> $confh
    64  	cat >> $confc << EOF
    65  int
    66  config_h_get_$name(void)
    67  {
    68  	return $value;
    69  }
    70  EOF
    71  }
    72  
    73  config_h_add_long ()
    74  {
    75  	if [ "$1" = "" -o "$2" = "" ]; then
    76  		echo "error: config_h_add_long: not called with <var_name> <var_value>"
    77  		return
    78  	fi
    79  	name=$1
    80  	value=$2
    81  
    82  	echo "long config_h_get_$name(void);" >> $confh
    83  	cat >> $confc << EOF
    84  long
    85  config_h_get_$name(void)
    86  {
    87  	return $value;
    88  }
    89  EOF
    90  }
    91  
    92  config_h_add_longlong ()
    93  {
    94  	if [ "$1" = "" -o "$2" = "" ]; then
    95  		echo "error: config_h_add_longlong: not called with <var_name> <var_value>"
    96  		return
    97  	fi
    98  	name=$1
    99  	value=$2
   100  
   101  	echo "long long config_h_get_$name(void);" >> $confh
   102  	cat >> $confc << EOF
   103  long long
   104  config_h_get_$name(void)
   105  {
   106  	return $value;
   107  }
   108  EOF
   109  }
   110  
   111  config_h_add_string ()
   112  {
   113  	if [ "$1" = "" -o "$2" = "" ]; then
   114  		echo "error: config_h_add_string: not called with <var_name> <var_value>"
   115  		return
   116  	fi
   117  	name=$1
   118  	value=$2
   119  
   120  	echo "char *config_h_get_$name(void);" >> $confh
   121  	cat >> $confc << EOF
   122  char *
   123  config_h_get_$name(void)
   124  {
   125  	return "$value";
   126  }
   127  EOF
   128  }
   129  
   130  config_add_def ()
   131  {
   132          if [ "$1" = "" -o "$2" = "" ]; then
   133                  return
   134          fi
   135          echo "#define $*" >> $confh
   136  }
   137  
   138  config_add_header ()
   139  {
   140  	echo "#ifndef __CONFIG_H_" >> $confh
   141  	echo "#define __CONFIG_H_" >> $confh
   142  	echo >> $confh
   143  }
   144  
   145  config_add_footer ()
   146  {
   147  	echo >> $confh
   148  	echo "#endif /* __CONFIG_H_ */" >> $confh
   149  }
   150