ImageMagick won't show Ghostscipt as delegate - delegates

Was trying to get ImageMagick to talk to Ghostscript using MacPorts in OSX Lion but it wouldn't have it. Used to have it working fine under Snow Leopard but something went amiss during Migration assistant.
Anyhow, have unstalled all of Mac Ports and am now trying using Homebrew
Have installed Homebrew, installed ImageMagick and then ghostscript. Imagemagick is working fine (using a php image script and MAMP) but Ghostscript is not converting PDF's to jpgs. I can see than 'gs' is not listed as a delegate of Imagemagick.
Here are some relevant Terminal dumps:
convert -list delegate
Path: /usr/local/Cellar/imagemagick/6.7.7-6/etc/ImageMagick/delegates.xml
Delegate Command
-------------------------------------------------------------------------------
blender => "blender" -b "%i" -F PNG -o "%o""\n"convert" -concatenate "%o*.png" "%o"
cdr => "uniconvertor" "%i" "%o.svg"; mv "%o.svg" "%o"
cgm => "ralcgm" -d ps -oC "%o" 2> "%Z"
dng:decode => "ufraw-batch" --silent --create-id=also --out-type=png --out-depth=16 "--output=%u.png" "%i"
dvi => "dvips" -q -o "%o" "%i"
epsps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"
epspdf "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
fig => "fig2dev" -L ps "%i" "%o"
hpg => "hp2xx" -q -m eps -f `basename "%o"` "%i"; mv -f `basename "%o"` "%o"
hpgl => "if [ -e hp2xx -o -e /usr/bin/hp2xx ]; then hp2xx -q -m eps -f `basename "%o"` "%i"; mv -f `basename "%o"` "%o"; else echo "You need to install hp2xx to use HPGL files with ImageMagick."; exit 1; fi"
htm => "html2ps" -U -o "%o" "%i"
html => "html2ps" -U -o "%o" "%i"
https => "curl" -s -k -o "%o" "https:%M"
ilbm => "ilbmtoppm" "%i" > "%o"
man => "groff" -man -Tps "%i" > "%o"
miff "ffmpeg" -v -1 -i "%i" -vframes %S -vcodec pam -an -f rawvideo -y "%u.pam" 2> "%Z"
pdfeps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
pdfps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"
plt => "echo" "set size 1.25,0.62; set terminal postscript portrait color solid; set output \'%o\'; load \'%i\'" > "%u";"gnuplot" "%u"
pnm "%o"
pov => "povray" "+i%i" -D0 "+o%o" +fn%q +w%w +h%h +a -q9 "-kfi%s" "-kff%n";"convert" -concatenate "%o*.png" "%o"
pseps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
pspdf "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
rgba "scanimage" -d "%i" > "%o"
scanx => "scanimage" > "%o"
shtml => "html2ps" -U -o "%o" "%i"
sid => "mrsidgeodecode" -if sid -i "%i" -of tif -o "%o" > "%u"
svg => "rsvg-convert" -o "%o" "%i"
tiffps "enscript" -o "%o" "%i"
wmf => "wmf2eps" -o "%o" "%i"
doms-imac:~ dom$ convert -list delegate | grep --color -E '(eps|pdf)'
epsps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"
epspdf "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
hpg => "hp2xx" -q -m eps -f `basename "%o"` "%i"; mv -f `basename "%o"` "%o"
hpgl => "if [ -e hp2xx -o -e /usr/bin/hp2xx ]; then hp2xx -q -m eps -f `basename "%o"` "%i"; mv -f `basename "%o"` "%o"; else echo "You need to install hp2xx to use HPGL files with ImageMagick."; exit 1; fi"
pdfeps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
pdfps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"
pseps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
pspdf "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
wmf => "wmf2eps" -o "%o" "%i"
convert -list configure
Path: /usr/local/Cellar/imagemagick/6.7.7-6/lib/ImageMagick/config/configure.xml
Name Value
-------------------------------------------------------------------------------
CC /usr/bin/clang
CFLAGS -D_THREAD_SAFE -D_THREAD_SAFE -pthread -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7 -Wall -D_THREAD_SAFE -pthread
CODER_PATH /usr/local/Cellar/imagemagick/6.7.7-6/lib/ImageMagick/modules-Q16/coders
CONFIGURE ./configure '--disable-osx-universal-binary' '--without-perl' '--prefix=/usr/local/Cellar/imagemagick/6.7.7-6' '--disable-dependency-tracking' '--enable-shared' '--disable-static' '--with-modules' '--without-magick-plus-plus' 'CC=/usr/bin/clang' 'CFLAGS=-Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7' 'LDFLAGS=-L/usr/local/Cellar/gettext/0.18.1.1/lib -L/usr/local/lib -L/usr/X11/lib' 'CPPFLAGS=-I/usr/local/Cellar/gettext/0.18.1.1/include -isystem /usr/local/include -I/usr/X11/include' 'CXX=/usr/bin/clang++' 'CXXFLAGS=-Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7'
CONFIGURE_PATH /usr/local/Cellar/imagemagick/6.7.7-6/etc/ImageMagick/
COPYRIGHT Copyright (C) 1999-2012 ImageMagick Studio LLC
CPPFLAGS -I/usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick
CXX /usr/bin/clang++
CXXFLAGS -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7 -D_THREAD_SAFE -pthread
DEFS -DHAVE_CONFIG_H
DELEGATES bzlib fontconfig freetype jpeg jng jp2 lcms2 png tiff x11 xml zlib
DISTCHECK_CONFIG_FLAGS 'CC=/usr/bin/clang' 'CFLAGS=-Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7' 'CPPFLAGS=-I/usr/local/Cellar/gettext/0.18.1.1/include -isystem /usr/local/include -I/usr/X11/include' 'CXX=/usr/bin/clang++' 'LDFLAGS=-L/usr/local/Cellar/gettext/0.18.1.1/lib -L/usr/local/lib -L/usr/X11/lib' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-gslib=no --with-fontpath= --with-wmf=no --with-perl=no
DOCUMENTATION_PATH /usr/local/Cellar/imagemagick/6.7.7-6/share/doc/ImageMagick
EXEC-PREFIX /usr/local/Cellar/imagemagick/6.7.7-6
EXECUTABLE_PATH /usr/local/Cellar/imagemagick/6.7.7-6/bin
FEATURES OpenCL
FILTER_PATH /usr/local/Cellar/imagemagick/6.7.7-6/lib/ImageMagick/modules-Q16/filters
HOST x86_64-apple-darwin11.4.0
INCLUDE_PATH /usr/local/Cellar/imagemagick/6.7.7-6/include/ImageMagick
LDFLAGS -L/usr/local/Cellar/imagemagick/6.7.7-6/lib -L/usr/local/Cellar/gettext/0.18.1.1/lib -L/usr/local/lib -L/usr/X11/lib -L/usr/X11/lib
LIB_VERSION 0x677
LIB_VERSION_NUMBER 6,7,7,6
LIBRARY_PATH /usr/local/Cellar/imagemagick/6.7.7-6/lib/ImageMagick
LIBS -lMagickCore -llcms2 -ltiff -lfreetype -ljpeg -L/usr/X11/lib -lfontconfig -lXext -lSM -lICE -lX11 -lXt -lbz2 -lz -lm -Wl,-framework,OpenCL -lm -lpthread -lltdl
NAME ImageMagick
PCFLAGS
PREFIX /usr/local/Cellar/imagemagick/6.7.7-6
QuantumDepth 16
RELEASE_DATE 2012-08-08
SHARE_PATH /usr/local/Cellar/imagemagick/6.7.7-6/share/ImageMagick
SVN_REVISION 8165
TARGET_CPU x86_64
TARGET_OS darwin11.4.0
TARGET_VENDOR apple
VERSION 6.7.7
WEBSITE http://www.imagemagick.org
How do I force Ghostscript to be seen as a delegate by ImageMagick?
 

