Hiya,
New here so sorry if I'm not following protocol. I had some issues compiling GLEW on my Mac and made a few small changes to the makefiles that may benefit others and may be good to add to the source. For reference, I'm using Mac OS X 10.10.2 and have XCode 6 installed but using the command line for compiling. I'm ignoring the warnings for all the deprecated stuff, that's a challenge for another day and they still work.
Also there are separate files for PPC, i386 and x86_64 libraries. I'm purely editing the Makefile.darwin file to make things work for me but I am compiling a universal binary for i386 and x86_64 but don't care about PPC. Bit easier.
I've added the following lines at the end for this:
CFLAGS.EXTRA += -arch i386 -arch x86_64
LDFLAGS.EXTRA += -arch i386 -arch x86_64
AR doesn't seem to be supported for creating static libraries, Apple seems to prefer you use LIBTOOL. Also STRIP doesn't seem to be supported so I've also added:
AR = LIBTOOL
STRIP =
Finally, while LDFLAGS.STATIC is defined it isn't used, I've added:
LDFLAGS.STATIC += -static -o
And then edited the main makefile and replace "$(AR) cr" with "$(AR) $(LDFLAGS.STATIC)"
Obviously that means the other makefiles need to be edited to have cr as the static linker flags (or have this defined at the beginning of the file).
After this all compiles fine.
Sorry got the priority wrong, somehow the stuff I changed in the headings got reset. Also realized I may have switched from AR to LIBTOOL because AR didn't do universal binaries. Was awhile since I last did this for 1.11..
Hi Bastiaan, I guess your main aim for this is to produce universal binaries in one shot. And I'm still on OS X 10.9, so might not be able to match your setup for the moment. (As a side note, I did resolve some of the deprecation warnings recently, but github might be more upto date than sourceforge) I think my preference would be to add a config/Makefile.darwin-universal which can be opted into via 'make SYSTEM=darwin-univeral'. My experience with building universal binaries is that generally I want to "lipo" the binaries at the end, rather than building multi arch and not being able to vary the compiler and linker flags along the way. I recognize that Apple opinion might not agree with that, but I think single arch is preferable by default. What do you think?
Hi Nigel,
Indeed the goal is to create a universal binary as most of my other source code is compiled as universal as well. I'm one of those crazies that doesn't mind the larger file size so I don't have to worry about running my code on different hardware.
I think having a darwin-universal makefile as an addition probably is a good idea as it gives people a choice.
Yeah, it turns out that another recent bug report concerns universal mac binaries too. https://sourceforge.net/p/glew/bugs/259/ If you could put a merge request over on github, I'd be happy to seriously consider it. https://github.com/nigels-com/glew
My old Mac has not ben replaced yet. I don't expect anything futher for this for the upcoming GLEW 2.0.0..
So far its been working just fine for me in 1.13 :)
This is what we do in MacPorts: https://trac.macports.org/browser/trunk/dports/graphics/glew/files/config_Makefile.darwin.patch
And then we pass in our desired arch flags as arguments to make, whether it's a single arch or multiple.
Also, as I mentioned in bug #259, you can create universal archives with ar as long as you use the s option (i.e. crs rather than cr). (And BTW, libtool is a completely different thing to ld, so calling its flags LDFLAGS.whatever doesn't really make sense.)
Fixed. Closing.