aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mk/configure37
-rw-r--r--mk/lang-c.mk12
2 files changed, 32 insertions, 17 deletions
diff --git a/mk/configure b/mk/configure
index 6351380..732163e 100644
--- a/mk/configure
+++ b/mk/configure
@@ -29,6 +29,19 @@ exec 10>config.status
exec 20>.config.mk
+# Print a quoted (if necessary) version of a string
+quote ()
+{
+ value="$1"
+ if ! test "${value%%\'*}" = "${value}"; then
+ value="'$(echo "${value}" | sed "s/'/'\\\\''/g")'"
+ elif ! test "$(printf '%s' ${value})" = "${value}"; then
+ value="'${value}'"
+ fi
+ echo "${value}"
+}
+
+
# Parse command line.
incomplete=
dashed=
@@ -284,7 +297,7 @@ for option; do
if test "${option%%=*}" = "${option}"; then
incomplete="${option}"
else
- eval "${nodash}=${option#*=}"
+ eval "${nodash}=$(quote "${option#*=}")"
eval "have_${nodash}=yes"
fi
done
@@ -395,14 +408,9 @@ fi
# Set unset directories to their default.
defdir ()
{
- p="${2}"
+ p="$(quote "${2}")"
if ! test "${p%%\'*}" = "${p}"; then
p="$(echo "${p}" | sed "s/'/'\\\\''/g")"
- p="'${p}'"
- p="$(echo "${p}" | sed "s/'/'\\\\''/g")"
- elif ! test "$(printf '%s' ${p})" = "${p}"; then
- p="'${p}'"
- p="$(echo "${p}" | sed "s/'/'\\\\''/g")"
fi
if ! test -n "$(eval echo '${have_'"${1}"'}')"; then
eval "${1}='${p}'"
@@ -496,7 +504,7 @@ defdir man7 "man7${MAN_SECTION_SUFFIX}"
defdir man8 "man8${MAN_SECTION_SUFFIX}"
defdir man9 "man9${MAN_SECTION_SUFFIX}"
if test -n "${MAN_SECTION}" && ! test -n "$(eval echo '${man'"${MAN_SECTION}"'ext}')"; then
- defdir man${MAN_SECTION}ext "$(eval echo '${man'"${MAN_SECTION}"'ext}')"
+ defdir "man${MAN_SECTION}ext" "$(eval echo '${man'"${MAN_SECTION}"'ext}')"
fi
defdir man0ext ".0"
defdir man1ext ".1"
@@ -522,12 +530,7 @@ fi
if test -n "${srcdir}"; then
srcdir="$(realpath "${srcdir}")/"
srcdir_proper="${srcdir}"
- if ! test "${srcdir%%\'*}" = "${srcdir}"; then
- srcdir="$(echo "${srcdir}" | sed "s/'/'\\\\''/g")"
- srcdir="'${srcdir}'"
- elif ! test "$(printf '%s' ${srcdir})" = "${srcdir}"; then
- srcdir="'${srcdir}'"
- fi
+ srcdir="$(quote "${srcdir}")"
fi
if ! test -f "${srcdir_proper}Makefile.in"; then
echo "${0}: error: cannot found source directory."
@@ -548,7 +551,11 @@ echo >&10
echo 'cd "$(dirname "${0}")"' >&10
# config.status calls ./configure with all arguments you called ./configure.
-echo "exec ${0}" "$@" >&10
+printf "exec %s" "${0}" >&10
+for option; do
+ printf " %s" "$(quote "${option}")" >&10
+done
+echo >&10
# Close config.status.
exec 10>&-
diff --git a/mk/lang-c.mk b/mk/lang-c.mk
index b8076d6..36d4496 100644
--- a/mk/lang-c.mk
+++ b/mk/lang-c.mk
@@ -60,11 +60,11 @@ endif
# BUILD VARIABLES:
# Optimisation settings for C code compilation.
+ifndef OPTIMISE
ifndef DEBUG
OPTIMISE = -O2 -g
endif
-ifndef DEBUG
-ifdef OPTIMISE
+ifdef DEBUG
ifdef __USING_GCC
OPTIMISE = -Og -g
endif
@@ -78,6 +78,7 @@ endif
ifdef _PEDANTIC
_PEDANTIC = -pedantic
endif
+ifndef WARN
ifndef DEBUG
WARN = -Wall
endif
@@ -99,6 +100,7 @@ ifndef __USING_GCC
WARN = -Wall -Wextra $(_PEDANTIC)
endif
endif
+endif
# Support for internationalisation?
ifndef WITHOUT_GETTEXT
@@ -112,9 +114,15 @@ _CPPFLAGS += $(foreach D,$(_ALL_DIRS),-D'$(D)="$($(D))"')
# MORE HELP VARIABLES:
# Compilation and linking flags, and command.
+ifndef CPPFLAGS
CPPFLAGS =
+endif
+ifndef CFLAGS
CFLAGS = $(OPTIMISE) $(WARN)
+endif
+ifndef LDFLAGS
LDFLAGS = $(OPTIMISE) $(WARN)
+endif
__CC = $(CC) -std=$(_C_STD) -c $(_CPPFLAGS) $(_CFLAGS)
__LD = $(CC) -std=$(_C_STD) $(_LDFLAGS)
__CC_POST = $(CPPFLAGS) $(CFLAGS) $(EXTRA_CPPFLAGS) $(EXTRA_CFLAGS)