Well, in your listing coming from convert -list delegate there are the following six lines:
eps<=>ps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"
eps<=>pdf "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
pdf<=>eps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
pdf<=>ps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pswrite" "-sOutputFile=%o" "-f%i"
ps<=>eps "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=epswrite" "-sOutputFile=%o" "-f%i"
ps<=>pdf "gs" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pdfwrite" "-sOutputFile=%o" "-f%i"
They all do mention "gs"...
However, you say you first installed ImageMagick and only then Ghostscript.
So ImageMagick could not find any Ghostscript during compile time, that's why it doesn't appear in convert -list configure | grep DELEG....
You should try and install in reverse order: first Ghostscript, then ImageMagick....

tl;dr
For latecomers, this is the short version of #Kurt Pfeifle's answer + comment section. Just run
brew update \
&& brew reinstall ghostscript \
&& brew reinstall imagemagick --with-ghostscript

Do you have multiple installations of ImageMagick's convert on your system (maybe because your MacPorts installation wasn't cleanly removed)? To find out, run this commandline (which uses Spotlight search):
mdfind convert 2>&1 | grep convert
Update your question with the full info coming from these commands:
which convert
convert -list configure
convert -version
otool -L $(which convert)
which gsx
which gsc
which gs
gs -version
otool -L $(which gs)

