]> git.draconx.ca Git - dxcommon.git/commitdiff
Normalize whitespace on detected library flags.
authorNick Bowler <nbowler@draconx.ca>
Fri, 22 Feb 2019 22:48:21 +0000 (17:48 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 23 Feb 2019 16:15:10 +0000 (11:15 -0500)
It seems that pkg-config sometimes spits out a bunch of trailing
whitespace.  This gets into the substituted variables and makes
them a bit annoying to work with.  Add a step to the library helper
which normalizes the spaces: in addition to removing leading and
trailing spaces this will also remove internal spaces, which I
think should be harmless as there does not appear to be any way
for the user to usefully get quoted spaces into these variables.

m4/libhelper.m4
m4/utils.m4

index 500389c123b358371b96cba3dfd002fc1eaade86..fdaaff5c0fafedc6bb73e08719ffcd8efe60833d 100644 (file)
@@ -1,4 +1,6 @@
-dnl Copyright © 2014 Nick Bowler
+dnl Copyright © 2014, 2019 Nick Bowler
+dnl
+dnl Helper macros for implementing library tests.
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
@@ -83,6 +85,8 @@ _DX_CVNAME([found])=no
 _dx_save_cflags=$CFLAGS
 _dx_save_libs=$LIBS
 m4_map_sep([_DX_LIB_TEST], [m4_newline], [$3])
+DX_VAR_NORMALIZE_SPACE([_DX_CVNAME([cflags])])
+DX_VAR_NORMALIZE_SPACE([_DX_CVNAME([libs])])
 CFLAGS=$_dx_save_cflags
 LIBS=$_dx_save_libs])dnl
 
index 32f3246cfc45fc9ab26897302e813ebdd1ad919c..c621631e3be08e1cc14af235bba88bbae60083f2 100644 (file)
@@ -1,6 +1,6 @@
-dnl Copyright © 2015, 2018 Nick Bowler
+dnl Copyright © 2015, 2018-2019 Nick Bowler
 dnl
-dnl Assorted helper macros
+dnl Assorted utility macros.
 dnl
 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
 dnl This is free software: you are free to do what the fuck you want to.
@@ -9,3 +9,8 @@ dnl There is NO WARRANTY, to the extent permitted by law.
 dnl DX_DO(arg, ...)
 dnl Expand each argument in sequence, inserting newlines between them.
 AC_DEFUN([DX_DO], [m4_do([$1], [m4_map_args([m4_newline], m4_shift($@))])])
+
+dnl DX_VAR_NORMALIZE_SPACE(varname)
+dnl Trim leading and trailing whitespace from a shell variable, and replace
+dnl consecutive sequences of internal whitespace with a single space.
+AC_DEFUN([DX_VAR_NORMALIZE_SPACE], [set -f; set x $$1; shift; $1=$[]* set +f])