# Using a make rule to call another

I am writing a LaTeX project that I am using a makefile for. I have a clean function to clean the excess LaTeX files:

.PHONY: clean
clean:
\rm *.aux *.blg *.out *.bbl *.log


But in some cases I need to get rid of the generated files as well as the PDF file. I have attempted this using:

.PHONY: clean_all
clean_all:
$(clean) \rm *.pdf  This does not work as it only removes the PDF file. My question is how do I invoke the clean rule inside the clean_all rule? ## 1 Answer Make the clean_all target depending on clean target: .PHONY: clean_all clean clean: rm -f *.aux *.blg *.out *.bbl *.log clean_all: clean rm -f *.pdf  I added the -f to rm so that non-existing files do not generate an error in the rules (e.g. when you would run the command twice). (BTW, I never heard of these rules being talked about as functions, you might want to recheck your terminology and have more success while Googling things about makefiles). • I called rules functions as I am new to makefiles and I am used to using the word. I have changed the title to accommodate your note. Although this corrects my problem, the PDF file is a dependency of the rule that produces it so it is not removed anyway. – user133987 Apr 12 '14 at 11:56 • @user133987 No problem about the functions/rules, just wanted to make sure you pick up the more common terminology. I updated the answer, because it still had $(clean) in it and the  (why where those there?). Invoking make clean_all should both remove the .pdf and the others. – Anthon Apr 12 '14 at 12:46
• Unfortunately, this still does not remove the PDF file. I used the \$(clean) as I thought that It might be like scripting, where I you call a function (but I see now that you put it as a dependency). Would it help if I added in the entire source of my makefile? – user133987 Apr 12 '14 at 13:13
• @user133987 The full Makefile can help, but more important is if there are any error messages. If e.g. there are no .blg file you will get a "No such file or directory". You can prevent that with the -f option to rm – Anthon Apr 12 '14 at 14:09
• Yes, adding the -f option did remove the error messages and hence allowed the removal of the PDF file. Thank you. – user133987 Apr 12 '14 at 14:13