Reputation: 561
I need to set a couple of flags in my makefile that needs are only windows specific i.e., I dont want them to be "seen" on other OS. I am using MinGW to build my project. These are the flags I want to set only for windows:
AM_LDFLAGS += -lws2_32
AM_LDFLAGS += -Xlinker --allow-multiple-definition
This is what I did in my makefile.am:
SYS := $(shell gcc -dumpmachine)
ifneq (, $(findstring mingw, $(SYS)))
AM_LDFLAGS += -lws2_32
AM_LDFLAGS += -Xlinker --allow-multiple-definition
endif
When I did autoreconf -isf
, it failed with following messages:
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
Any suggestions on how to handle this?
Upvotes: 2
Views: 1433
Reputation: 57890
You should add the check to your configure.ac, something like this:
AC_CANONICAL_HOST
case $host_os in
*mingw*) mingw=true ;;
*) mingw=false ;;
esac
AM_CONDITIONAL([MINGW], [test x$mingw = xtrue])
Then in Makefile.am, you can do
if MINGW
AM_LDFLAGS += -lws2_32
AM_LDFLAGS += -Xlinker --allow-multiple-definition
endif
Make sure you don't indent the body of the if condition in Makefile.am!
Upvotes: 2