]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
ordering it this way seems better
authorWolfgang Bumiller <wry.git@bumiller.com>
Sun, 15 Dec 2013 18:53:01 +0000 (19:53 +0100)
committerWolfgang Bumiller <wry.git@bumiller.com>
Sun, 15 Dec 2013 18:53:01 +0000 (19:53 +0100)
configure

index a2dcc22fa8c7008c2d4a9cc3701efc39675da35e..40dd5887b6ac8e197f881b9ce01ead4c8491eecf 100755 (executable)
--- a/configure
+++ b/configure
@@ -3,93 +3,6 @@
 
 progname="$0"
 
-#
-# Object lists
-#
-
-# all_c_obj will be filled by print_objects
-all_c_obj=()
-
-# executables is an array of variable names used in the makefile to
-# name an executable; the list of objects is assumed to be
-# in ${var}_OBJ
-executables=(GMQCC QCVM TESTSUITE PAK)
-print_all_rule() {
-  printf 'all:'
-  for i in "${executables[@]}"; do
-    printf ' $(%s)' "$i"
-  done
-  echo
-}
-
-# create all the object variables:
-print_objects() {
-  local common=(ansi.o util.o hash.o stat.o fs.o opts.o conout.o)
-    all_c_obj+=("${common[@]}")
-  local gmqcc=(main.o utf8.o
-               lexer.o parser.o ftepp.o
-               fold.o intrin.o correct.o
-               ast.o ir.o code.o)
-    all_c_obj+=("${gmqcc[@]}")
-  local qcvm=(exec.o)
-    all_c_obj+=("${qcvm[@]}")
-  local testsuite=(test.o)
-    all_c_obj+=("${testsuite[@]}")
-  local pak=(pak.o)
-    all_c_obj+=("${pak[@]}")
-  cat <<EOF
-GMQCC     = gmqcc${cf_exesuffix}
-QCVM      = qcvm${cf_exesuffix}
-TESTSUITE = testsuite${cf_exesuffix}
-PAK       = pak${cf_exesuffix}
-
-QCVM_OBJ      := ${common[@]} ${qcvm[@]}
-GMQCC_OBJ     := ${common[@]} ${gmqcc[@]}
-TESTSUITE_OBJ := ${common[@]} ${testsuite[@]}
-PAK_OBJ       := ${common[@]} ${pak[@]}
-
-EOF
-  printf 'ALL_PROGRAMS ='
-  for i in "${executables[@]}"; do
-    printf ' $(%s)' "$i"
-  done
-  echo
-}
-
-# generate the commands used to build objects and executables
-# in a way that works with both BSD make and gmake by not relying
-# on special vars like - also generate the .d files
-print_targets() {
-  # generate object rules to get the right path: $cf_dir
-  for obj in "${all_c_obj[@]}"; do
-    local c_src="${cf_dir}/${obj%.o}.c"
-    local d_inc="${obj}.d"
-    echo "${obj}: ${c_src}"
-    echo $'\t'"\$(CC) \$(CFLAGS) \$(CPPFLAGS) -c -o \$@ \"${c_src}\" -MMD -MF \"${d_inc}\" -MT \$@"
-  done
-
-  for exe in "${executables[@]}"; do
-    echo "\$(${exe}): \$(${exe}_OBJ)"
-    echo $'\t'"\$(CC) \$(LDFLAGS) -o \$(${exe}) \$(${exe}_OBJ) \$(LIBS)"
-  done
-}
-
-#
-# configure script
-#
-
-# TODO: colors
-die() {
-  local mesg="$1"; shift
-  printf "fatal: ${mesg}\n" "$@"
-  exit 1
-}
-
-msg() {
-  local mesg="$1"; shift
-  printf "configure: ${mesg}\n" "$@"
-}
-
 usage() {
   cat <<EOF
 ${progname} [options]
@@ -124,6 +37,18 @@ parse_cmdline() {
   done
 }
 
+# TODO: colors
+die() {
+  local mesg="$1"; shift
+  printf "fatal: ${mesg}\n" "$@"
+  exit 1
+}
+
+msg() {
+  local mesg="$1"; shift
+  printf "configure: ${mesg}\n" "$@"
+}
+
 #
 # Some library functions
 #
@@ -147,12 +72,37 @@ has_cmd() {
 #
 need_cmd uname
 need_cmd tr
+need_cmd readlink
 
 #
-# Let's figure out where we are...
+# default host specific values:
 #
+host="$(uname -s | tr A-Z a-z)"
+case "${host}" in
+  linux|*bsd*)
+    cf_prefix="${cf_prefix:-/usr/local}"
+    cf_bindir="${cf_bindir:-${cf_prefix}/bin}"
+    cf_datadir="${cf_datadir:-${cf_prefix}/share}"
+    cf_mandir="${cf_mandir:-${cf_datadir}/man}"
+    cf_man1dir="${cf_man1dir:-${cf_mandir}/man1}"
+    cf_exesuffix=""
+    ;;
+  *)
+    cf_prefix="${cf_prefix:-}"
+    cf_bindir="${cf_bindir:-}"
+    cf_datadir="${cf_datadir:-}"
+    cf_mandir="${cf_mandir:-}"
+    cf_man1dir="${cf_man1dir:-}"
+    cf_exesuffix=".exe"
+    ;;
+esac
 
