Android release v6.7_preview1
[xcsoar.git] / build / targets.mk
blob1e9a64493c2ce51d36ada8ef1ec010778dc0a891
1 TARGETS = PC WIN64 \
2 PPC2000 PPC2003 PPC2003X WM5 WM5X \
3 ALTAIR \
4 UNIX UNIX32 UNIX64 OPT \
5 PI KOBO \
6 ANDROID ANDROID7 ANDROID7NEON ANDROID86 ANDROIDMIPS \
7 ANDROIDFAT \
8 WINE CYGWIN
10 ifeq ($(TARGET),)
11 ifeq ($(HOST_IS_UNIX),y)
12 TARGET = UNIX
13 else
14 TARGET = PC
15 endif
16 else
17 ifeq ($(filter $(TARGET),$(TARGETS)),)
18 $(error Unknown target: $(TARGET))
19 endif
20 endif
22 TARGET_FLAVOR := $(TARGET)
24 HAVE_CE := n
25 HAVE_FPU := y
26 X64 := n
27 TARGET_IS_ARM = n
28 XSCALE := n
29 ARMV5 = n
30 ARMV6 = n
31 ARMV7 := n
32 NEON := n
33 X86 := n
34 MIPS := n
35 FAT_BINARY := n
37 TARGET_IS_DARWIN := n
38 TARGET_IS_LINUX := n
39 TARGET_IS_PI := n
40 TARGET_IS_KOBO := n
41 HAVE_POSIX := n
42 HAVE_WIN32 := y
43 HAVE_MSVCRT := y
45 TARGET_ARCH :=
47 # virtual targets ("flavors")
49 ifeq ($(TARGET),WIN64)
50 X64 := y
51 override TARGET = PC
52 endif
54 ifeq ($(TARGET),PPC2003X)
55 TARGET_IS_ARM = y
56 XSCALE := y
57 override TARGET = PPC2003
58 endif
60 ifeq ($(TARGET),WM5X)
61 TARGET_IS_ARM = y
62 XSCALE := y
63 override TARGET = WM5
64 endif
66 ifeq ($(TARGET),ANDROID)
67 TARGET_IS_ARM = y
68 ifeq ($(DEBUG),n)
69 ARMV6 = y
70 else
71 # ARMv5 in the debug build, to allow installation on the emulator
72 ARMV5 = y
73 endif
74 endif
76 ifeq ($(TARGET),ANDROID7NEON)
77 NEON := y
78 override TARGET = ANDROID7
79 endif
81 ifeq ($(TARGET),ANDROID7)
82 TARGET_IS_ARM = y
83 ARMV7 := y
84 override TARGET = ANDROID
85 endif
87 ifeq ($(TARGET),ANDROID86)
88 X86 := y
89 override TARGET = ANDROID
90 endif
92 ifeq ($(TARGET),ANDROIDMIPS)
93 MIPS := y
94 override TARGET = ANDROID
95 endif
97 ifeq ($(TARGET),ANDROIDFAT)
98 FAT_BINARY := y
99 override TARGET = ANDROID
100 endif
102 # real targets
104 ifeq ($(TARGET),PPC2000)
105 TARGET_IS_ARM = y
106 CE_MAJOR := 3
107 CE_MINOR := 00
108 PCPU := ARM
110 HAVE_CE := y
111 endif
113 ifeq ($(TARGET),PPC2003)
114 TARGET_IS_ARM = y
115 CE_MAJOR := 4
116 CE_MINOR := 00
117 PCPU := ARMV4
119 HAVE_CE := y
120 endif
122 ifeq ($(TARGET),PC)
123 ifeq ($(X64),y)
124 TCPREFIX := x86_64-w64-mingw32-
125 TARGET_ARCH += -m64
126 else
127 TCPREFIX := i686-w64-mingw32-
128 TARGET_ARCH += -march=i586
129 endif
131 ifneq ($(MINGWPATH),)
132 TCPREFIX := $(MINGWPATH)
133 endif
135 ifeq ($(WINHOST),y)
136 TCPREFIX :=
137 endif
139 WINVER = 0x0500
140 endif
142 ifeq ($(TARGET),CYGWIN)
143 TCPREFIX :=
145 TARGET_ARCH += -march=i586
147 WINVER = 0x0500
148 WINHOST := y
150 HAVE_POSIX := y
151 HAVE_WIN32 := y
152 HAVE_MSVCRT := n
153 HAVE_VASPRINTF := y
154 endif
156 ifeq ($(TARGET),ALTAIR)
157 CE_MAJOR := 5
158 CE_MINOR := 00
160 TARGET_IS_ARM = y
161 HAVE_CE := y
162 XSCALE := y
163 endif
165 ifeq ($(TARGET),WM5)
166 TARGET_IS_ARM = y
167 PCPU := ARMV4
168 CE_MAJOR := 5
169 CE_MINOR := 00
171 HAVE_CE := y
172 endif
174 ifeq ($(TARGET),WINE)
175 TCPREFIX := wine
176 TARGET_ARCH += -march=i586
177 WINVER = 0x0500
179 HAVE_POSIX := y
180 HAVE_MSVCRT := n
181 endif
183 ifeq ($(TARGET),OPT)
184 override TARGET = UNIX
185 DEBUG = n
186 endif
188 ifeq ($(TARGET),UNIX)
189 # LOCAL_TCPREFIX is set in local-config.mk if configure was run.
190 TCPREFIX := $(LOCAL_TCPREFIX)
191 TCSUFFIX := $(LOCAL_TCSUFFIX)
192 TARGET_IS_ARM = $(HOST_IS_ARM)
193 TARGET_IS_PI = $(HOST_IS_PI)
194 ARMV6 = $(HOST_IS_ARMV6)
195 ARMV7 = $(HOST_IS_ARMV7)
196 NEON = $(HOST_HAS_NEON)
197 endif
199 ifeq ($(TARGET),UNIX32)
200 override TARGET = UNIX
201 TARGET_ARCH += -m32
202 endif
204 ifeq ($(TARGET),UNIX64)
205 override TARGET = UNIX
206 TARGET_ARCH += -m64
207 endif
209 ifeq ($(TARGET),PI)
210 override TARGET = UNIX
211 TCPREFIX := arm-linux-gnueabihf-
212 PI ?= /opt/pi/root
213 TARGET_ARCH += -march=armv6j -mfpu=vfp -mfloat-abi=hard
214 TARGET_IS_PI = y
215 TARGET_IS_ARM = y
216 ARMV6 = y
217 endif
219 ifeq ($(TARGET),KOBO)
220 # Experimental target for Kobo Mini
221 override TARGET = UNIX
222 TCPREFIX := arm-linux-gnueabihf-
223 KOBO ?= /opt/kobo/arm-unknown-linux-gnueabi
224 TARGET_ARCH += -march=armv7-a -mfloat-abi=hard
225 TARGET_IS_KOBO = y
226 TARGET_IS_ARM = y
227 ARMV7 := y
228 endif
230 ifeq ($(TARGET),UNIX)
231 HAVE_POSIX := y
232 HAVE_WIN32 := n
233 HAVE_MSVCRT := n
234 HAVE_VASPRINTF := y
236 ifeq ($(ARMV6),y)
237 TARGET_ARCH += -march=armv6
238 endif
240 ifeq ($(ARMV7),y)
241 TARGET_ARCH += -march=armv7-a
242 endif
244 ifeq ($(NEON),y)
245 TARGET_ARCH += -mfpu=neon -mfpu=vfpv3-d16
246 endif
247 endif
249 ifeq ($(filter $(TARGET),UNIX WINE),$(TARGET))
250 ifeq ($(HOST_IS_LINUX),y)
251 TARGET_IS_LINUX := y
252 endif
253 ifeq ($(HOST_IS_DARWIN),y)
254 TARGET_IS_DARWIN := y
255 endif
256 endif
258 ifeq ($(TARGET),ANDROID)
259 ANDROID_NDK ?= $(HOME)/opt/android-ndk-r8e
261 ANDROID_PLATFORM = android-16
262 ANDROID_SDK_PLATFORM = $(ANDROID_PLATFORM)
264 # NDK r8b has only android-14
265 ANDROID_NDK_PLATFORM = android-14
267 ANDROID_ARCH = arm
268 ANDROID_ABI2 = arm-linux-androideabi
269 ANDROID_ABI3 = armeabi
270 ANDROID_ABI4 = $(ANDROID_ABI2)
271 ANDROID_ABI_SUBDIR = .
272 ANDROID_GCC_VERSION = 4.7
273 ANDROID_GCC_VERSION2 = $(ANDROID_GCC_VERSION)
275 ifeq ($(ARMV7),y)
276 ANDROID_ABI3 = armeabi-v7a
277 ANDROID_ABI_SUBDIR = armv7-a
278 endif
280 ifeq ($(X86),y)
281 ANDROID_ARCH = x86
282 ANDROID_ABI2 = x86
283 ANDROID_ABI3 = x86
284 ANDROID_ABI4 = i686-linux-android
285 endif
287 ifeq ($(MIPS),y)
288 ANDROID_ARCH = mips
289 ANDROID_ABI2 = mipsel-linux-android
290 ANDROID_ABI3 = mips
291 endif
293 ANDROID_NDK_PLATFORM_DIR = $(ANDROID_NDK)/platforms/$(ANDROID_NDK_PLATFORM)
294 ANDROID_TARGET_ROOT = $(ANDROID_NDK_PLATFORM_DIR)/arch-$(ANDROID_ARCH)
296 ANDROID_GCC_TOOLCHAIN_NAME = $(ANDROID_ABI2)-$(ANDROID_GCC_VERSION)
298 ifeq ($(CLANG),y)
299 ANDROID_TOOLCHAIN_NAME = llvm-3.2
301 # workaround: use libstdc++ 4.6, because 4.7 fails to link with
302 # clang due to missing __atomic_* symbols
303 ANDROID_GCC_VERSION = 4.6
304 else
305 ANDROID_TOOLCHAIN_NAME = $(ANDROID_GCC_TOOLCHAIN_NAME)
306 endif
308 ifeq ($(HOST_IS_DARWIN),y)
309 ANDROID_HOST_TAG = darwin-x86
310 else ifeq ($(WINHOST),y)
311 ANDROID_HOST_TAG = windows
312 else ifeq ($(UNAME_M),x86_64)
313 ANDROID_HOST_TAG = linux-x86_64
314 else
315 ANDROID_HOST_TAG = linux-x86
316 endif
318 ANDROID_GCC_TOOLCHAIN = $(ANDROID_NDK)/toolchains/$(ANDROID_GCC_TOOLCHAIN_NAME)/prebuilt/$(ANDROID_HOST_TAG)
319 ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/$(ANDROID_TOOLCHAIN_NAME)/prebuilt/$(ANDROID_HOST_TAG)
321 ifeq ($(CLANG),y)
322 TCPREFIX = $(ANDROID_TOOLCHAIN)/bin/
323 else
324 TCPREFIX = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_ABI4)-
325 endif
327 ifeq ($(X86),y)
328 HAVE_FPU := y
329 endif
331 ifeq ($(MIPS),y)
332 HAVE_FPU := y
333 endif
335 ifeq ($(ARMV5),y)
336 LLVM_TRIPLE = armv5te-none-linux-androideabi
337 TARGET_ARCH += -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork
338 HAVE_FPU := n
339 endif
341 ifeq ($(ARMV6),y)
342 LLVM_TRIPLE = armv6-none-linux-androideabi
343 TARGET_ARCH += -march=armv6 -mtune=xscale -msoft-float -mthumb-interwork
344 HAVE_FPU := n
345 endif
347 ifeq ($(ARMV7),y)
348 LLVM_TRIPLE = armv7-none-linux-androideabi
349 TARGET_ARCH += -march=armv7-a -mfloat-abi=softfp -mthumb-interwork
350 HAVE_FPU := y
351 endif
353 ifeq ($(ARMV7)$(NEON),yy)
354 TARGET_ARCH += -mfpu=neon
355 endif
357 ifeq ($(ARMV7)$(NEON),yn)
358 TARGET_ARCH += -mfpu=vfpv3-d16
359 endif
361 TARGET_ARCH += -fpic -funwind-tables
363 TARGET_IS_LINUX := y
364 HAVE_POSIX := y
365 HAVE_WIN32 := n
366 HAVE_MSVCRT := n
367 HAVE_VASPRINTF := y
368 endif
370 ifeq ($(HAVE_CE),y)
371 TCPREFIX := arm-mingw32ce-
372 HAVE_FPU := n
374 ifeq ($(XSCALE),y)
375 TARGET_ARCH += -mcpu=xscale
376 else
377 TARGET_ARCH += -mcpu=strongarm1110
378 endif
379 endif
381 ######## target definitions
383 TARGET_INCLUDES =
384 TARGET_CPPFLAGS = -I$(TARGET_OUTPUT_DIR)/include
386 ifeq ($(TESTING),y)
387 TARGET_CPPFLAGS += -DTESTING=y
388 endif
390 ifneq ($(WINVER),)
391 TARGET_CPPFLAGS += -DWINVER=$(WINVER) -D_WIN32_WINDOWS=$(WINVER)
392 TARGET_CPPFLAGS += -D_WIN32_WINNT=$(WINVER) -D_WIN32_IE=$(WINVER)
393 endif
395 ifeq ($(HAVE_CE),y)
396 TARGET_CPPFLAGS += -D_WIN32_WCE=0x0$(CE_MAJOR)$(CE_MINOR)
397 TARGET_CPPFLAGS += -DWIN32_PLATFORM_PSPC=$(CE_MAJOR)$(CE_MINOR)
398 endif
400 ifeq ($(HAVE_WIN32),y)
401 TARGET_CPPFLAGS += -DWIN32_LEAN_AND_MEAN
402 TARGET_CPPFLAGS += -DNOMINMAX
403 ifeq ($(TARGET),CYGWIN)
404 TARGET_CPPFLAGS += -DWIN32
405 endif
406 endif
408 ifeq ($(TARGET),PPC2000)
409 TARGET_CPPFLAGS += -DNOLINETO -DNOCLEARTYPE
410 endif
412 ifeq ($(TARGET),WINE)
413 TARGET_CPPFLAGS += -D__WINE__
414 TARGET_CPPFLAGS += -DWINE_STRICT_PROTOTYPES
415 # -mno-cygwin
416 endif
418 ifeq ($(TARGET),ALTAIR)
419 TARGET_CPPFLAGS += -DGNAV
420 endif
422 ifeq ($(HAVE_POSIX),y)
423 TARGET_CPPFLAGS += -DHAVE_POSIX
424 TARGET_CPPFLAGS += -DHAVE_STDINT_H
425 TARGET_CPPFLAGS += -DHAVE_UNISTD_H
426 TARGET_CPPFLAGS += -DHAVE_VASPRINTF
427 endif
429 ifeq ($(HAVE_MSVCRT),y)
430 TARGET_CPPFLAGS += -DHAVE_MSVCRT
431 TARGET_CPPFLAGS += -DUNICODE -D_UNICODE
432 endif
434 ifeq ($(HAVE_WIN32),n)
435 TARGET_INCLUDES += -I$(SRC)/unix
436 endif
438 ifeq ($(TARGET),WINE)
439 TARGET_INCLUDES += -I$(SRC)/wine
440 endif
442 ifeq ($(HOST_IS_PI)$(TARGET_IS_PI),ny)
443 TARGET_CPPFLAGS += --sysroot=$(PI) -isystem $(PI)/usr/include/arm-linux-gnueabihf
444 endif
446 ifeq ($(TARGET_IS_KOBO),y)
447 TARGET_CPPFLAGS += -DKOBO
448 TARGET_CPPFLAGS += -isystem $(KOBO)/include
449 endif
451 ifeq ($(TARGET),ANDROID)
452 TARGET_CPPFLAGS += --sysroot=$(ANDROID_TARGET_ROOT)
453 TARGET_CPPFLAGS += -DANDROID
454 CXXFLAGS += -D__STDC_VERSION__=199901L
456 ifeq ($(X86),y)
457 # On NDK r6, the macro _BYTE_ORDER never gets defined - workaround:
458 TARGET_CPPFLAGS += -D_BYTE_ORDER=_LITTLE_ENDIAN
459 endif
460 endif
462 ####### compiler target
464 ifeq ($(HAVE_WIN32),y)
465 ifeq ($(TARGET),WINE)
466 TARGET_ARCH += -m32
467 else
468 TARGET_ARCH += -mwin32
469 endif
471 WINDRESFLAGS := -I$(SRC) $(TARGET_CPPFLAGS)
472 endif
474 ifeq ($(TARGET),PC)
475 TARGET_ARCH += -mwindows -mms-bitfields
476 endif
478 ifeq ($(TARGET),CYGWIN)
479 WINDRESFLAGS += -I./Data
480 endif
482 ####### linker configuration
484 TARGET_LDFLAGS =
485 TARGET_LDLIBS =
486 TARGET_LDADD =
488 ifeq ($(TARGET),PC)
489 TARGET_LDFLAGS += -Wl,--major-subsystem-version=5
490 TARGET_LDFLAGS += -Wl,--minor-subsystem-version=00
492 # default to "console"; see SCREEN_LDLIBS
493 TARGET_LDFLAGS += -Wl,-subsystem,console
494 endif
496 ifeq ($(HAVE_WIN32),y)
497 ifeq ($(HAVE_CE),y)
498 TARGET_LDFLAGS += -Wl,--major-subsystem-version=$(CE_MAJOR)
499 TARGET_LDFLAGS += -Wl,--minor-subsystem-version=$(CE_MINOR)
500 endif
502 ifeq ($(TARGET),WINE)
503 TARGET_LDLIBS += -lpthread
504 else
505 ifneq ($(TARGET),CYGWIN)
506 # link libstdc++-6.dll statically, so we don't have to distribute it
507 TARGET_LDFLAGS += -static
508 endif
509 endif
510 endif
512 ifeq ($(HAVE_POSIX),y)
513 ifneq ($(TARGET),ANDROID)
514 TARGET_LDLIBS += -lpthread
515 ifeq ($(TARGET_IS_LINUX),y)
516 TARGET_LDLIBS += -lrt # for clock_gettime()
517 endif
518 endif
519 endif
521 ifeq ($(HOST_IS_PI)$(TARGET_IS_PI),ny)
522 TARGET_LDFLAGS += --sysroot=$(PI) -L$(PI)/usr/lib/arm-linux-gnueabihf
523 endif
525 ifeq ($(TARGET_IS_KOBO),y)
526 TARGET_LDFLAGS += -L$(KOBO)/lib
527 TARGET_LDFLAGS += -static
528 endif
530 ifeq ($(TARGET),ANDROID)
531 TARGET_LDFLAGS += -Wl,--no-undefined
532 TARGET_LDFLAGS += --sysroot=$(ANDROID_TARGET_ROOT)
533 TARGET_LDFLAGS += -L$(ANDROID_TARGET_ROOT)/usr/lib
535 ifeq ($(ARMV7),y)
536 TARGET_LDFLAGS += -Wl,--fix-cortex-a8
537 endif
538 endif
540 ifneq ($(filter PC WINE CYGWIN,$(TARGET)),)
541 TARGET_LDLIBS += -lwinmm
542 endif
544 ifeq ($(TARGET),CYGWIN)
545 TARGET_LDLIBS += -lintl
546 endif
548 ifeq ($(HAVE_CE),y)
549 ifneq ($(TARGET),ALTAIR)
550 TARGET_CPPFLAGS += -DHAVE_NOTE_PRJ_DLL
551 TARGET_CPPFLAGS += -DHAVE_AYGSHELL_DLL
552 TARGET_CPPFLAGS += -DHAVE_IMGDECMP_DLL
553 endif
554 endif
556 ifeq ($(TARGET),UNIX)
557 ifeq ($(TARGET_IS_DARWIN),n)
558 TARGET_LDLIBS += -lm
559 endif
560 endif
562 ifeq ($(TARGET),ANDROID)
563 TARGET_LDLIBS += -lc -lm
564 TARGET_LDLIBS += -llog
565 TARGET_LDADD += $(ANDROID_GCC_TOOLCHAIN)/lib/gcc/$(ANDROID_ABI4)/$(ANDROID_GCC_VERSION2)/$(ANDROID_ABI_SUBDIR)/libgcc.a
566 endif
568 ######## output files
570 TARGET_EXEEXT = .exe
572 ifeq ($(TARGET),UNIX)
573 TARGET_EXEEXT :=
574 endif
576 ifeq ($(TARGET),ANDROID)
577 TARGET_EXEEXT :=
578 endif