Makefile error (e=2): The system cannot find the file specified - makefile

I'm completely new to Makefile (and to Docker), and I'm struggling with understanding how to point to a subdirectory.
This is the file structure:
project
[...docker
[ [...Dockerfile
[
[...client
[ [...docker
[ [...Dockerfile
[...api
(Sorry, can't find the pipe on my keyboard)
The Makefile includes two builds.
# Makefile
build_api:
# docker compose build
build_client:
# client/docker compose build
up: build_api build_client
# docker compose up -d
The api image gets created and launched, but the client image fails with this error:
make (e=2): The system cannot find the file specified.
make: *** [Makefile:5: build_client] Error 2
How can I point to a subdirectory inside the Makefile?

The format of your Makefile as of now is set up to try to run the folder client/docker as a command.
Instead, try # cd client ; docker compose build
This should then enter the client folder and then run the docker command there.

Related

How does make command doesnot search for Makefile in the same directory first?

I am using the command make for compiling source codes. However, the command always issue this error
Makefile:10: Makefile_compiler_HOSTNAME: No such file or directory
make: *** No rule to make target `Makefile_compiler_HOSTNAME'. Stop.
where HOSTNAME is the hostname of my computer. It seems like make is defaulted to search for the file Makefile_compiler_HOSTNAME before the file Makefile.
Is there any way to set the default behaviour of make back?

Make always build even when there is no file change

I'm writing a simple Makefile:
all: image
image: ./common ./source
docker build -t some-resource -f source/Dockerfile .
.PHONY: all image
I expect that image is only built when files under folders common or source have changes. But when I run make, it always run docker run even without any file change. What's the problem?
When you run make, it will try to make the first target, which is all. This causes make to make the target image. Because there is no actual file named image (you even told make that it is a phony target), it will always execute the docker command.
In this case, it is not possible for make to determine that "common and source have changes". Normally make does this by comparing the modification timestamps of the target and the dependencies but there is no actual target to check (image is not a file).

qmake generated target_wrapper.sh fails on make check

I have a qmake project with a subdirs template and two child projects.
The subdir projects are two testcases. The project is built with on mingw64.
When I run "mingw32-make check", the process fails when the first testcase is called by the target_wrapper.sh:
cd && /C/JENKINS/workspace/MyProject/tests/test1/target_wrapper.sh release/test1.exe
/C/JENKINS/workspace/MyProject/tests/test1/target_wrapper.sh: Zeile 6: /home/jenluelokal/release/test1.exe: No such file or directory
mingw32-make[2]: *** [Makefile.Release:82: check] Error 127
The Makefile.Release calls the following line for the check target:
check: first
cd && /C/JENKINS/workspace/MyProject/tests/test1/target_wrapper.sh $(TESTRUNNER) release/$(TARGET) $(TESTARGS)
By request the target_wrapper.sh:
#!/bin/sh
PATH=/C/Qt/Qt5.9.2/5.9/mingw64/bin:$PATH
export PATH
QT_PLUGIN_PATH=/C/Qt/Qt5.9.2/5.9/mingw64/share/qt5/plugins${QT_PLUGIN_PATH:+:$QT_PLUGIN_PATH}
export QT_PLUGIN_PATH
exec "$#"
The first cd changes into the homedir of the current user and calls target_wrapper.sh. The target_wrapper.sh script tries to execute the
test1 binary - which is not inside the home directory.
What am I doing wrong?
DESTDIR needs be set, so the make check target knows where to look for the test executables. The "cd" changes into this directory before trying to run the target_wrapper.sh.

How to customize the docker gcc command and add own path instead of /usr/src

I'm trying to compile a C file named test.c using docker's gcc container.
I'm using the following command, I have put the test.c in my homein ubuntu.
sudo docker run -v /home/moomal/workspace/FypProject/WebContent/file/:/myapp.c:ro gcc:4.9 sh -c "gcc -o myapp /home/moomal/workspace/FypProject/WebContent/file/myapp.c; ./myapp"
It works cool, but, I want to change the folder from home to a folder inside my eclipse web project folder. I have an editor on a web page and then on compile it creates a test.c file inside a folder. I want to access that file.
I tried adding the path like /home/moomal/workspace/FypProject/WebContent/file but I get the error
gcc: error: /home/moomal/workspace/FypProject/WebContent/file/myapp.c: No such file or directory
gcc: fatal error: no input files
compilation terminated.
sh: 1: ./myapp: not found
You seem to be confused about several things here.
The -v HOST_PATH:CON_PATH argument can be used to mount files inside a container, as you seem to be attempting. The HOST_PATH can be a file or a directory. The CON_PATH determines where that file or directory will be in the container. In your case, I think you want:
-v /home/moomal/workspace/FypProject/WebContent/file/myapp.c:/myapp.c
Not just ...file/:/myapp.c. I'm not sure what you expected your version to do (how can a directory be mapped to a file?).
Also, in the shell command you give the path on the host, but as this is processed in the container, you need the path in the container i.e:
gcc -o myapp /myapp.c
Putting it together, I would expect to see something like:
sudo docker run -v /home/moomal/workspace/FypProject/WebContent/file/myapp.c:/myapp.c:ro gcc:4.9 sh -c "gcc -o myapp /myapp.c; ./myapp"

Build gcc on linux script

Good day, i write script for building gcc on linux, my code is:
#!/bin/bash
export INSTALLATION_GCC=/opt
cd $INSTALLATION_GCC
tar xjvf gcc-4.7.0.tar.bz2
export srcdir="$INSTALLATION_GCC/gcc-4.7.0"
export objdir="$INSTALLATION_GCC/gcc-bin"
export insdir="$INSTALLATION_GCC/usr/local"
mkdir -p $srcdir
mkdir -p $objdir
mkdir -p $insdir
cd $objdir
$srcdir/configure --prefix=$insdir
make bootstrap
make install
but when i run this script i get errors:
No such file or directoryopt
tar (child): gcc-4.7.0.tar.bz2\r: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
/configure: No such file or directory
'. Stop. No rule to make target `bootstrap
'. Stop. No rule to make target `install
Why cd not work successful, if i execute my script (if i input this command in interactive mode all ok)?After building and installing gcc why my version of gcc not changing, how can i replace old version gcc properly?
I think my comment about a backspace being part of the directory name is relevant:
"There is something strange here, the error message No such file or directoryopt is missing a space and a /. It looks to me like your code did not generate this error message, are you sure that $INSTALLATION_GCC is /opt with the leading /? It almost appears that the first character of $INSTALLATION_GCC is a backspace."
I also spied gcc-4.7.0.tar.bz2\r in one of the error messages. A \r would give these effects. The most common unwanted source of \r (carriage-return) is Windows. Are you using something like Notepad on Windows to edit your scripts? If Windows is involved, convert your script using dos2unix.

Resources