2014-12-22 54 views
1

我需要在我的生成文件中設置幾個標誌,這些標誌只需要特定的窗口即我不希望它們在其他操作系統上「看到」。我正在使用MinGW來構建我的項目。這些是我想要只爲窗口設置的標誌:在生成文件中添加特定於平臺的標誌

AM_LDFLAGS += -lws2_32 
AM_LDFLAGS += -Xlinker --allow-multiple-definition 

這是我在做makefile.am:

SYS := $(shell gcc -dumpmachine) 
ifneq (, $(findstring mingw, $(SYS))) 
    AM_LDFLAGS += -lws2_32 
    AM_LDFLAGS += -Xlinker --allow-multiple-definition 
endif 

當我做autoreconf -isf,它失敗,以下消息:

Makefile.am:34: endif without if 
Makefile.am:30: `:='-style assignments are not portable 
Makefile.am:30: shell gcc -dumpmachine: non-POSIX variable name 
Makefile.am:30: (probably a GNU make extension) 
Makefile.am:31: findstring mingw, $(SYS: non-POSIX variable name 
Makefile.am:31: (probably a GNU make extension) 
aminclude.mk:162: .PHONY was already defined in condition TRUE, which includes condition DX_COND_doc ... 
Makefile.am:80: `aminclude.mk' included from here 
core/Makefile.mk:169: ... `.PHONY' previously defined here 
Makefile.am:56: `core/Makefile.mk' included from here 
Makefile.am:271: <D: non-POSIX variable name 
Makefile.am:230: user variable `distdir' defined here... 
/mingw/share/automake-1.11/am/distdir.am: ... overrides Automake variable `distdir' defined here 
autoreconf-2.68: automake failed with exit status: 1 

有關如何處理此問題的任何建議?

回答

2

您應檢查添加到你的configure.ac,這樣的事情:

AC_CANONICAL_HOST 
case $host_os in 
    *mingw*) mingw=true ;; 
    *) mingw=false ;; 
esac 
AM_CONDITIONAL([MINGW], [test x$mingw = xtrue]) 

然後在Makefile.am,你可以做

if MINGW 
AM_LDFLAGS += -lws2_32 
AM_LDFLAGS += -Xlinker --allow-multiple-definition 
endif 

確保你不縮進Makefile.am中if條件的主體!

+0

最好使用預定義的'$ host_os'將處理交叉編譯的情況 – vitalyster

+0

@vitalyster我configure.ac嘗試這樣做:在 窗口*) AM_LDFLAGS + = -lws2_32 AM_LDFLAGS 'AC_CANONICAL_HOST 情況下$ host_os + = -Xlinker --allow-multiple-definition ;; *) AM_LDFLAGS + = AM_LDFLAGS + = ;; esac'但沒有工作。我會嘗試@ptomato的建議,看看它是否有效。 –

+0

@ptomato我嘗試了你的建議,使乾淨;使strtok相關的錯誤失敗。 所以我編輯了makefile.am作爲'if!MINGW .....',這沒有任何意義。我在這裏錯過了什麼嗎? –

相關問題