D
D
DVoropaev2019-12-07 19:17:41
GNU Make
DVoropaev, 2019-12-07 19:17:41

How to create a directory in make?

The original makefile looked like this:

install:
  mkdir "/usr/local/bin/myprogram/"
  cp ./src/myprogram /usr/local/bin/myprogram/
  ...

Everything is fine, but if I edit the code and re-do make install, then it swears that the directory exists and stops.
sudo make install 
mkdir "/usr/local/bin/myprogram/"
mkdir: невозможно создать каталог «/usr/local/bin/myprogram/»: Файл существует
makefile:2: recipe for target 'install' failed
make: *** [install] Error 1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2019-12-07
@DVoropaev

Put a minus before mkdir (and before cp too).
make analyzes the return code of each executed command individually, if the command ends with a return code not equal to 0 (usually a sign of an error when the program is running), then make by default terminates the build process with an error. The minus sign causes make to ignore the return code.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question