2009-08-25 86 views
3

如果我在我的Makefile中添加註釋(# ...),make會給我一個錯誤並退出。如果我刪除評論,makefile工作正常。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 [email protected]:$(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 
+1

發佈的makefile – 2009-08-25 08:33:06

+0

我使用相同版本製作的嘗試這樣做。在任何地方添加註釋都可以正常工作,所以很明顯你做錯了什麼 – jrockway 2009-08-25 08:35:44

+0

我已經發布了makefile。 – Fu86 2009-08-25 08:40:55

回答

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 
+0

'cat -vet' - 不想要! – rishta 2012-12-29 22:15:03

1

您可能使用空格代替製表符的評論。 請發佈makefile,以便我們不必猜測。

+0

如果這是問題(很可能),張貼在SO(或一般的互聯網)不會有太大的幫助。誰使用互聯網上的標籤? – 2009-08-25 08:38:06

+0

不,註釋中沒有標籤。 – Fu86 2009-08-25 08:42:58

+0

我錯過了。標籤應該在你的規則中。我以爲你會在你的規則中留下評論,而在他們面前有空格而不是標籤。這似乎並非如此(規則中沒有任何評論)。 – 2009-08-25 08:48:57