Makefile无法理解评论 [英] Makefile can't understand comments

查看:70
本文介绍了Makefile无法理解评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在Makefile中添加注释(# ...),则make给我一个错误,然后退出.如果删除注释,makefile会正常工作.

If I put comments (# ...) in my Makefile, make gives me an error and quit. If I remove the comments, the makefile works fine.

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
    

    推荐答案

    您的Makefile对我有用(用制表符代替空格),因此听起来好像您遇到了一些杂乱的非打印字符.

    Your Makefile works for me (with spaces replaced by tabs), so it sounds like you have a case of stray non-printing chars.

    尝试检查"cat -vet Makefile"的输出.这将显示EOL,TAB和其他看不见的字符在哪里.

    Try inspecting the output of "cat -vet Makefile". That will show where EOL, TAB and other unseen chars are.

    您将希望看到以下内容:

    You'll want to see something like this:

    # 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"开头.

    Make sure all commands are preceeded by "^I".

    您还可以尝试使用类似以下内容的流浪字符:

    You could also try to looking for stray chars using something like:

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

    这篇关于Makefile无法理解评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