Merge branch 'master' of github.com:informatimago/bin

Pascal J. Bourguignon [2019-01-27 14:44]
Merge branch 'master' of github.com:informatimago/bin
Filename
odc
with-gcc-8.bash
diff --git a/odc b/odc
new file mode 100755
index 0000000..267bc87
--- /dev/null
+++ b/odc
@@ -0,0 +1,6 @@
+#!/bin/bash
+od -t x1 \
+| ( echo 'static unsigned char buffer[]={'
+    sed -e 's/^[0-9a-fA-F]*\( \|$\)/ /' -e 's/\([0-9a-fA-F][0-9a-fA-F]\)/0x\1,/g'
+    echo '};' )
+
diff --git a/with-gcc-8.bash b/with-gcc-8.bash
index 746fdbd..fb41f03 100644
--- a/with-gcc-8.bash
+++ b/with-gcc-8.bash
@@ -50,25 +50,28 @@ function trim_colons(){

 function with_gcc_8(){
     gcc_prefix="/usr/local/gcc"
+    libs=(${gcc_prefix}/lib64 ${gcc_prefix}/lib /usr/local/lib64 /usr/local/lib /usr/lib /lib )
     export PATH=$(trim_colons "${gcc_prefix}/bin:${PATH}")
     export CFLAGS=$(trim_spaces "-I${gcc_prefix}/include ${CFLAGS:-}")
     export CXXFLAGS=$(trim_spaces "-I${gcc_prefix}/include ${CXXFLAGS:-}")
-    export LDFLAGS=$(trim_spaces "-L${gcc_prefix}/lib ${LDFLAGS:-}")
-    export LD_LIBRARY_PATH="${gcc_prefix}/lib:/usr/local/lib:/usr/local/lib64:/usr/lib:/lib"
+    export LDFLAGS=$(trim_spaces "${LDFLAGS:-} $(printf -- "-L%s " "${libs[@]}") ")
+    export LD_LIBRARY_PATH="$(trim_colons $(printf -- "%s:" "${libs[@]}"))"
     export PKG_CONFIG_PATH="${gcc_prefix}/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig"
-    libs="-L${gcc_prefix}/lib -L/usr/local/lib -L/usr/local/lib64 -L/lib -L/usr/lib"

-    gcc -dumpversion
     case "$(gcc -dumpversion)" in
     [789]*)
         export CFLAGS=$(trim_spaces "${CFLAGS:-} ${sanitize_cc[*]} -g -g3 -ggdb -O0")
-        export LDFLAGS=$(trim_spaces "${LDFLAGS:-} ${libs} ${sanitize_ld[*]}")
+        export LDFLAGS=$(trim_spaces "${LDFLAGS:-} ${sanitize_ld[*]}")
         ;;
     *)
         export CFLAGS=$(trim_spaces "${CFLAGS:-} -g -g3 -ggdb -O0")
-        export LDFLAGS=$(trim_spaces "${LDFLAGS:-} ${libs}")
+        export LDFLAGS=$(trim_spaces "${LDFLAGS:-}")
         ;;
     esac
+
+    # for var in PATH CFLAGS CXXFLAGS LDFLAGS LD_LIBRARY_PATH PKG_CONFIG_PATH ; do
+    #     printf "export %s='%s'\n" "${var}" "${!var}"
+    # done
 }

 with_gcc_8
ViewGit