Portable Makefile question

Hi,
I’m trying to create a Makefile which works on Mac OS X, Linux, and
Win32 (using MinGW).

The problem I am stuck on is dealing with the OpenGL libraries.

“sdl-config --libs” on Mac OS X includes them ("-framework OpenGL"),
but on Linux and Win32 it does not. For Linux and Win32 I need to add
"-lGL -lGLU" into the Makefile which of course breaks the Mac OS X
build.

Does anyone have experience creating cross platform Makefiles which
link with OpenGL?–
Paul Richards
pauldoo at users.sf.net

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Le jeudi 3 Juin 2004 03:31, Paul Richards a ?crit :

Hi,
I’m trying to create a Makefile which works on Mac OS X, Linux, and
Win32 (using MinGW).

The problem I am stuck on is dealing with the OpenGL libraries.

“sdl-config --libs” on Mac OS X includes them ("-framework OpenGL"),
but on Linux and Win32 it does not. For Linux and Win32 I need to add
"-lGL -lGLU" into the Makefile which of course breaks the Mac OS X
build.

Does anyone have experience creating cross platform Makefiles which
link with OpenGL?

And why not patching SDL itself ?

You then would be able to check that its version is greater than the one
containing this patch, so you would be sure that you can blindly believe
sdl-config --libs. In other cases, reject SDL sources.


Michel Nolard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAvvk0yAKwOMHoSb0RAlweAKDKfuJhA2hBOKYqktiUcO6oL0iN1wCgqxp3
L/0rDP5r3Kgc+O5SHajZeVc=
=92i4
-----END PGP SIGNATURE-----

I have been trying to do some cross platform GNU Makefiles.
The following is a part from a Makefile I did a while ago, it should detect
win32 (only with mingw), freebsd and linux:
(It doesn’t link OpenGL but it’s easy to add, also to link opengl to windows
you link it with -lopengl32 and for glu -lglu32)

win32 := false
freebsd := false
linux := false

autodetect_os := true

ifeq ($(strip $(autodetect_os)), true)
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “FreeBSD”)),)
freebsd = true
endif
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “Linux”)),)
linux = true
endif
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “mingw”)),)
win32 = true
endif
endif

ifeq ($(strip $(freebsd)), true)
SDL_CFLAGS = $(shell sdl11-config --cflags)
SDL_LDFLAGS = $(shell sdl11-config --libs)
EXTRA_CFLAGS = -DFREEBSD=1
endif

ifeq ($(strip $(linux)), true)
SDL_CFLAGS = $(shell sdl-config --cflags)
SDL_LDFLAGS = $(shell sdl-config --libs)
EXTRA_CFLAGS = -DLINUX=1
endif

ifeq ($(strip $(win32)), true)
SDL_CFLAGS = $(shell sdl-config --cflags)
SDL_LDFLAGS = $(shell sdl-config --libs)
EXTRA_LDFLAGS = -lwsock32
EXTRA_CFLAGS = -DWIN32=1
endifOn Thursday 03 June 2004 03:31, Paul Richards wrote:

Hi,
I’m trying to create a Makefile which works on Mac OS X, Linux, and
Win32 (using MinGW).

The problem I am stuck on is dealing with the OpenGL libraries.

“sdl-config --libs” on Mac OS X includes them ("-framework OpenGL"),
but on Linux and Win32 it does not. For Linux and Win32 I need to add
"-lGL -lGLU" into the Makefile which of course breaks the Mac OS X
build.

Does anyone have experience creating cross platform Makefiles which
link with OpenGL?

Hi,
I’m trying to create a Makefile which works on Mac OS X, Linux, and
Win32 (using MinGW).

The problem I am stuck on is dealing with the OpenGL libraries.

“sdl-config --libs” on Mac OS X includes them ("-framework OpenGL"),
but on Linux and Win32 it does not. For Linux and Win32 I need to add
"-lGL -lGLU" into the Makefile which of course breaks the Mac OS X
build.

Does anyone have experience creating cross platform Makefiles which
link with OpenGL?

I have been trying to do some cross platform GNU Makefiles.
The following is a part from a Makefile I did a while ago, it should
detect
win32 (only with mingw), freebsd and linux:
(It doesn’t link OpenGL but it’s easy to add, also to link opengl to
windows
you link it with -lopengl32 and for glu -lglu32)

win32 := false
freebsd := false
linux := false

autodetect_os := true

ifeq ($(strip $(autodetect_os)), true)
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “FreeBSD”)),)
freebsd = true
endif
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “Linux”)),)
linux = true
endif
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “mingw”)),)
win32 = true
endif
endif

ifeq ($(strip $(freebsd)), true)
SDL_CFLAGS = $(shell sdl11-config --cflags)
SDL_LDFLAGS = $(shell sdl11-config --libs)
EXTRA_CFLAGS = -DFREEBSD=1
endif

ifeq ($(strip $(linux)), true)
SDL_CFLAGS = $(shell sdl-config --cflags)
SDL_LDFLAGS = $(shell sdl-config --libs)
EXTRA_CFLAGS = -DLINUX=1
endif

ifeq ($(strip $(win32)), true)
SDL_CFLAGS = $(shell sdl-config --cflags)
SDL_LDFLAGS = $(shell sdl-config --libs)
EXTRA_LDFLAGS = -lwsock32
EXTRA_CFLAGS = -DWIN32=1
endif

Nice solution, I think I’ll steal this bit of code if you don’t mind…
:slight_smile:

I’d really like to see sdl-config deal with this though… It shouldn’t
be my responsibility imo.On Jun 3, 2004, at 4:54 AM, Alexander Bussman wrote:

On Thursday 03 June 2004 03:31, Paul Richards wrote:


Paul Richards
pauldoo at users.sf.net

yeah it would be cool if you could do something like:

sdl-config --gllibs

to get the -lglu32 -lopengl32 for windows and whatever else you use for
other OS’s.> ----- Original Message -----

From: p.a.richards@sms.ed.ac.uk (Paul Richards)
To: "A list for developers using the SDL library. ((includes SDL-announce))"

Sent: Thursday, June 03, 2004 9:09 AM
Subject: Re: [SDL] Portable Makefile question

On Jun 3, 2004, at 4:54 AM, Alexander Bussman wrote:

On Thursday 03 June 2004 03:31, Paul Richards wrote:

Hi,
I’m trying to create a Makefile which works on Mac OS X, Linux, and
Win32 (using MinGW).

The problem I am stuck on is dealing with the OpenGL libraries.

“sdl-config --libs” on Mac OS X includes them ("-framework OpenGL"),
but on Linux and Win32 it does not. For Linux and Win32 I need to add
"-lGL -lGLU" into the Makefile which of course breaks the Mac OS X
build.

Does anyone have experience creating cross platform Makefiles which
link with OpenGL?

I have been trying to do some cross platform GNU Makefiles.
The following is a part from a Makefile I did a while ago, it should
detect
win32 (only with mingw), freebsd and linux:
(It doesn’t link OpenGL but it’s easy to add, also to link opengl to
windows
you link it with -lopengl32 and for glu -lglu32)

win32 := false
freebsd := false
linux := false

autodetect_os := true

ifeq ($(strip $(autodetect_os)), true)
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “FreeBSD”)),)
freebsd = true
endif
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “Linux”)),)
linux = true
endif
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “mingw”)),)
win32 = true
endif
endif

ifeq ($(strip $(freebsd)), true)
SDL_CFLAGS = $(shell sdl11-config --cflags)
SDL_LDFLAGS = $(shell sdl11-config --libs)
EXTRA_CFLAGS = -DFREEBSD=1
endif

ifeq ($(strip $(linux)), true)
SDL_CFLAGS = $(shell sdl-config --cflags)
SDL_LDFLAGS = $(shell sdl-config --libs)
EXTRA_CFLAGS = -DLINUX=1
endif

ifeq ($(strip $(win32)), true)
SDL_CFLAGS = $(shell sdl-config --cflags)
SDL_LDFLAGS = $(shell sdl-config --libs)
EXTRA_LDFLAGS = -lwsock32
EXTRA_CFLAGS = -DWIN32=1
endif

Nice solution, I think I’ll steal this bit of code if you don’t mind…
:slight_smile:

I’d really like to see sdl-config deal with this though… It shouldn’t
be my responsibility imo.


Paul Richards
pauldoo at users.sf.net


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi,
I’m trying to create a Makefile which works on Mac OS X, Linux, and
Win32 (using MinGW).

The problem I am stuck on is dealing with the OpenGL libraries.

“sdl-config --libs” on Mac OS X includes them ("-framework OpenGL"),
but on Linux and Win32 it does not. For Linux and Win32 I need to add
"-lGL -lGLU" into the Makefile which of course breaks the Mac OS X
build.

Does anyone have experience creating cross platform Makefiles which
link with OpenGL?

I have been trying to do some cross platform GNU Makefiles.
The following is a part from a Makefile I did a while ago, it should
detect
win32 (only with mingw), freebsd and linux:
(It doesn’t link OpenGL but it’s easy to add, also to link opengl to
windows
you link it with -lopengl32 and for glu -lglu32)

win32 := false
freebsd := false
linux := false

autodetect_os := true

ifeq ($(strip $(autodetect_os)), true)
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “FreeBSD”)),)
freebsd = true
endif
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “Linux”)),)
linux = true
endif
ifneq ($(strip $(shell $(CC) -v 2>&1 |grep “mingw”)),)
win32 = true
endif
endif

ifeq ($(strip $(freebsd)), true)
SDL_CFLAGS = $(shell sdl11-config --cflags)
SDL_LDFLAGS = $(shell sdl11-config --libs)
EXTRA_CFLAGS = -DFREEBSD=1
endif

ifeq ($(strip $(linux)), true)
SDL_CFLAGS = $(shell sdl-config --cflags)
SDL_LDFLAGS = $(shell sdl-config --libs)
EXTRA_CFLAGS = -DLINUX=1
endif

ifeq ($(strip $(win32)), true)
SDL_CFLAGS = $(shell sdl-config --cflags)
SDL_LDFLAGS = $(shell sdl-config --libs)
EXTRA_LDFLAGS = -lwsock32
EXTRA_CFLAGS = -DWIN32=1
endif

Nice solution, I think I’ll steal this bit of code if you don’t mind…
No problem, that’s why I posted it :slight_smile:

I’d really like to see sdl-config deal with this though… It shouldn’t
be my responsibility imo.
Yeah, that would really be nice.
Maybe someday it will get added to sdl-config :slight_smile:

// Alexander BussmanOn Thursday 03 June 2004 18:09, Paul Richards wrote:

On Jun 3, 2004, at 4:54 AM, Alexander Bussman wrote:

On Thursday 03 June 2004 03:31, Paul Richards wrote:

— Paul Richards <p.a.richards at sms.ed.ac.uk> wrote:

I’d really like to see sdl-config deal with this
though… It shouldn’t
be my responsibility imo.

I think - given that on OS X sdl-config --libs spits
out “-framework OpenGL” - that sdl-config is probably
INTENDED to deal with it for you. Perhaps it has
merely been neglected for some reason or another?__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.