diff options
author | Karel Kočí <karel.koci@nic.cz> | 2017-01-26 15:26:33 +0100 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2017-01-26 15:26:33 +0100 |
commit | 594caeb275f5c15f57b5178165c1e9ec6a67fa44 (patch) | |
tree | 8df93aafea510a707f972bb4de45c2b9054666d0 /test-curl/test/configure | |
parent | 1e506098990a0711e30537438a07abe15131942b (diff) | |
download | turris-myrepo-594caeb275f5c15f57b5178165c1e9ec6a67fa44.tar.gz turris-myrepo-594caeb275f5c15f57b5178165c1e9ec6a67fa44.tar.bz2 turris-myrepo-594caeb275f5c15f57b5178165c1e9ec6a67fa44.zip |
Temporally save curl testing application until new curl fixes it
Diffstat (limited to 'test-curl/test/configure')
-rwxr-xr-x | test-curl/test/configure | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/test-curl/test/configure b/test-curl/test/configure new file mode 100755 index 0000000..5a456c3 --- /dev/null +++ b/test-curl/test/configure @@ -0,0 +1,202 @@ +#!/bin/sh +# vim:ft=sh:ts=4:sw=4:noexpandtab + +# Configured variables ##################################################### +# Described in following format: +# name:initial value:type:if exported to makefile:if exported to C header +# Where type can be just a string (in C in "") or plain. None implies plain. +CNFS="PREFIX:/usr/local:string:T:F +EPREFIX:/usr/local:string:T:F +DEBUG:no::T:F +CPREFIX:::T:F +CC:cc::T:F +CFLAGS:::T:F +LFLAGS:::T:F" +############################################################################ +# TODO add options to fine tune installation directories + +print_help() { + echo "Usage: ./configure [OPTION]..." + echo "GEML configuration script. Execute this script to configure project" + echo "and prepare it for building." + echo + echo " --help, -h Give this help list" + echo " --debug, -d Enable development features." + echo " --release, -r Disable development features for project." + echo " --dep-check Force depencency check for this machine." + echo " --prefix=PREFIX Set PREFIX as installation prefix for" + echo " architecture independent files." + echo " In default /usr/local" + echo " --exec-prefix=EPREFIX Set EPREFIX as installation prefix for" + echo " architecture dependent files." + echo " In default PREFIX" + echo + echo "Environment variables:" + echo " CPREFIX Compilation tools prefix." + echo " CC C compiler command." + echo " CFLAGS C compiler flags." + echo " LDFLAGS C Linker flags." +} + +CONFIG_FILE=.config +CONFIGURED_FILE=.configured # TODO + +# Backup variables from environment +ENVVARS="CPREFIX CC CFLAGS LDFLAGS" +for E in $ENVVARS; do + eval "[ -n \"\${$E+y}\" ]" && eval "BACKUP_$E=\$$E" +done + +# Load default configuration if variable not set from environment +eval `echo "$CNFS" | sed -ne 's/^\([^:]*\):\([^:]*\).*$/\1=\2/p'` + +# Load existing configuration +if [ -f "$CONFIG_FILE" ]; then + . ./"$CONFIG_FILE" +fi + +# Requested operation. +# c - Configure, default configuration behavior +# m - Prints output for Makefile +# h - Prints C header file (machine validation is skipped) +OP=c + +# Parse arguments +while [ "$#" -gt 0 ]; do + case $1 in + -h|--help) + print_help + exit 0 + ;; + --prefix) + PREFIX=$2 + [ -z "$EPREFIX_USER" ] && EPREFIX="$PREFIX" + shift + ;; + --prefix=*) + PREFIX=${1#--prefix=} + [ -z "$EPREFIX_USER" ] && EPREFIX="$PREFIX" + ;; + --exec-prefix) + EPREFIX=$2 + EPREFIX_USER=y + shift + ;; + --exec-prefix=*) + EPREFIX=${1#--exec-prefix=} + EPREFIX_USER=y + ;; + -d|--debug) + DEBUG=yes + ;; + -r|--release) + DEBUG=no + ;; + --op-makefile) + OP=m + ;; + --op-h) + OP=h + ;; + *) + echo Unknown option $1 1>&2 + exit 2 + ;; + esac + shift +done + +# Recover from enviroment variables +for E in $ENVVARS; do + eval "[ -n \"\${BACKUP_$E+y}\" ]" && eval "$E=\$BACKUP_$E" +done + +# Basically save configuration to file +configure() { + echo "# GEML configuration file" > "$CONFIG_FILE" + echo "# Please do not edit this file directly." >> "$CONFIG_FILE" + echo "$CNFS" | while read L; do + NAME=`echo "$L" | grep -o -E '^[^:]*'` + eval "VALUE=\$$NAME" + echo "$NAME=$VALUE" >> "$CONFIG_FILE" + done + echo "Configuration written to \"$CONFIG_FILE\"" +} + +# Generate Makefile and configure them if they doesn't exists in PWD +doext() { + if [ -f "Makefile" ] || [ -f configure ]; then + return + fi + GEMLDIR=`dirname "$0"` + + echo "# This is external Makefile for GEML." > Makefile + echo >> Makefile + echo "GEML_PATH = $GEMLDIR" >> Makefile + echo >> Makefile + echo "MAKEARGS := -C \"\$(GEML_PATH)\"" >> Makefile + echo "MAKEARGS += O=\"\$(shell pwd)\"" >> Makefile + echo >> Makefile + echo "MAKEFLAGS += --no-print-directory" >> Makefile + echo >> Makefile + echo "Q ?= @" >> Makefile + echo ".PHONY: all \$(MAKECMDGOALS)" >> Makefile + echo "all \$(MAKECMDGOALS):" >> Makefile + echo " \$(Q)\$(MAKE) \$(MAKEARGS) \$@" >> Makefile + + echo Created local Makefile + + echo "# This is external configure script for GEML." > configure + echo "GEML_PATH=$GEMLDIR" >> configure + echo "cd \$(dirname \$0)" >> configure + echo "\$GEML_PATH/configure \$@" >> configure + chmod +x configure + + echo Created local configure script +} + +makefile() { + echo "$CNFS" | while read L; do + if [ `echo $L | awk -F ':' '{ print $4 }'` != "T" ]; then + continue + fi + NAME=`echo "$L" | grep -o -E '^[^:]*'` + eval "VALUE=\$$NAME" + echo "$NAME := $VALUE" + done +} + +cheader() { + echo "$CNFS" | while read L; do + if [ `echo $L | awk -F ':' '{ print $5 }'` != "T" ]; then + continue + fi + NAME=`echo "$L" | grep -o -E '^[^:]*'` + eval "VALUE=\$$NAME" + if [ "`echo $L | awk -F ':' '{ print $3 }'`" = "string" ]; then + echo "#define $NAME \"$VALUE\"" + else + echo "#define $NAME $VALUE" + fi + done +} + +validate() { + echo -n + # TODO check dependencies and programs +} + +case $OP in + c) + validate + doext + configure + ;; + m) + validate + makefile + ;; + h) + cheader + ;; +esac |