Reprinted from http://www.crifan.com/make_makefile_recipe_for_target_failed_omit_error_while_executing_makefile/
Problem
In Cygwin, the makefile is executed, where the call HHC generates a CHM file from the hhp file.
The result is an error in the last step:
ADMINISTRATOR@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC
$ make chm
...
Created e:\Dev_Root\docbook\dev\books\VBR\output\htmlhelp\MPEG_VBR.chm, 181,978 bytes
Compression decreased File by 70,718 bytes.
Makefile:131:recipe for Target '.. /output/htmlhelp/mpeg_vbr.chm ' failed make
: * * * * [...] /output/htmlhelp/mpeg_vbr.chm] Error 1
But strangely enough, the corresponding file Mpeg_vbr.chm was successfully generated, but there was an error here.
The corresponding makefile source code is:
$ (Output_file_chm): $ (output_file_htmlhelp) $ (output_dir_chm)/htmlhelp.hhp $ (output_dir_chm)/TOC.HHC iconv-f
UTF-8-T GB18030 < $ (output_dir_chm)/htmlhelp.hhp > $ (output_dir_chm)/HTMLHELP_GB18030.HHP
MV $ (output_dir_ CHM)/htmlhelp_gb18030.hhp $ (output_dir_chm)/htmlhelp.hhp
iconv-f UTF-8-T GB18030 < $ (output_dir_chm)/TOC.HHC > $ (output_dir_chm)/TOC_GB18030.HHC
mv $ (output_dir_chm)/TOC_GB18030.HHC $ (output_dir_chm)/TOC.HHC
echo "---before HHC"
HHC $ (output_dir_chm)/htmlhelp.hhp
echo "+++after HHC"
Chm:clean_chm $ (output_file_ CHM)
"Resolution Process"
1. It is the same error to think that the less than the iconv in the above cause an error, and the result is less than the number.
2. Then add the above echo command, the result is HHC the following sentence: +++after HHC, is not shown, confirmed that the HHC command itself to perform the result is wrong, so HHC execution error, return to makefile, and then makefile reported above recipe Error for Target failed.
3. It is strange, however, that the above HHC command, which is executed alone to the Cygwin command, does not show anything wrong. It is estimated that the return value is wrong and no one catches it, so you don't know the error.
4. Then you want to find a way to get the result of the last command line execution from makefile, but you never get it because you can't execute the following sentence of HHC.
5. Then think of itself, although the HHC command error, but the purpose has been achieved, has been able to generate a CHM, so, here want to find a way to makefile in the implementation process, ignore this error can be.
And then you find a lot of information, like here:
A global approach is to add "-I" or "–ignore-errors" arguments to make, so all commands in makefile ignore the error. And if a rule is to ". IGNORE "as the target, then all the commands in this rule will ignore the error. These are different levels of ways to prevent command errors, and you can set them according to your different preferences.
There is also a "K" or "–keep-going" parameter to mention make, which means that if the command in a rule fails, then the rule is executed, but the other rules continue to execute.
The result is that how to ignore the whole error, so does not meet the requirements here.
And then finally found: The makefile of the variables, which spoke of:
Two special characters in the makefile can be added before the command to execute: - make ignores the error of the command. If you want to produce a record but want to ignore the error, it may be because the catalogue already exists.
-mkdir/usr/local/repository
If you want to clear the target file, but want to ignore the bug, it may be because the file does not exist.
Clean:
-rm main.o 2.o 3.o
@: Make does not display the command to be executed on the standard output. The determinant if starting with the symbol @ allows make to stop printing the standard output when the law is executed.
Install:myapp
@if [D $ (instdir)]; \
then \
...; \
fi
That is, the corresponding command preceded by a minus sign '-', you can ignore the command error, the subsequent command can continue to execute.
So, finally, use:
-HHC $ (output_dir_chm)/htmlhelp.hhp
will be able to achieve the desired effect. In this way, the makefile execution process is not interrupted by a HHC error.
Although the problem is fixed here, the root cause of the specific error is unclear, so try to figure out why it is wrong.
Then, about the return value of things, and finally with:
echo "---Before HHC" # Here's "-" to
ignore the HHC error
-HHC $ (output_dir_chm)/htmlhelp.hhp
echo $?
echo "+++after HHC"
The results of the test are:
Makefile:131:recipe for Target '.. /output/htmlhelp/mpeg_vbr.chm ' failed make
: [... /output/htmlhelp/mpeg_vbr.chm] Error 1 (ignored)
echo. /output/htmlhelp/mpeg_vbr.html.. /output/htmlhelp/htmlhelp.hhp.. /OUTPUT/HTMLHELP/TOC.HHC
.. /output/htmlhelp/mpeg_vbr.html.. /output/htmlhelp/htmlhelp.hhp.. /OUTPUT/HTMLHELP/TOC.HHC
echo "+++after HHC"
+++after HHC
Looks like HHC. The returned value is:
.. /output/htmlhelp/mpeg_vbr.html.. /output/htmlhelp/htmlhelp.hhp.. /OUTPUT/HTMLHELP/TOC.HHC.. /output/htmlhelp/mpeg_vbr.html.. /output/htmlhelp/htmlhelp.hhp.. /output/htmlhelp/toc.hhc
The results later went through the following toss:
ADMINISTRATOR@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC $ Iconv1retcode= ' iconv-f UTF-8-T GB18030 <. /OUTPUT/HTMLHELP/HTMLHELP.HHP > ... /OUTPUT/HTMLHELP/HTMLHELP_GB18030.HHP ' ADMINISTRATOR@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC $ echo $ Iconv1retcode administrator@k470/cygdrive/e/dev_root/docbook/dev/books/vbr/src $ Mv1Retcode= ' mv. /output/htmlhelp/htmlhelp_gb18030.hhp..
/OUTPUT/HTMLHELP/HTMLHELP.HHP ' Administrator@k470/cygdrive/e/dev_root/docbook/dev/books/vbr/src $ echo $mv 1Retcode
ADMINISTRATOR@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC $ echo $? 0 ADMINISTRATOR@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC $ iconv-f UTF-8-T GB18030 <. /OUTPUT/HTMLHELP/TOC.HHC > ...
/OUTPUT/HTMLHELP/TOC_GB18030.HHC ADMINISTRATOR@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC $ echo $? 0 ADMINISTRATOR@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC $ mv. /OUTPUT/HTMLHELP/TOC_GB18030.HHC.. /OUTPUT/HTMLHELP/TOC.HHC administrator@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC $ echo $? 0 ADMINISTRATOR@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC $ HHC. /OUTPUT/HTMLHELP/HTMLHELP.HHP Microsoft HTML help Compiler 4.74.8702 compiling e:\Dev_Root\docbook\dev\books\VBR\
Output\htmlhelp\mpeg_vbr.chm index.html ... Created e:\Dev_Root\docbook\dev\books\VBR\output\htmlhelp\MPEG_VBR.chm, 181,978 bytes Compression decreased file by
70,718 bytes.
ADMINISTRATOR@K470/CYGDRIVE/E/DEV_ROOT/DOCBOOK/DEV/BOOKS/VBR/SRC $ echo $? 1
Confirmed that the original Linux under the commands, such as ICONV,MV, the implementation of the results, if there is no error, will return 0, indicating normal, and here HHC is the tool below Windows, its return 1 means that the implementation of normal results, resulting in the Makefile received 1, Thought is the program execution is wrong, therefore the error:
Makefile:131:recipe for Target '.. /output/htmlhelp/mpeg_vbr.chm ' failed
and said it was error 1:
Make: [.. /output/htmlhelp/mpeg_vbr.chm] Error 1 (ignored)
Summary
The phenomenon here is the error of the outgoing recipe for target xxx failed during makefile execution, causing the execution to break.
The direct reason is that the HHC command execution result is incorrect.
And the fundamental reason is that HHC's command, which belongs to Microsoft's (Windows) tool, is called by Cygwin, and then returns a value of 1, indicating that the result is correct, but the result is that the makefile of Linux is mistaken.
Because the general program under Linux is the return value of 0 indicates that the program execution is normal.
Therefore, the tools used are different platforms, resulting in incomplete compatibility.
The workaround here is to precede the corresponding HHC command with a minus sign, which means that makefile executes the command, even if the command fails, you can ignore the command's error and continue to execute the remaining commands so that the makefile continues to perform normally.
So, if other people encounter similar problems:
One is to be careful not to use the tools of different platforms to cause incompatibility problems
Second, you can add a minus sign to the related command in makefile to (intentionally) ignore some of the commands (possible) errors so that makefile can continue to run even if there are (not serious) errors.