I have the following bits in my makefile:
GLFW_FLAG := -m32 -O2 -Iglfw/include -Iglfw/lib -Iglfw/lib/cocoa $(CFLAGS)
...
$(BUILD_DIR)/%.o : %.c
$(CC) -c $(GLFW_FLAG) $< -o $@
$(BUILD_DIR)/%.o : %.m
$(CC) -c $(GLFW_FLAG) $< -o $@
The -m32 instructs GCC to generate 32bit code. It’s there because on some configurations GHC is set to build 32bit code but GCC’s default is sometimes 64bit. I would like to generalize this so that it autodetects whether GHC is building 32bit or 64bit code and then passes the correct flag to GCC.
Question: How can I ask GHC what type of code (32bit vs. 64bit) it will build?
PS: My cabal file calls this makefile during the build to workaround limitations in cabal. I do wish I could just list these as c-sources in my cabal file.
Thanks to Ed’ka I know the correct answer now.
The Makefile now has a rule like this:
It’s a bit long, but all it does is extract the “Gcc Linker flags” from ghc’s output. Note: This is the output of
ghc --infoand notghc +RTS --info.This is better than the other suggested ways as it gives me all the flags that need to be specified and not just the -m flag. It’s also empty when no flags are needed.
Thank you everyone!