diff options
author | Karel Kočí <karel.koci@nic.cz> | 2017-02-16 13:44:36 +0100 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2017-02-16 13:44:36 +0100 |
commit | c2adfd2f707be8f4fca0f0cbdd45802206141c18 (patch) | |
tree | 1067b7ac1baef2b74690bf0594e4437122e6bbcd /deactivated/test-curl/test/configure | |
parent | 9f0f3e1b06456f43bc02e00839238a664b4ee6fe (diff) | |
download | turris-myrepo-c2adfd2f707be8f4fca0f0cbdd45802206141c18.tar.gz turris-myrepo-c2adfd2f707be8f4fca0f0cbdd45802206141c18.tar.bz2 turris-myrepo-c2adfd2f707be8f4fca0f0cbdd45802206141c18.zip |
Deactivate curl-test
Diffstat (limited to 'deactivated/test-curl/test/configure')
-rwxr-xr-x | deactivated/test-curl/test/configure | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/deactivated/test-curl/test/configure b/deactivated/test-curl/test/configure new file mode 100755 index 0000000..5a456c3 --- /dev/null +++ b/deactivated/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 |