How to print to commandline in nmake? - gnu-make

Is there a command/function in nmake to print to the commandline similar to what is available in GNU make with $(info ...)?
I cannot use echo.

Related

gnu make - assert specific command line tools are available

In a makefile, how would I make sure that certain tools like gcov, lcov, g++ are available before executing any other targets?
I want to gracefully fail with
gcov/lcov/g++ not available
.
You could try something like:
TOOLS := gcov lcov g++
$(foreach TOOL,$(TOOLS),\
$(if $(shell command -v $(TOOL)),,\
$(error Cannot locate $(TOOL) on PATH)))
This assumes you're using a POSIX shell obviously.

How to put command with doxygen into makefile

I use linux and filter doxygen output as follows:
doxygen 2> >(grep "Arguments.h") 1> /dev/null
which is just to concentrate on failures within Arguments.h.
Now i want to put all that in a minimal makefile for GNU Make 4.3
doc:
doxygen 2> >(grep "Arguments.h") 1> /dev/null
of course later to replace Arguments.h by some other file.
But this does not work: reply is
doxygen 2> >(grep "Arguments.h") 1> /dev/null
/bin/sh: -c: line 0: syntax error near unexpected token `>'
/bin/sh: -c: line 0: `doxygen 2> >(grep "Arguments.h") 1> /dev/null'
make: *** [makefile:2: doc] Error 1
as far as i know make... one has to escape sth, but no idea what...
Any specialists which can help?
This is not related to escaping etc. This is related to which shell is being used.
GNU make (as with all versions of make) always invokes /bin/sh to run recipes, and that is a POSIX standard shell (or some proximity to it). The command you're using is definitely not supported by the POSIX standard, it appears to be using many features available only as enhancements in the bash shell.
If you want to write your recipes using bash features you have to tell make that it should be using bash as the shell, not /bin/sh. You can add this to your makefile:
SHELL = /bin/bash

How to execute a common lisp text file (clozure cl)?

I am a beginner at Lisp, having only used DrRacket for some dabbling in Racket/Scheme. I have had much trouble figuring out how to run a .lisp file with Clozure CL for Windows. I tried running a .lisp file in SBCL on Ubuntu (running on virtualbox) without success as well.
I should mention that I've looked into the related questions about running files but I wasn't able to see any direct solution. Some are using .bat files, some are "creating applications" with Clozure CL's image (or something along those lines).
For SBCL in Ubuntu, I've tried:
sbcl lisptest.lisp \ The python/forth way.
(load "lisptest.lisp")
(load lisptest.lisp)
(--load lisptest.lisp)
:cd C:\Temp
(:cd C:\Temp)
and more.
I also tried to run it from notepad++:
cmd /k C:\Temp\ccl-1.11-windows\ccl\wx86cl64.exe "$(FULL_CURRENT_PATH)"
which is how I usually execute python files, but this method hasn't been successful.
**I will definitely start learning to use Emacs and Slime (Emacs is the obvious choice for lisp). But for the sake of knowledge, I would appreciate some tips on the alternative, basic-text-editor way of getting something trivial like "hello world" to print without my typing it explicity into the REPL and instead interpreting (or compiling) a text file with the instruction.
Thanks for your help.
Typically programs have help - did you look at that?
SBCL, Ubuntu, from the shell:
A Common Lisp file:
$ cat test.lisp
(format t "Hello World~%~%")
SBCL shows help:
$ sbcl --help
Usage: sbcl [runtime-options] [toplevel-options] [user-options]
Common runtime options:
--help Print this message and exit.
--version Print version information and exit.
--core <filename> Use the specified core file instead of the default.
--dynamic-space-size <MiB> Size of reserved dynamic space in megabytes.
--control-stack-size <MiB> Size of reserved control stack in megabytes.
Common toplevel options:
--sysinit <filename> System-wide init-file to use instead of default.
--userinit <filename> Per-user init-file to use instead of default.
--no-sysinit Inhibit processing of any system-wide init-file.
--no-userinit Inhibit processing of any per-user init-file.
--disable-debugger Invoke sb-ext:disable-debugger.
--noprint Run a Read-Eval Loop without printing results.
--script [<filename>] Skip #! line, disable debugger, avoid verbosity.
--quit Exit with code 0 after option processing.
--non-interactive Sets both --quit and --disable-debugger.
Common toplevel options that are processed in order:
--eval <form> Form to eval when processing this option.
--load <filename> File to load when processing this option.
User options are not processed by SBCL. All runtime options must
appear before toplevel options, and all toplevel options must
appear before user options.
For more information please refer to the SBCL User Manual, which
should be installed along with SBCL, and is also available from the
website <http://www.sbcl.org/>.
Using the script option from above:
$ sbcl --script test.lisp
Hello World
The same for Clozure CL
$ ccl --help
usage: ccl <options>
where <options> are one or more of:
-h, --help : this text
-V, --version : print (LISP-IMPLEMENTATION-VERSION) and exit
-K, --terminal-encoding : specify character encoding to use for *TERMINAL-IO*
-n, --no-init : suppress loading of init file
-e, --eval : evaluate <form> (may need to quote <form> in shell)
-l, --load : load <file>
-T, --set-lisp-heap-gc-threshold : set lisp-heap-gc-threshold to <n>
-Q, --quiet : if --batch, also suppress printing of heralds, prompts
-R, --heap-reserve <n>: reserve <n> (default: 1610612736)
bytes for heap expansion
-S, --stack-size <n>: set size of initial thread's control stack to <n>
-Z, --thread-stack-size <n>: set default size of first (listener) thread's stacks based on <n>
-b, --batch: exit when EOF on *STANDARD-INPUT*
--no-sigtrap : obscure option for running under GDB
--debug : try to ensure that kernel debugger uses a TTY for I/O
-I, --image-name <image-name>
and <image-name> defaults to ccl.image
Any arguments following the pseudoargument "--" are
not processed and are available to the application as
the value of CCL:*UNPROCESSED-COMMAND-LINE-ARGUMENTS* .
Using the load option from above
$ ccl --load test.lisp --eval '(quit)'
Hello World
 
