make + tex: file not found - makefile

I have a directory with the following files
➜ hrrep git:(master) ✗ ls -l
total 1000
drwxrwxrwx 22 zmjones staff 748 May 28 23:28 data
-rw-rw-rw- 1 zmjones staff 7180 May 20 16:17 data.R
drwxrwxrwx 9 zmjones staff 306 May 28 23:38 figures
-rw-r--r-- 1 zmjones staff 85841 May 28 23:23 hill_jones_hr.bib
-rw-r--r-- 1 zmjones staff 29193 May 28 22:23 hill_jones_hr.tex
-rw-r--r-- 1 zmjones staff 572 May 28 23:46 makefile
-rw-rw-rw- 1 zmjones staff 9588 May 28 22:47 models.R
drwxrwxrwx 3 zmjones staff 102 May 28 23:28 papers
drwxrwxrwx 9 zmjones staff 306 May 28 23:28 tex
-rw-r--r-- 1 zmjones staff 1483 May 20 12:58 un_data.py
These files are described by a makefile (using GNU Make 3.81)
all: ./data/cat_un_data.csv ./data/rep.csv ./figures/*.png ./hj-hr.pdf
./data/cat_un_data.csv: un_data.py #refreshing one will refresh all
python un_data.py
./data/rep.csv: data.R ./data/cat_un_data.csv
R CMD BATCH --no-save --no-restore data.R
./figures/*.png: models.R ./data/rep.csv
R CMD BATCH --no-save --no-restore models.R
TEXMCD := pdflatex -interaction=batchmode
hill_jones_hr.pdf: hill_jones_hr.tex ./figures/*.png
$(TEXCMD) $<
]bibtex *.aux
$(TEXCMD) $<
$(TEXCMD) $<
find . | egrep ".*((\.(aux|log|blg|bbl|out|Rout|Rhistory|DS_Store))|~)$$" | xargs rm
rm -rf auto
The makefile seems to work fine until it gets to the hll_jones_hr.pdf target, where it fails with an error:
hill_jones_hr.tex
make: hill_jones_hr.tex: No such file or directory
make: *** [hill_jones_hr.pdf] Error 1
I don't understand what the problem is. The document compiles fine when I execute pdflatex and bibtex manually. I tried adding the ignore error flag to no avail. I presume this is some stupid make error that I am making. This folder is in Dropbox if that makes any difference. I also tried adding the ./ prefix to both the .tex file and the .pdf target; the error was the same.

The problem is that the $(TEXCMD) variable is not defined, so your command:
$(TEXCMD) $<
is expanding to just $< or just the filename, which is not a legal command by itself.

use ./hill_jones_hr.tex instead of hill_jones_hr.tex, and try again.

Related

`go list` prints out non-existing Target

As per golint's README.md:
To find out where golint was installed you can run `go list -f {{.Target}} golang.org/x/lint/golint`.
When I run the command I get:
/Users/Marko/go/bin/golint
But there is no such file:
ls -alF /Users/Marko/go/bin/
total 6432
drwxr-xr-x 3 Marko staff 96 Nov 29 12:32 ./
drwxr-xr-x 4 Marko staff 128 Nov 29 12:05 ../
-rwxr-xr-x 1 Marko staff 3289296 Nov 29 12:32 hello*
How can I find out where is golint?
You need to install it first. Run go get -u golang.org/x/lint/golint. I'm not sure why does go list still list it as a Target, even if it is not installed.

TAR override the contents of the directory

My understanding of tar command that it will override the content of the file if file exist. Otherwise it would keep as existing.
[root#something~]# ls -al /etc/init.d/
total XX
drwxr-xr-x. 2 root root 83 Jun 14 2018 .
drwxr-xr-x. 10 root root 127 Jun 6 2017 ..
-rwxr-xr-x. 1 root root 7293 Jan 2 2018 network
-rw-r--r--. 1 root root 1160 Feb 20 2018 README
[root#something~]# tar tvf /tmp/env_pkg_1.tar
drwxr-xr-x staff 0 2020-05-29 19:42 etc/
drwxr-xr-x user/staff 0 2020-05-29 18:04 etc/init.d/
-rw-r--r-- user/staff 3383 2020-05-29 18:04 etc/init.d/sshd
[root#something~]# cd /
[root#something /]# tar xf /tmp/env_pkg_1.tar
[root#something/]# ls -al /etc/init.d/
total 16
drwxr-xr-x 2 XXXXXX XXXXXX 18 May 29 18:04 .
drwxr-xr-x. 85 XXXXXX XXXXXX 8192 May 29 19:42 ..
-rw-r--r-- 1 XXXXXX XXXXXX 3383 May 29 18:04 sshd
I am not understand why tar is replacing the entire contents of /etc/init.d
Any inputs would be helpful ?
I belive that /etc/init.d is a link to /etc/rc.d/init.d.
When you untarred that file, it overwrote the link with a directory. All of your files are still in /etc/rc.d/init.d.
To fix your situation, remove /etc/init.d, relink it, and add a h to the tar command:
rm -rf /etc/init.d
cd /etc
ln -s ./rc.d/init.d
cd /
tar xhf /tmp/env_pkg_1.tar
You can use -k or --keep-old-files, so it does not touch any files that are already within the destination. Judging by your output in /etc/init.d/ you want to keep network and README and next to them extract sshd, so in your case, they do not overlap.
Alternatively --keep-newer-files will have tar replace files that are newer from the tar archive, than what's on the destination..

Makefile Macro to ignore all files named test

I'm trying to create a makefile for this project of mine, but I'm quite new to the concept. I have a makefile for each project, and a overarching make file in my main directory which I can call that communicates with all the other makefiles.
I have a few files I have named "test" to help me debug my project. By default, I want to have these test files included in my build, but with macro (ex: make TEST_FILES=false), I want to omit the files from the build.
Is there a convenient way to omit all files named "test"?
Thank you in advance!
Try something like this:
# Makefile
ifeq ($(TEST_FILES),false)
SOURCES := $(filter-out test%, $(wildcard *.txt))
else
SOURCES := $(wildcard *.txt)
endif
all:
#echo $(SOURCES)
which does this:
$ LC_ALL=C ls -nlah && \
> make all && \
> TEST_FILES=false make all
total 72K
drwx------ 2 10335 11111 4.0K May 26 15:36 .
drwxrwxrwt 585 0 0 60K May 26 15:31 ..
-rw-r--r-- 1 10335 11111 157 May 26 15:36 Makefile
-rw-r--r-- 1 10335 11111 0 May 26 14:57 bar.txt
-rw-r--r-- 1 10335 11111 0 May 26 14:57 foo.txt
-rw-r--r-- 1 10335 11111 0 May 26 14:57 qux.txt
-rw-r--r-- 1 10335 11111 0 May 26 15:30 test_bar.txt
-rw-r--r-- 1 10335 11111 0 May 26 15:30 test_foo.txt
-rw-r--r-- 1 10335 11111 0 May 26 15:27 test_qux.txt
bar.txt foo.txt qux.txt test_bar.txt test_foo.txt test_qux.txt
bar.txt foo.txt qux.txt
References:
https://www.gnu.org/software/make/manual/make.html#Text-Functions
https://www.gnu.org/software/make/manual/make.html#Wildcard-Function
https://www.gnu.org/software/make/manual/make.html#Conditional-Syntax

Compilation fails: No such file or directory (but it DOES exist!)

I'm trying to compile the Ethereum Go client. Following the instructions I simply run make geth, but that fails:
$ make geth
build/env.sh go run build/ci.go install ./cmd/geth
make: build/env.sh: No such file or directory
make: *** [geth] Error 1
As far as I understand from this error it complaints that either build/env.sh or build/ci.go doesn't exist. So I checked out the build folder, but they both seem to be there:
$ ls -l build
total 648
drwxr-xr-x 3 kramer65 staff 102 Feb 13 13:45 _vendor
-rw-r--r-- 1 kramer65 staff 2892 Feb 13 13:45 ci-notes.md
-rw-r--r-- 1 kramer65 staff 30516 Feb 13 13:45 ci.go <===
-rw-r--r-- 1 kramer65 staff 123 Feb 13 13:45 deb.changelog
... some other files here
-rw-r--r-- 1 kramer65 staff 379 Feb 13 13:45 deb.rules
-rwxr-xr-x 1 kramer65 staff 721 Feb 13 13:45 env.sh <===
-rw-r--r-- 1 kramer65 staff 1722 Feb 13 13:45 mvn.pom
... and some more files here
I checked whether go is installed and which version it is:
$ which go
/usr/local/bin/go
$ go version
go version go1.7.5 darwin/amd64
So go seems to be fine.
Does anybody have any idea how I can debug/solve this? All tips are welcome!
Ok, nevermind. Found it. The problem was that line endings where in dos style.
So to recursively convert line endings to unix I ran:
find . -type f -print0 | xargs -0 -n 1 -P 4 dos2unix
and then tried building again. That fixed it.
I hope this helps someone else here. In any case I wish you all a beautiful day!
I solve the problem using by following instructions below. I don't know the reason, but I completely get rid of brew to make it run. (mac)
1 install go(I used package)
2 git clone https://github.com/ethereum/go-ethereum
3 cd go-ethereum && git checkout tags/v1.8.2
4 run `find . -type f -print0 | xargs -0 -n 1 -P 4 dos2unix`(if you don't have dos2unix, you could brew one, it does not break anything.)
5 make geth
6 ln -s /path/to/origin/geth /path/to/target/geth
Then run which geth you could find your geth. Run geth version you can see your version.

Bash/Shell scripting

What does the command cp $1/. $2 do? I know cp is used for copying from source(stored in variable $1) to destination(stored in variable $2). I am just confused with the /. used along with the variable. Can someone please help me understand this?
The command:
$ cp -R $1/. $2
copies contents of directory pointed by $1 to the directory $2.
Without -R switch this command would fail both when $1 is a file or directory.
In general, . points to the current directory. You can see that by comparing inode's shown by ls:
$ mkdir test
$ ls -ali
9525121 drwxr-xr-x 3 IU wheel 102 23 mar 12:31 .
771046 drwxrwxrwt 21 root wheel 714 23 mar 12:30 ..
9525312 drwxr-xr-x 2 IU wheel 68 23 mar 12:31 test
$ cd test
$ ls -ali
9525312 drwxr-xr-x 2 IU wheel 68 23 mar 12:31 .
9525121 drwxr-xr-x 3 IU wheel 102 23 mar 12:31 ..
Note that inode 9525312 points to test when viewed from the parent directory, and points to . when viewed from inside the test directory.

Resources