[SDL] Portable Makefile question
Alexander Bussman
buxman at telia.com
Thu Jun 3 03:54:27 PDT 2004
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
More information about the SDL
mailing list