I am very disappointed by the fact that this Makefile is outputting nonsense errors!
bin:
mkdir -p bin
gcc ./lsmodf/main.c ./lsmodf/oggetto.c ./lsmodf/lsmodfunctions.c -o ./bin/custom-
lsmod
clean:
rm -rf *o bin/custom-lsmod
rm -rf *o bin
test:
rm -rf *o bin/custom-lsmod
rm -rf *o bin
mkdir -p bin
gcc lsmodf/main.c lsmodf/oggetto.c lsmodf/lsmodfunctions.c -o bin/custom-lsmod
#echo "\n\n\033[5;1m----------------------------------------\033[0m"
#echo "\033[1;31m LSMOD senza opzioni \033[0m\n"
bin/custom-lsmod
#echo "\033[5;1m----------------------------------------\033[0m"
#echo "\033[1;31m LSMOD con ordinamento per id\033[0m\n"
bin/custom-lsmod sort=id
#rm -rf *o bin/custom-lsmod
#rm -rf *o bin
Whenever I execute make test it compiles everything, runs bin/custom-lsmod and then throws:
make: *** [test] Error 90
and it stops. I mean: it doesn't execute the instructions under that line.
Try adding a hyphen at the beginning of the command:
-bin/custom-lsmod
This tells Make to ignore the error.
I suppose you do not have the execution rigths.
Try adding chmod +x bin/custom-lsmod before bin/custom-lsmod.
Thread on Error 126
For all those ones who received this kind of error:
Looks like bin/custom-lsmod returned 90, so Make stopped there.
As Biffen said, it is an error returned by the executable. The compiler didn't return anything, but I forgot to put return 0 at the end of my code, and it seems to be that the cause of problem.
Hope this could help people who encountered this problem.
Related
I have a Makefile that looks like this:
RENDER_HTML=jupyter nbconvert --execute --to html
MATE40001_TARGETS=$(wildcard MATE40001/notes/*.ipynb)
.phony: all
all: MATE40001
.phony: variables
variables:
#echo MATE40001_TARGETS:
#echo ${MATE40001_TARGETS} | sed 's/ /\n/' | sed 's/MATE/\tMATE/'
.phony: MATE40001
MATE40001: ${MATE40001_TARGETS}
mkdir -p $#/html/
${RENDER_HTML} $^
mv $#/notes/*.html $#/html/
.phony: clean
clean:
rm -rf */html/ *~ */notes/*.html
When I run:
make
make clean
make
make MATE40001
I get the following output:
...
<normal output>
...
rm -rf */html/ *~ */notes/*.html
make: Nothing to be done for 'all'.
make: 'MATE40001' is up to date.
As far as I understand, make is looking for the file MATE40001 which exists as a folder and then stops because there are no updated files. However I do not want this to happen, and I thought that adding .phony: MATE40001 would stop this problem.
What do I need to add/change to fix this issue?
from comment by #G.M.
Use .PHONY instead of .phony
so I made a makefile for a c program. For some reason my 'clean' is not working. Here's a little bit of my makefile:
CC=gcc
FLAGS=-c -Wall -I.
CLEANC=rm -rf *.o
move.o: move.c
$(CC) $(FLAGS) move.c
/*Lot more codes like this^^^*/
clean:
$(CLEANC)
When I run 'make clean' in command prompt, I'm shown the following:
rm -rf *.o
process_begin: CreateProcess(NULL, rm -rf *.o, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:116: recipe for target 'clean' failed
make: *** [clean] Error 2
I can't figure out what I'm doing wrong. I've tried changing CLEANC to
rm -f *.o
rm *.o
rm *o
rm -f *.o test.exe //test.exe is executable
but it still gave me the same error no matter what I tried. I could really use the help. Thanks in advance.
Judging from the CreateProcess appearing in your error output I assume you are running make under Windows.
This means that there is no rm command, you should use del instead and -rf flags should also be adjusted accordingly.
OBJS = $(addprefix $(OBJ_DIR)/,$(patsubst %.c,%.o,$(notdir $(SRCS))))
DELOBJS = $(addprefix .\obj\,$(patsubst %.c,%.o,$(notdir $(SRCS))))
.PHONY: clean
clean:
del xxx
del $(DELOBJS)
del does not work because Windows uses \ to distinguish file paths,so you have to take OBJS with \path, that is, DELOBJS I wrote
I have this Makefile:
default:
mv presentacion.pdf /tmp
pdflatex presentacion.tex
clean:
rm -f *.{aux,log,nav,out,snm,toc}
The order make works well but when I try to do a make clean the shell outputs:
rm -f *.{aux,log,nav,out,snm,toc}
And does not remove the files. What's wrong in the code?
Try to set the shell to bash in your makefile (according docs)
SHELL=/bin/bash
default:
mv presentacion.pdf /tmp
pdflatex presentacion.tex
clean:
rm -f *.{aux,log,nav,out,snm,toc}
You can let make add the prefix to your files (instead of bash), by using addprefix:
PREFIXES := aux log nav out snm toc
FILES := $(addprefix *., $(PREFIXES))
default:
mv presentacion.pdf /tmp
pdflatex presentacion.tex
clean:
rm -f $(FILES)
I use a lot of rm -rf in my makefiles for cleanup. A couple weeks ago I found $(RM) which seems more general, but it expands to rm -f on my machine. How can I get recursive deletion with the general form?
$(RM) -rf is what I usually see (even though the -f is redundant).
You can also create a common Makefile to define your own RM = rm -rf and then include it from the Makefiles in your project.
Just define it yourself:
RM := rm -rF
In a Makefile, I read:
-rm -rf (instead of rm -rf). What does the first "-" mean at the beginning of the line in a Makefile ?
It means that make itself will ignore any error code from rm.
In a makefile, if any command fails then the make process itself discontinues processing. By prefixing your commands with -, you notify make that it should continue processing rules no matter the outcome of the command.
For example, the makefile rule:
clean:
rm *.o
rm *.a
will not remove the *.a files if rm *.o returns an error (if, for example, there aren't any *.o files to delete). Using:
clean:
-rm *.o
-rm *.a
will fix that particular problem.
Aside: Although it's probably not needed in your specific case (since the -f flag appears to prevent rm from returning an error when the file does not exist), it's still good practice to mark the line explicitly in the makefile - rm may return other errors under certain circumstances and it makes your intent clear.