summaryrefslogtreecommitdiffstats
path: root/kBuild/sdks/LIBSDL.kmk
blob: 2c828075bb103ae79b2ac1a7b5a4f9de64ca912e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# $Id: LIBSDL.kmk 3418 2020-08-21 11:02:13Z bird $
## @file
# kBuild SDK - Simple DirectMedia Layer, targeting $(KBUILD_TARGET).
#

#
# Copyright (c) 2006-2017 knut st. osmundsen <bird-kBuild-spam-xviiv@anduin.net>
#
# This file is part of kBuild.
#
# kBuild is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# kBuild is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with kBuild; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#
# As a special exception you are granted permission to include this file, via
# the kmk include directive, as you wish without this in itself causing the
# resulting makefile, program or whatever to be covered by the GPL license.
# This exception does not however invalidate any other reasons why the makefile,
# program, whatever should not be covered the GPL.
#
#

SDK_LIBSDL := Simple DirectMedia Layer, targeting $(KBUILD_TARGET).

# SDK Specific Properties
_SDK_LIBSDK_IS_FRAMEWORK := no
ifndef PATH_SDK_LIBSDL
 PATH_SDK_LIBSDL := $(wildcard $(KBUILD_DEVTOOLS_TRG)/libsdl/v*)
 ifeq ($(PATH_SDK_LIBSDL),)
  PATH_SDK_LIBSDL := $(wildcard $(KBUILD_DEVTOOLS_BLD)/libsdl/v*)
 endif
 ifneq ($(PATH_SDK_LIBSDL),)
  PATH_SDK_LIBSDL := $(lastword $(sort $(PATH_SDK_LIBSDL)))
 else

  # Darwin might have a framework for it.
  ifeq ($(KBUILD_TARGET),darwin)
   PATH_SDK_LIBSDL := $(firstword $(wildcard \
	/System/Library/Frameworks/SDL.framework/SDL \
	/Library/Frameworks/SDL.framework/SDL \
	) )
   ifneq ($(PATH_SDK_LIBSDL),)
    PATH_SDK_LIBSDL := $(patsubst %/,%,$(dir $(PATH_SDK_LIBSDL)))
    _SDK_LIBSDK_IS_FRAMEWORK := yes
   endif
  endif

  ifeq ($(PATH_SDK_LIBSDL),)
   PATH_SDK_LIBSDL := $(firstword $(foreach root,$(KBUILD_LIB_SEARCH_ROOTS) \
   	,$(if $(wildcard $(addsuffix libSDL.*,$(addprefix $(root),$(KBUILD_LIB_SEARCH_SUBS)))),$(root),) ))
   ifeq ($(PATH_SDK_LIBSDL),/)
	PATH_SDK_LIBSDL := /.
   else ifneq ($(PATH_SDK_LIBSDL),)
	PATH_SDK_LIBSDL := $(patsubst %/,%,$(PATH_SDK_LIBSDL))
   else
    $(warning kBuild: PATH_SDK_LIBSDL couldn't be determined!)
    PATH_SDK_LIBSDL := $(KBUILD_DEVTOOLS_TRG)/libsdl/not/found
   endif
  endif
 endif
else
 PATH_SDK_LIBSDL := $(PATH_SDK_LIBSDL)
 ifeq ($(KBUILD_TARGET),darwin)
  # Check if it's the framework or not.
  _SDK_LIBSDK_IS_FRAMEWORK := $(if $(wildcard $(PATH_SDK_LIBSDL)/Headers/SDL.h),yes)
 endif
endif

#
# The way libsdl is distributed on the different platforms
# varies quite a bit, thus this kludge.
#
ifeq ($(KBUILD_TARGET),os2)
 LIB_SDK_LIBSDL_SDLMAIN  ?=
 DLL_SDK_LIBSDL_SDL      ?= $(PATH_SDK_LIBSDL)/SDL/SDL12.dll
 DLL_SDK_LIBSDL_FSLIB    ?= $(PATH_SDK_LIBSDL)/SDL/FSLib.dll
 LIB_SDK_LIBSDL_SDL      ?= $(PATH_SDK_LIBSDL)/SDL/SDL12.lib
 LIB_SDK_LIBSDL_SDLGFX   ?= $(PATH_SDK_LIBSDL)/SDLGfx/SDLGFX.lib
 LIB_SDK_LIBSDL_SDLIMAGE ?= $(PATH_SDK_LIBSDL)/SDLImage/SDLIMAGE.lib
 LIB_SDK_LIBSDL_SDLMIXER ?= $(PATH_SDK_LIBSDL)/SDLMixer/SDLMIXER.lib
 LIB_SDK_LIBSDL_SDLNET   ?= $(PATH_SDK_LIBSDL)/SDLNet/SDLNET.lib
 LIB_SDK_LIBSDL_SDLTTF   ?= $(PATH_SDK_LIBSDL)/SDLTTF/SDLTTF.lib

 # General Properties used by kBuild
 SDK_LIBSDL_INCS ?= \
 	$(PATH_SDK_LIBSDL)/SDL/include \
 	$(PATH_SDK_LIBSDL)/SDLGfx \
 	$(PATH_SDK_LIBSDL)/SDLImage \
 	$(PATH_SDK_LIBSDL)/SDLMixer \
 	$(PATH_SDK_LIBSDL)/SDLNet \
 	$(PATH_SDK_LIBSDL)/SDLTTF
 SDK_LIBSDL_LIBS ?= \
 	$(LIB_SDK_LIBSDL_SDL)
 SDK_LIBSDL_LIBPATH ?= \
 	$(PATH_SDK_LIBSDL)/SDL \
 	$(PATH_SDK_LIBSDL)/SDLGfx \
 	$(PATH_SDK_LIBSDL)/SDLImage \
 	$(PATH_SDK_LIBSDL)/SDLMixer \
 	$(PATH_SDK_LIBSDL)/SDLNet \
 	$(PATH_SDK_LIBSDL)/SDLTTF

else ifeq ($(KBUILD_TARGET),win) # ASSUMES VC++ on windows, sorry.
 LIB_SDK_LIBSDL_SDLMAIN  ?= $(PATH_SDK_LIBSDL)/lib/SDLmain.lib
 LIB_SDK_LIBSDL_SDL      ?= $(PATH_SDK_LIBSDL)/lib/SDL.lib
 DLL_SDK_LIBSDL_SDL      ?= $(PATH_SDK_LIBSDL)/lib/SDL.dll
 LIB_SDK_LIBSDL_SDLGFX   ?= $(PATH_SDK_LIBSDL)/lib/SDL_gfx.lib
 LIB_SDK_LIBSDL_SDLIMAGE ?= $(PATH_SDK_LIBSDL)/lib/SDL_image.lib
 LIB_SDK_LIBSDL_SDLMIXER ?= $(PATH_SDK_LIBSDL)/lib/SDL_mixer.lib
 LIB_SDK_LIBSDL_SDLNET   ?= $(PATH_SDK_LIBSDL)/lib/SDL_net.lib
 LIB_SDK_LIBSDL_SDLTTF   ?= $(PATH_SDK_LIBSDL)/lib/SDL_ttf.lib
 DLL_SDK_LIBSDL_SDLTTF   ?= $(PATH_SDK_LIBSDL)/lib/SDL_ttf.dll

 # General Properties used by kBuild
 SDK_LIBSDL_INCS ?= \
	$(PATH_SDK_LIBSDL)/include/SDL \
	$(PATH_SDK_LIBSDL)/include
 SDK_LIBSDL_LIBS ?= \
	$(LIB_SDK_LIBSDL_SDL)
 SDK_LIBSDL_LIBPATH ?= \
 	$(PATH_SDK_LIBSDL)/lib

else ifeq ($(KBUILD_TARGET).$(_SDK_LIBSDK_IS_FRAMEWORK),darwin.yes)
 # darwin + framework
 LIB_SDK_LIBSDL_SDLMAIN  ?= $(NO_SUCH_VARIABLE)
 LIB_SDK_LIBSDL_SDL      ?= $(NO_SUCH_VARIABLE)
 LIB_SDK_LIBSDL_SDLGFX   ?= $(NO_SUCH_VARIABLE)
 LIB_SDK_LIBSDL_SDLIMAGE ?= $(NO_SUCH_VARIABLE)
 LIB_SDK_LIBSDL_SDLMIXER ?= $(NO_SUCH_VARIABLE)
 LIB_SDK_LIBSDL_SDLNET   ?= $(NO_SUCH_VARIABLE)
 LIB_SDK_LIBSDL_SDLTTF   ?= $(NO_SUCH_VARIABLE)

 # General Properties used by kBuild
 SDK_LIBSDL_INCS         ?= $(PATH_SDK_LIBSDL)/Headers
 SDK_LIBSDL_LDFLAGS      ?= -framework SDL

else # ASSUMES Unix like system
 LIB_SDK_LIBSDL_SDLMAIN  ?= SDLmain
 LIB_SDK_LIBSDL_SDL      ?= SDL
 LIB_SDK_LIBSDL_SDLGFX   ?= SDL_gfx
 LIB_SDK_LIBSDL_SDLIMAGE ?= SDL_image
 LIB_SDK_LIBSDL_SDLMIXER ?= SDL_mixer
 LIB_SDK_LIBSDL_SDLNET   ?= SDL_net
 LIB_SDK_LIBSDL_SDLTTF   ?= SDL_ttf

 # General Properties used by kBuild
 ifndef SDK_LIBSDL_INCS
  ifneq ($(wildcard $(PATH_SDK_LIBSDL)/include/SDL/),)
   SDK_LIBSDL_INCS := $(PATH_SDK_LIBSDL)/include/SDL
  else
   SDK_LIBSDL_INCS := $(PATH_SDK_LIBSDL)/include
  endif
 endif
 SDK_LIBSDL_LIBS ?= \
	$(LIB_SDK_LIBSDL_SDL)
 SDK_LIBSDL_LIBPATH ?= \
 	$(PATH_SDK_LIBSDL)/lib
endif