shiblon / latex-makefile

A Makefile for LaTeX - drop it in, type make, and magic happens.
Other
185 stars 30 forks source link

Fix for "make clean" error for file-names with "(" and/or ")" #179

Closed shiblon closed 8 years ago

shiblon commented 8 years ago

Originally reported on Google Code with ID 166

To fix the "make clean", I applied the following little patch (basically wrapping $1
with quotes in 'remove-files-helper') on version 2.2.0:

===================================================================
@@ -859,7 +859,7 @@

 # Don't call this directly - it is here to avoid calling wildcard more than
 # once in remove-files.
-remove-files-helper    = $(if $1,$(RM) $1,$(sh_true))
+remove-files-helper    = $(if "$1",$(RM) "$1",$(sh_true))

 # $(call remove-files,file1 file2)
 remove-files       = $(call remove-files-helper,$(wildcard $1))
===================================================================

Reported by gsbabil on 2012-11-07 01:59:29

shiblon commented 8 years ago
I'm a bit skeptical of this. Does it actually work for multiple files? In particular,
I'm really pretty sure that

rm "file1 file1"

will not do what we want - it will try to find a single file named "file1 file2", so
this fix is broken.

Note that $(wildcard $1) returns a space-separated list of files.

I think it's actually fine to simply not support files with ( and ) in their names.

Reported by shiblon on 2012-11-07 09:33:59

shiblon commented 8 years ago
You are right. I was too hasty. It doesn't not work for the cases you 
pointed out. Also, it appears that GNU make has some serious troubles 
handling file-names with spaces AND these special characters.

Reported by gsbabil on 2012-11-07 12:51:55

shiblon commented 8 years ago
I just added the following to support deleting user-defined files. The variable 'clean_userdefined'
can be specified in 'Makefile.ini' or 'Variables.ini' to perform cleaning of user-defined
files.

===================================================================
 .PHONY: clean-nographics
 clean-nographics: clean-tex clean-deps clean-backups clean-auxiliary ;

+.PHONY: clean-userdefined
+clean-userdefined:
+   $(QUIET)$(call clean-files,$(clean_userdefined))
+
 .PHONY: clean
-clean: clean-generated clean-tex clean-graphics clean-deps clean-backups clean-auxiliary
;
+clean: clean-generated clean-tex clean-graphics clean-deps clean-backups clean-auxiliary
clean-userdefined;

 #
 # HELP TARGETS
===================================================================

Reported by gsbabil on 2012-11-07 13:17:30

shiblon commented 8 years ago
I'm accepting this patch, but calling it "CLEAN_EXTRA". I'll ping this bug when it's
submitted.

Reported by shiblon on 2012-11-23 15:02:39

shiblon commented 8 years ago
Actually, I'm going to just call it cleanextra (the variable, not the target - the target
will be clean-extra).

Reported by shiblon on 2012-11-23 15:04:59

shiblon commented 8 years ago
rd13ff27c27be has the fix.

Reported by shiblon on 2012-11-23 15:08:04