Makefile无法理解评论

时间:2009-08-25 08:28:41

标签: linux makefile

如果我在我的Makefile中添加了评论(# ...),make会给我一个错误并退出。如果删除注释,makefile就可以正常工作。

Makefile:1: *** missing separator. Stop.
  • 制作版:3.81
  • Linux:Ubuntu 9.04

Makefile:

# Backup Makefile
#
# Create backups from various services and the system itself. This
# script is used to perform single backup tasks or a whole backup
# from the system. For more information about this file and how to
# use it, read the README file in the same directory.

BACKUP_ROOT = /srv/backup
ETC_PATH = /srv/config
SVN_PATH = /srv/svn/
TRAC_PATH = /srv/trac/sysinventory
PR10_PATH = /swsd/project/vmimages/...
PR10_MOUNT_PATH = /tmp/temp_sshfs_pr10

MYSQL_USER = "xxx"
MYSQL_PASSWORD = "xxx"


DATE = `date +%F`

help :
        cat README

init-environment :
        mkdir -p $(BACKUP_ROOT)
        mkdir $(BACKUP_ROOT)/tmp
        mkdir -p $(PR10_MOUNT_PATH)

backup : backup-mysql backup-configuration backup-svn backup-trac

upload-to-pr10 : mount-pr10
        tar cf $(DATE)-backup-blizzard.tar -C $(BACKUP_ROOT) *.-backup.tar.gz
        mv $(BACKUP_ROOT)/*-backup-blizzard.tar $(PR10_MOUNT_PATH)/
        umount $(PR10_MOUNT_PATH)

mount-pr10 :
        su xxx -d "sshfs -o allow_root xxx@xxx:$(PR10_PATH) $(PR10_MOUNT_PATH)"
        fusermount -u $(PR10_MOUNT_PATH)

backup-mysql :
        mysqldump --comments --user=$(MYSQL_USER) --password=$(MYSQL_PASSWORD) --all-databases --result-file=$(BACKUP_ROOT)/tmp/mysql_dump.sql
        tar czf $(BACKUP_ROOT)/$(DATE)-mysql-backup.tar.gz -C 
        $(BACKUP_ROOT)/tmp/mysql_dump.sql

backup-configuration :
        tar czf $(BACKUP_ROOT)/$(DATE)-configuration-backup.tar.gz $(ETC_PATH)/

backup-svn :
        svnadmin dump $(SVN_PATH)/repository > $(BACKUP_ROOT)/tmp/svn_repository.dump
        tar czf $(BACKUP_ROOT)/$(DATE)-subversion-backup.tar.gz -C $(BACKUP_ROOT)/tmp/svn_repository.dump

backup-trac :
        tar czf $(BACKUP_ROOT)/$(DATE)-trac-backup.tar.gz $(TRAC_PATH)/

clean :
        rm -f $(BACKUP_ROOT)/tmp/mysql_dump.sql
        rm -f $(BACKUP_ROOT)/tmp/svn_repository.dump
        rm -f $(BACKUP_ROOT)/*-backup.tar.gz
        rm -f $(BACKUP_ROOT)/*-backup-blizzard.tar

2 个答案:

答案 0 :(得分:9)

你的Makefile适合我(用标签替换空格),所以听起来你有一个流浪的非打印字符。

尝试检查“cat -vet Makefile”的输出。这将显示EOL,TAB和其他看不见的字符的位置。

你会想看到这样的东西:

# Backup Makefile$
#$
# Create backups from various services and the system itself. This$
# script is used to perform single backup tasks or a whole backup$
# from the system. For more information about this file and how to$
# use it, read the README file in the same directory.$
$
BACKUP_ROOT = /srv/backup$
ETC_PATH = /srv/config$
SVN_PATH = /srv/svn/$
TRAC_PATH = /srv/trac/sysinventory$
PR10_PATH = /swsd/project/vmimages/...$
PR10_MOUNT_PATH = /tmp/temp_sshfs_pr10$
$
MYSQL_USER = "xxx"$
MYSQL_PASSWORD = "xxx"$
$
$
DATE = `date +%F`$
$
help :$
^Icat README$
$
$
init-environment :$
^Imkdir -p $(BACKUP_ROOT)$
^Imkdir $(BACKUP_ROOT)/tmp$
^Imkdir -p $(PR10_MOUNT_PATH)$
$

确保所有命令都以“^I”开头。

您还可以尝试使用以下内容查找杂散字符:

cat -vet Makefile | grep "\^[^I]" --colour=auto

答案 1 :(得分:1)

您可能已使用空格而非制表符来评论。 请发布makefile,以便我们不必猜测。