-need_cmd readlink
+# for the default-supported compilers:
+cf_cflags_gcc=(-Wall -Wextra -Werror -Wstrict-aliasing -Wno-attributes)
+cf_ldflags_gcc=()
+cf_libs_gcc=(-lm)
+
+# Let's figure out where we are...
 cf_wd="${PWD}"
 cf_dir="$(readlink -f "${progname}")"
 # or should we use the hopefully more reliable basename command?
@@ -208,34 +158,6 @@ fi
 cf_valgrind=0
 has_cmd valgrind && cf_valgrind=1
 
-#
-# default host specific values:
-#
-host="$(uname -s | tr A-Z a-z)"
-case "${host}" in
-  linux|*bsd*)
-    cf_prefix="${cf_prefix:-/usr/local}"
-    cf_bindir="${cf_bindir:-${cf_prefix}/bin}"
-    cf_datadir="${cf_datadir:-${cf_prefix}/share}"
-    cf_mandir="${cf_mandir:-${cf_datadir}/man}"
-    cf_man1dir="${cf_man1dir:-${cf_mandir}/man1}"
-    cf_exesuffix=""
-    ;;
-  *)
-    cf_prefix="${cf_prefix:-}"
-    cf_bindir="${cf_bindir:-}"
-    cf_datadir="${cf_datadir:-}"
-    cf_mandir="${cf_mandir:-}"
-    cf_man1dir="${cf_man1dir:-}"
-    cf_exesuffix=".exe"
-    ;;
-esac
-
-# for the default-supported compilers:
-cf_cflags_gcc=(-Wall -Wextra -Werror -Wstrict-aliasing -Wno-attributes)
-cf_ldflags_gcc=()
-cf_libs_gcc=(-lm)
-
 # compiler specific flags:
 [[ $CC != g++ ]] && cf_cflags_gcc+=(-Wmissing-prototypes -Wstrict-prototypes)
 [[ $CC = clang ]] && \
@@ -278,6 +200,75 @@ case "${cf_cctype}" in
     die "compiler type '%s' not handled here!" "${cf_cctype}"
 esac
 
+#
+# Makefile generation routines
+#
+
+# executables is an array of variable names used in the makefile to
+# name an executable; the list of objects is assumed to be
+# in ${var}_OBJ
+executables=(GMQCC QCVM TESTSUITE PAK)
+all_c_obj=() # filled by print_objects
+print_all_rule() {
+  printf 'all:'
+  for i in "${executables[@]}"; do
+    printf ' $(%s)' "$i"
+  done
+  echo
+}
+
+# create all the object variables:
+print_objects() {
+  local common=(ansi.o util.o hash.o stat.o fs.o opts.o conout.o)
+    all_c_obj+=("${common[@]}")
+  local gmqcc=(main.o utf8.o
+               lexer.o parser.o ftepp.o
+               fold.o intrin.o correct.o
+               ast.o ir.o code.o)
+    all_c_obj+=("${gmqcc[@]}")
+  local qcvm=(exec.o)
+    all_c_obj+=("${qcvm[@]}")
+  local testsuite=(test.o)
+    all_c_obj+=("${testsuite[@]}")
+  local pak=(pak.o)
+    all_c_obj+=("${pak[@]}")
+  cat <<EOF
+GMQCC     = gmqcc${cf_exesuffix}
+QCVM      = qcvm${cf_exesuffix}
+TESTSUITE = testsuite${cf_exesuffix}
+PAK       = pak${cf_exesuffix}
+
+QCVM_OBJ      := ${common[@]} ${qcvm[@]}
+GMQCC_OBJ     := ${common[@]} ${gmqcc[@]}
+TESTSUITE_OBJ := ${common[@]} ${testsuite[@]}
+PAK_OBJ       := ${common[@]} ${pak[@]}
+
+EOF
+  printf 'ALL_PROGRAMS ='
+  for i in "${executables[@]}"; do
+    printf ' $(%s)' "$i"
+  done
+  echo
+}
+
+# generate the commands used to build objects and executables
+# in a way that works with both BSD make and gmake by not relying
+# on special vars like - also generate the .d files
+print_targets() {
+  # generate object rules to get the right path: $cf_dir
+  for obj in "${all_c_obj[@]}"; do
+    local c_src="${cf_dir}/${obj%.o}.c"
+    local d_inc="${obj}.d"
+    echo "${obj}: ${c_src}"
+    echo $'\t'"\$(CC) \$(CFLAGS) \$(CPPFLAGS) -c -o \$@ \"${c_src}\" -MMD -MF \"${d_inc}\" -MT \$@"
+  done
+
+  for exe in "${executables[@]}"; do
+    echo "\$(${exe}): \$(${exe}_OBJ)"
+    echo $'\t'"\$(CC) \$(LDFLAGS) -o \$(${exe}) \$(${exe}_OBJ) \$(LIBS)"
+  done
+}
+
 #
 # Now generate our output file
 #