Try
C:/path/to/ccl -l lisptest.lisp
This should work the same as
(load "lisptest.lisp")
If you can let us know specifically how that fails, we can be of more help.

Embed R code into BASH unix script

We know that we can embed AWK or SED directly into a BASH script by
awk { ....}
. I wanted to do something similar to R such as
mybashscript.sh
R { .... }
without having to create a .R file and calling the .R file from bash using Rscript myRscript.R
Is there a way to do this. I have searched everywhere but was not able to find an answer. Please help.
You can easily embed R code directly into a bash script using the Rscript command, and specifically, with regards to your question, the -e expr construction. Check man Rscript.
An example:
#!/bin/bash
echo "This is a bash script"
echo "Running R code..."
Rscript -e 'cat("hello world")'
Bash is able to execute a statement from an arbitrary scripting language. It is in the form VARIABLE_NAME=$(INTERPRETER -c "EMBEDDED CODE"). In the case of R INTERPRETER -c would be replaced with R --arch i386 -q --slave -e. The --arch option can be any supported architecture such as i386 or x64, -q keep the interpreter from printing start-up info and --slave keeps the output as clean as possible.

make sees different PATH than account's .bashrc-configured PATH

I want to call ShellCheck, a Haskell program for linting shell scripts, from a Makefile.
When I install ShellCheck via cabal install, it is installed as ~/.cabal/bin/shellcheck. So, I have configured Bash accordingly:
$ cat ~/.bashrc
export PATH="$PATH:~/.cabal/bin"
$ source ~/.bashrc
$ shellcheck -V
ShellCheck - shell script analysis tool
version: 0.3.4
license: GNU Affero General Public License, version 3
website: http://www.shellcheck.net
This enables me to run shellcheck from any directory in Bash. However, when I try to call it from a Makefile, make cannot find shellcheck.
$ cat Makefile
shlint:
-shlint lib/
shellcheck:
-shellcheck lib/**
lint: shlint shellcheck
$ make shellcheck
shellcheck lib/**
/bin/sh: 1: shellcheck: not found
make: [shellcheck] Error 127 (ignored)
I think that make is not receiving the same PATH as my normal Bash shell. How can I fix this?
Try using $HOME, not ~:
export PATH="$PATH:$HOME/.cabal/bin"
The ~-means-home-directory feature is not supported in pathnames everywhere in all shells. When make runs a recipe it doesn't use the user's shell (that would be a disaster!) it uses /bin/sh always.
On some systems (particularly Debian/Ubuntu-based GNU/Linux distributions) the default /bin/sh is not bash, but rather dash. Dash doesn't support ~ being expanded in the PATH variable.
In general, you should reserve ~ for use on the command line as a shorthand. But in scripting, etc. you should always prefer to write out $HOME.
ETA:
Also, the double-star syntax lib/** is a non-standard feature of shells like bash and zsh and will not do anything special in make recipes. It is identical to writing lib/*.
You can force make to use a different shell than /bin/sh by adding:
SHELL := /bin/bash
to your makefile, for example, but this makes it less portable (if that's an issue).

Resources