Related

MacOs Qt build from source with custom ICU

I am trying to build Qt on Mac from source. Using ICU from custom location.
so in ./configure I added -icu -L ${MEMSOURCE_LIB}/icu/lib -I ${MEMSOURCE_LIB}/icu/include
I added icu/bin to PATH.
In this configuration qt manages to configure and pass tests resulting in ICU ................... yes
However during the make step I get:
dyld: Library not loaded: #rpath/libicui18n.65.dylib
Referenced from: /Users/tpnsvo/__TE/lib_qt5_15_4_release/qt5/qtbase/lib/QtCore.framework/Versions/5/QtCore
Reason: image not found
How do I make it?
I tried:
bash
make -d
to get more info. Found nothing relevant.
I tried setting DYLD(_FALLBACK)_LIBRARY_PATH and similar.
No success.
build script:
#!/bin/bash
set -e
[ -z "$MEMSOURCE_LIB" ] && MEMSOURCE_LIB=$1
[ -z "$MEMSOURCE_LIB" ] && echo "Qt build: no MEMSOURCE_LIB" && exit 1
[ -z "$BUILD_TYPE" ] && BUILD_TYPE=$2
[ -z "$BUILD_TYPE" ] && echo "ICU: BUILD_TYPE not specified" && exit 1
QT_COMPILATION_PARAMS=""
if [ $BUILD_TYPE = "release" ]
then
QT_COMPILATION_PARAMS="-release -force-debug-info"
elif [ $BUILD_TYPE = "debug" ]
then
QT_COMPILATION_PARAMS="-debug -force-debug-info"
fi
cd "$MEMSOURCE_LIB/qt5"
PATH=$PATH:${MEMSOURCE_LIB}/icu/bin
export DYLD_FALLBACK_LIBRARY_PATH="$DYLD_FALLBACK_LIBRARY_PATH":${MEMSOURCE_LIB}/icu/lib
export LD_RUNPATH_SEARCH_PATH=${MEMSOURCE_LIB}/icu/lib
./configure \
${QT_COMPILATION_PARAMS} \
-recheck-all \
-c++std c++14 \
-prefix ${MEMSOURCE_LIB}/qt5_install \
\
-confirm-license \
-feature-commandlineparser \
-opengl desktop \
-icu -L ${MEMSOURCE_LIB}/icu/lib -I ${MEMSOURCE_LIB}/icu/include \
-opensource \
-qt-harfbuzz \
-qt-libjpeg \
-qt-libpng \
-securetransport \
-system-zlib \
-v \
\
-no-avx \
-no-avx2 \
-no-sse4.1 \
-no-sse4.2 \
\
-no-dbus \
-no-feature-cups \
-no-feature-d3d12 \
-no-feature-ftp \
-no-feature-lcdnumber \
-no-feature-pdf \
-no-feature-pdf-widgets \
-no-feature-printdialog \
-no-feature-printer \
-no-feature-printpreviewdialog \
-no-feature-printpreviewwidget \
-no-feature-qml-devtools \
-no-feature-qml-preview \
-no-feature-qml-profiler \
-no-opengles3 \
-no-pch \
-no-qml-debug \
-no-sql-odbc \
-no-sql-psql \
-no-sql-sqlite \
-no-sql-sqlite2 \
-no-webengine-printing-and-pdf \
-no-webengine-spellchecker \
-no-webengine-webrtc \
\
-nomake examples \
-nomake tests \
-nomake tools
cd "$MEMSOURCE_LIB/qt5"
make -j3
make install
echo "Qt build: ALL OK"
Last command before error and error
/Users/tpnsvo/Downloads/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -g -std=c++1y -fapplication-extension -arch x86_64 -isysroot /Users/tpnsvo/Downloads/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.13 -fvisibility=hidden -fvisibility-inlines-hidden -fno-exceptions -Wall -Wextra -Winconsistent-missing-override -Wobjc-interface-ivars -Wobjc-method-access -Wobjc-multiple-method-names -Werror=unguarded-availability -Werror=unguarded-availability-new -Werror=unsupported-availability-guard -fPIC -DQT_NO_LINKED_LIST -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_USING_NAMESPACE -DQT_NO_FOREACH -DQT_USE_SYSTEM_PROXIES -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DGL_SILENCE_DEPRECATION -DQT_BUILD_NETWORK_LIB -DQT_BUILDING_QT -DQT_NO_CAST_TO_ASCII -DQT_ASCII_CAST_WARNINGS -DQT_MOC_COMPAT -DQT_USE_QSTRINGBUILDER -DQT_DEPRECATED_WARNINGS -DQT_DISABLE_DEPRECATED_BEFORE=0x050000 -DQT_DEPRECATED_WARNINGS_SINCE=0x060000 -DQT_NO_EXCEPTIONS -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -DQT_NO_DEBUG -DQT_CORE_LIB -I. -Ikernel -I../../include -I../../include/QtNetwork -I../../include/QtNetwork/5.15.4 -I../../include/QtNetwork/5.15.4/QtNetwork -I../../include/QtCore/5.15.4 -I../../include/QtCore/5.15.4/QtCore -I../../include/QtCore -I.moc -I/Users/tpnsvo/__TE/lib_qt5_15_4_release/icu/include -I../../mkspecs/macx-clang -F/Users/tpnsvo/__TE/lib_qt5_15_4_release/qt5/qtbase/lib -o .obj/qhttpsocketengine.o socket/qhttpsocketengine.cpp
error:
dyld: Library not loaded: #rpath/libicui18n.65.dylib
Referenced from: /Users/tpnsvo/__TE/lib_qt5_15_4_release/qt5/qtbase/lib/QtCore.framework/Versions/5/QtCore
Reason: image not found
Need a job token; we have children
Duplicate the job FD
Live child 0x7fa93aa3ce60 (vulkan/qvulkanfunctions.h) PID 20806
Reaping losing child 0x7fa93aa3ce60 PID 20806
make[3]: *** [vulkan/qvulkanfunctions.h] Abort trap: 6
Removing child 0x7fa93aa3ce60 PID 20806 from chain.
Reaping losing child 0x7ffd9a008bd0 PID 17745
make[2]: *** [sub-gui-make_first] Error 2
Removing child 0x7ffd9a008bd0 PID 17745 from chain.
Released token for child 0x7ffd9a008bd0 (sub-gui-make_first).
make[2]: *** Waiting for unfinished jobs....Obtained token for child 0x7fc4cd024f00 (.obj/qnativesocketengine.o).```

Print the last saved screenshot with Terminal

This shows the last saved screenshot (on my Desktop path):
ls -t | head -n1
This prints perfectly:
lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 image.png
How does one combine them?
Without really knowing what I'm doing I've tried this:
ls -t | head -n1 |awk '{lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 $0}'
which, naturally fails:
lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 "$(ls -t | head -n1)"
Or more clear:
filetouse="$(ls -t | head -n1)"
lpoptions=( -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 )
lp "${lpoptions[#]}" "${filetouse}"
Ok, just managed to do it.
This worked:
ls -t | head -n1 | xargs -I {} lp -o -scaling=50 -o media=Custom.60x42mm -o page-left=0 -o page-right=0 -o page-top=5 -o page-bottom=5 {}
Thanks to this question.

How to add dependency in a generated Makefile

I have to modify an broken project which has errors in Makefile. However, I'm new to libtool and couldn't figure out where I should modify in the Makefile. The error is
../libpsc/.libs/libpsc.a(push_part_1vb_mix.o):(.rodata+0x38): undefined reference to `psc_push_particles_1vb_ps2_ops'
The object file which contains psc_push_particles_1vb_ps2_ops is located in ../libpsc/sse2 folder. How to modify the Makefile to let the linker find this object file? I attached portion of the Makefile. Any suggestions will be appreciated. Thanks in advance!
# Makefile.in generated by automake 1.11.6 from Makefile.am.
# src/Makefile. Generated from Makefile.in by configure.
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
# Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; #echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgdatadir = $(datadir)/psc
pkgincludedir = $(includedir)/psc
pkglibdir = $(libdir)/psc
pkglibexecdir = $(libexecdir)/psc
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = x86_64-unknown-linux-gnu
host_triplet = x86_64-unknown-linux-gnu
bin_PROGRAMS = psc_es1$(EXEEXT) psc_bohm$(EXEEXT) psc_spitzer$(EXEEXT) \
psc_kelvin_helmholtz$(EXEEXT) \
psc_kelvin_helmholtz_double$(EXEEXT) psc_mirror$(EXEEXT) \
psc_harris$(EXEEXT) psc_bubble$(EXEEXT) psc_bubble_yz$(EXEEXT) \
psc_test_emission$(EXEEXT) psc_test_singlepart$(EXEEXT) \
psc_test_microsphere$(EXEEXT) psc_photon_test$(EXEEXT) \
psc_test_twoparticles$(EXEEXT) psc_test_heating$(EXEEXT) \
psc_test_fdtd$(EXEEXT)
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compiler_flags.m4 \
$(top_srcdir)/m4/ax_check_hdf5.m4 $(top_srcdir)/m4/libtool.m4 \
$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
psc_bohm_SOURCES = psc_bohm.c
psc_bohm_OBJECTS = psc_bohm.$(OBJEXT)
psc_bohm_LDADD = $(LDADD)
psc_bohm_DEPENDENCIES = libpsc/libpsc.la libmrc/src/libmrc.la
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
am__v_lt_0 = --silent
psc_bubble_SOURCES = psc_bubble.c
# Skip hundreds of lines...
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
include ./$(DEPDIR)/dummy.Po
include ./$(DEPDIR)/psc_bohm.Po
include ./$(DEPDIR)/psc_bubble.Po
include ./$(DEPDIR)/psc_bubble_yz.Po
include ./$(DEPDIR)/psc_es1.Po
include ./$(DEPDIR)/psc_harris.Po
include ./$(DEPDIR)/psc_kelvin_helmholtz.Po
include ./$(DEPDIR)/psc_kelvin_helmholtz_double.Po
include ./$(DEPDIR)/psc_mirror.Po
include ./$(DEPDIR)/psc_photon_test.Po
include ./$(DEPDIR)/psc_spitzer.Po
include ./$(DEPDIR)/psc_test_emission.Po
include ./$(DEPDIR)/psc_test_fdtd.Po
include ./$(DEPDIR)/psc_test_heating.Po
include ./$(DEPDIR)/psc_test_microsphere.Po
include ./$(DEPDIR)/psc_test_singlepart.Po
include ./$(DEPDIR)/psc_test_twoparticles.Po
.c.o:
$(AM_V_CC)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
$(COMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CC)source='$<' object='$#' libtool=no \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(AM_V_CC_no)$(COMPILE) -c -o $# $<
.c.obj:
$(AM_V_CC)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
$(COMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# `$(CYGPATH_W) '$<'` &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CC)source='$<' object='$#' libtool=no \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(AM_V_CC_no)$(COMPILE) -c -o $# `$(CYGPATH_W) '$<'`
.c.lo:
$(AM_V_CC)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
$(LTCOMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Plo
# $(AM_V_CC)source='$<' object='$#' libtool=yes \
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
# $(AM_V_CC_no)$(LTCOMPILE) -c -o $# $<
.cxx.o:
$(AM_V_CXX)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
$(CXXCOMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CXX)source='$<' object='$#' libtool=no \
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(CXXCOMPILE) -c -o $# $<
.cxx.obj:
$(AM_V_CXX)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
$(CXXCOMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# `$(CYGPATH_W) '$<'` &&\
$(am__mv) $$depbase.Tpo $$depbase.Po
# $(AM_V_CXX)source='$<' object='$#' libtool=no \
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(CXXCOMPILE) -c -o $# `$(CYGPATH_W) '$<'`
.cxx.lo:
$(AM_V_CXX)depbase=`echo $# | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
$(LTCXXCOMPILE) -MT $# -MD -MP -MF $$depbase.Tpo -c -o $# $< &&\
$(am__mv) $$depbase.Tpo $$depbase.Plo
# $(AM_V_CXX)source='$<' object='$#' libtool=yes \
# DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) \
# $(AM_V_CXX_no)$(LTCXXCOMPILE) -c -o $# $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
# Skipped the lines left

Using a variable in a bash script for loop

I have a file which has the number of .pdfs in my folder. I assign this number to a variable, fileNum like so:
fileNum=$(ls -l *.pdf | wc -l)
echo $fileNum returns this number without any problem.
Now I need to use fileNum in a for loop and I am having problems with it.
My for loop is:
for i in {1..$fileNum}
do
var=$(awk 'NR=='$i 'pdfs.file')
gs \
-sOutputFile="exgs_"$var \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-dProcessColorModel=/DeviceGray \
-dCompatibilityLevel=1.4 \
-dNOPAUSE \
-dBATCH \
$var
done
The $ at the beginning of fileNum gives me an error message which is:
awk: line 1: syntax error at or near {
Things are fine when I actually use the number itself (which in this case is 17).
Obviously, awk doesn't like this because of ... something.... I don't know what. What should I do about this?
I tried other forms such as $(fileNum) and filenum with the single quotes around it.
Is it something to do with strings?
I'd use bash to read the file instead of running awk for every line.
while read -r file; do
gs -sOutputFile="exgs_$file" \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-dProcessColorModel=/DeviceGray \
-dCompatibilityLevel=1.4 \
-dNOPAUSE \
-dBATCH \
"$file"
done < pdfs.file
See also http://mywiki.wooledge.org/BashFAQ/001
Otherwise, for the general case where you want to iterate from 1 to n, I'd use a C-style for-loop.
n=10
for (( i=1; i <= n; i++)); do
...
done
This is because Bash will do the expansion on the braces before the variable. You need to use eval in this case so that Bash expands the variable first.
for i in $(eval echo {1..$fileNum})
do
var=$(awk 'NR=='$i 'pdfs.file')
gs \
-sOutputFile="exgs_"$var \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-dProcessColorModel=/DeviceGray \
-dCompatibilityLevel=1.4 \
-dNOPAUSE \
-dBATCH \
$var
done
I would rather write:
for i in $(seq $fileNum)
do
....
done

Makefile to CMakeLists.txt

I have some problems converting the attached Makefile to an equivalent CMakeLists.txt .
The build process goes like that :
Generate src/lexer.cpp given src/lexer.l.cpp with flex.
Generate src/parser.cpp given src/parser.y.cpp with bison.
Compile almost anything inside src/ into a .so library.
Recompile them with different flags to generate an executable.
Compile sources inside stdlib/ directories three, output the binaries to build/ so that :
stdlib/std/hashing/md5.cc
Would become
build/std/hashing/md5.so
But i really don't know how to reproduce this process with cmake macros ... any help ?
CXX=g++
WFLAGS= -w
OPTIMIZATION= -O3 -pipe -fomit-frame-pointer -ffast-math
CFLAGS= -Iinclude/ $(WFLAGS) $(OPTIMIZATION)
LFLAGS= -ldl -lpcre -lpthread
LIBXML_CFLAGS= `xml2-config --cflags`
LIBXML_LFLAGS= `xml2-config --libs`
LIBFFI_CFLAGS= `pkg-config libffi --cflags`
LIBFFI_LFLAGS= `pkg-config libffi --libs`
STDLIB_LFLAGS= -ldl -lpcre -lcurl -lpthread $(LIBXML_LFLAGS) $(LIBFFI_LFLAGS)
STDLIB_CFLAGS= $(WFLAGS) -L. -I./include/ $(OPTIMIZATION) -fPIC $(LIBXML_CFLAGS) $(LIBFFI_CFLAGS) -lhybris -lc -shared
PREFIX=/usr
TARGET=hybris
LIBOBJ=src/context.lo \
src/gc.lo \
src/common.lo \
src/engine.lo \
src/node.lo \
src/types.lo \
src/types/binary.lo \
src/types/char.lo \
src/types/float.lo \
src/types/integer.lo \
src/types/map.lo \
src/types/matrix.lo \
src/types/string.lo \
src/types/structure.lo \
src/types/class.lo \
src/types/vector.lo \
src/hashtable.lo \
src/vmem.lo \
src/vcode.lo \
src/parser.lo \
src/lexer.lo
SOURCES=src/common.cpp \
src/gc.cpp \
src/lexer.cpp \
src/context.cpp \
src/hashtable.cpp \
src/vmem.cpp \
src/vcode.cpp \
src/node.cpp \
src/types.cpp \
src/types/binary.cpp \
src/types/char.cpp \
src/types/float.cpp \
src/types/integer.cpp \
src/types/map.cpp \
src/types/matrix.cpp \
src/types/string.cpp \
src/types/structure.cpp \
src/types/class.cpp \
src/types/vector.cpp \
src/engine.cpp \
src/parser.cpp
STDSRC=stdlib/std/hashing/md5.cc \
stdlib/std/hashing/crc32.cc \
stdlib/std/hashing/sha1.cc \
stdlib/std/hashing/sha2.cc \
stdlib/std/io/network/http.cc \
stdlib/std/io/network/tcp.cc \
stdlib/std/io/network/smtp.cc \
stdlib/std/io/file.cc \
stdlib/std/io/console.cc \
stdlib/std/io/xml.cc \
stdlib/std/type/reflection.cc \
stdlib/std/type/string.cc \
stdlib/std/type/matrix.cc \
stdlib/std/type/array.cc \
stdlib/std/type/map.cc \
stdlib/std/type/type.cc \
stdlib/std/type/binary.cc \
stdlib/std/encoding.cc \
stdlib/std/os/dll.cc \
stdlib/std/os/time.cc \
stdlib/std/os/threads.cc \
stdlib/std/os/process.cc \
stdlib/std/gc.cc \
stdlib/std/pcre.cc \
stdlib/std/math.cc
OBJECTS=$(SOURCES:.cpp=.o)
LOBJECTS=$(SOURCES:.cpp=.lo)
STDOBJ=$(patsubst stdlib%.cc,build%.so, $(STDSRC))
all: src/lexer.cpp src/parser.cpp lib hybris stdlib
lib: $(LOBJECTS)
$(CXX) -shared -Wl,-soname,libhybris.so.1 -o lib$(TARGET).so.1.0 $(LIBOBJ)
ln -sf lib$(TARGET).so.1.0 lib$(TARGET).so
ln -sf lib$(TARGET).so.1.0 lib$(TARGET).so.1
hybris: $(OBJECTS)
$(CXX) src/*.o src/types/*.o -o $(TARGET) $(CFLAGS) $(LFLAGS)
stdlib: $(STDOBJ)
.cpp.o:
$(CXX) -c $< -o $# $(CFLAGS)
.cpp.lo:
$(CXX) -c $< -o $# $(CFLAGS) -fPIC
build/%.so: stdlib/%.cc
mkdir -p $(dir $#)
$(CXX) $< -o $# $(STDLIB_CFLAGS) $(STDLIB_LFLAGS)
src/parser.cpp: src/parser.y.cpp
bison -y -d -o $# $?
src/lexer.cpp: src/lexer.l.cpp
flex -o $# $?
For the flex/bison part (warning: untested, I usually have .ypp and .lpp suffixes for parser+lexer files):
cmake_minimum_required(VERSION 2.8)
set(SOURCES src/common.cpp src/gc.cpp src/lexer.cpp ...)
include(FindBISON)
include(FindFLEX)
bison_target(parser src/parser.y.cpp ${CMAKE_CURRENT_BINARY_DIR}/src/parser.cpp)
flex_target(lexer src/module/parametrierung/driverlexer.lpp ${CMAKE_CURRENT_BINARY_DIR}/driverlexer.cpp)
add_flex_bison_dependency(lexer parser)
add_library(libhybris SHARED ${BISON_parser_OUTPUTS} ${FLEX_lexer_OUTPUTS} ${SOURCES})

Resources