TaskStats: simplify margin formula
[xcsoar.git] / build / targets.mk
blob04e36f02ffae8e379f84eac0cd7d33b4942f5602
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 XSCALE := n
28 ARMV5 = n
29 ARMV6 = n
30 ARMV7 := n
31 NEON := n
32 X86 := n
33 MIPS := n
34 FAT_BINARY := n
36 TARGET_IS_DARWIN := n
37 TARGET_IS_LINUX := n
38 TARGET_IS_PI := n
39 TARGET_IS_KOBO := n
40 HAVE_POSIX := n
41 HAVE_WIN32 := y
42 HAVE_MSVCRT := y
44 TARGET_ARCH :=
46 # virtual targets ("flavors")
48 ifeq ($(TARGET),WIN64)
49 X64 := y
50 override TARGET = PC
51 endif
53 ifeq ($(TARGET),PPC2003X)
54 XSCALE := y
55 override TARGET = PPC2003
56 endif
58 ifeq ($(TARGET),WM5X)
59 XSCALE := y
60 override TARGET = WM5
61 endif
63 ifeq ($(TARGET),ANDROID)
64 ifeq ($(DEBUG),n)
65 ARMV6 = y
66 else
67 # ARMv5 in the debug build, to allow installation on the emulator
68 ARMV5 = y
69 endif
70 endif
72 ifeq ($(TARGET),ANDROID7NEON)
73 NEON := y
74 override TARGET = ANDROID7
75 endif
77 ifeq ($(TARGET),ANDROID7)
78 ARMV7 := y
79 override TARGET = ANDROID
80 endif
82 ifeq ($(TARGET),ANDROID86)
83 X86 := y
84 override TARGET = ANDROID
85 endif
87 ifeq ($(TARGET),ANDROIDMIPS)
88 MIPS := y
89 override TARGET = ANDROID
90 endif
92 ifeq ($(TARGET),ANDROIDFAT)
93 FAT_BINARY := y
94 override TARGET = ANDROID
95 endif
97 # real targets
99 ifeq ($(TARGET),PPC2000)
100 CE_MAJOR := 3
101 CE_MINOR := 00
102 PCPU := ARM
104 HAVE_CE := y
105 endif
107 ifeq ($(TARGET),PPC2003)
108 CE_MAJOR := 4
109 CE_MINOR := 00
110 PCPU := ARMV4
112 HAVE_CE := y
113 endif
115 ifeq ($(TARGET),PC)
116 ifeq ($(X64),y)
117 TCPREFIX := x86_64-w64-mingw32-
118 TARGET_ARCH += -m64
119 else
120 TCPREFIX := i686-w64-mingw32-
121 TARGET_ARCH += -march=i586
122 endif
124 ifneq ($(MINGWPATH),)
125 TCPREFIX := $(MINGWPATH)
126 endif
128 ifeq ($(WINHOST),y)
129 TCPREFIX :=
130 endif
132 WINVER = 0x0500
133 endif
135 ifeq ($(TARGET),CYGWIN)
136 TCPREFIX :=
138 TARGET_ARCH += -march=i586
140 WINVER = 0x0500
141 WINHOST := y
143 HAVE_POSIX := y
144 HAVE_WIN32 := y
145 HAVE_MSVCRT := n
146 HAVE_VASPRINTF := y
147 endif
149 ifeq ($(TARGET),ALTAIR)
150 CE_MAJOR := 5
151 CE_MINOR := 00
153 HAVE_CE := y
154 XSCALE := y
155 endif
157 ifeq ($(TARGET),WM5)
158 PCPU := ARMV4
159 CE_MAJOR := 5
160 CE_MINOR := 00
162 HAVE_CE := y
163 endif
165 ifeq ($(TARGET),WINE)
166 TCPREFIX := wine
167 TARGET_ARCH += -march=i586
168 WINVER = 0x0500
170 HAVE_POSIX := y
171 HAVE_MSVCRT := n
172 endif
174 ifeq ($(TARGET),OPT)
175 override TARGET = UNIX
176 DEBUG = n
177 endif
179 ifeq ($(TARGET),UNIX)
180 # LOCAL_TCPREFIX is set in local-config.mk if configure was run.
181 TCPREFIX := $(LOCAL_TCPREFIX)
182 TCSUFFIX := $(LOCAL_TCSUFFIX)
183 TARGET_IS_PI = $(HOST_IS_PI)
184 ARMV6 = $(HOST_IS_ARMV6)
185 ARMV7 = $(HOST_IS_ARMV7)
186 NEON = $(HOST_HAS_NEON)
187 endif
189 ifeq ($(TARGET),UNIX32)
190 override TARGET = UNIX
191 TARGET_ARCH += -m32
192 endif
194 ifeq ($(TARGET),UNIX64)
195 override TARGET = UNIX
196 TARGET_ARCH += -m64
197 endif
199 ifeq ($(TARGET),PI)
200 override TARGET = UNIX
201 TCPREFIX := arm-linux-gnueabihf-
202 PI ?= /opt/pi/root
203 TARGET_ARCH += -march=armv6j -mfpu=vfp -mfloat-abi=hard
204 TARGET_IS_PI = y
205 ARMV6 = y
206 endif
208 ifeq ($(TARGET),KOBO)
209 # Experimental target for Kobo Mini
210 override TARGET = UNIX
211 TCPREFIX := arm-linux-gnueabihf-
212 KOBO ?= /opt/kobo/arm-unknown-linux-gnueabi
213 TARGET_ARCH += -march=armv7-a -mfloat-abi=hard
214 TARGET_IS_KOBO = y
215 ARMV7 := y
216 endif
218 ifeq ($(TARGET),UNIX)
219 HAVE_POSIX := y
220 HAVE_WIN32 := n
221 HAVE_MSVCRT := n
222 HAVE_VASPRINTF := y
224 ifeq ($(ARMV6),y)
225 TARGET_ARCH += -march=armv6
226 endif
228 ifeq ($(ARMV7),y)
229 TARGET_ARCH += -march=armv7-a
230 endif
232 ifeq ($(NEON),y)
233 TARGET_ARCH += -mfpu=neon -mfpu=vfpv3-d16
234 endif
235 endif
237 ifeq ($(filter $(TARGET),UNIX WINE),$(TARGET))
238 ifeq ($(HOST_IS_LINUX),y)
239 TARGET_IS_LINUX := y
240 endif
241 ifeq ($(HOST_IS_DARWIN),y)
242 TARGET_IS_DARWIN := y
243 endif
244 endif
246 ifeq ($(TARGET),ANDROID)
247 ANDROID_NDK ?= $(HOME)/opt/android-ndk-r8e
249 ANDROID_PLATFORM = android-16
250 ANDROID_SDK_PLATFORM = $(ANDROID_PLATFORM)
252 # NDK r8b has only android-14
253 ANDROID_NDK_PLATFORM = android-14
255 ANDROID_ARCH = arm
256 ANDROID_ABI2 = arm-linux-androideabi
257 ANDROID_ABI3 = armeabi
258 ANDROID_ABI4 = $(ANDROID_ABI2)
259 ANDROID_ABI_SUBDIR = .
260 ANDROID_GCC_VERSION = 4.7
261 ANDROID_GCC_VERSION2 = $(ANDROID_GCC_VERSION)
263 ifeq ($(ARMV7),y)
264 ANDROID_ABI3 = armeabi-v7a
265 ANDROID_ABI_SUBDIR = armv7-a
266 endif
268 ifeq ($(X86),y)
269 ANDROID_ARCH = x86
270 ANDROID_ABI2 = x86
271 ANDROID_ABI3 = x86
272 ANDROID_ABI4 = i686-linux-android
273 endif
275 ifeq ($(MIPS),y)
276 ANDROID_ARCH = mips
277 ANDROID_ABI2 = mipsel-linux-android
278 ANDROID_ABI3 = mips
279 endif
281 ANDROID_NDK_PLATFORM_DIR = $(ANDROID_NDK)/platforms/$(ANDROID_NDK_PLATFORM)
282 ANDROID_TARGET_ROOT = $(ANDROID_NDK_PLATFORM_DIR)/arch-$(ANDROID_ARCH)
284 ANDROID_GCC_TOOLCHAIN_NAME = $(ANDROID_ABI2)-$(ANDROID_GCC_VERSION)
286 ifeq ($(CLANG),y)
287 ANDROID_TOOLCHAIN_NAME = llvm-3.2
288 else
289 ANDROID_TOOLCHAIN_NAME = $(ANDROID_GCC_TOOLCHAIN_NAME)
290 endif
292 ifeq ($(HOST_IS_DARWIN),y)
293 ANDROID_HOST_TAG = darwin-x86
294 else ifeq ($(WINHOST),y)
295 ANDROID_HOST_TAG = windows
296 else ifeq ($(UNAME_M),x86_64)
297 ANDROID_HOST_TAG = linux-x86_64
298 else
299 ANDROID_HOST_TAG = linux-x86
300 endif
302 ANDROID_GCC_TOOLCHAIN = $(ANDROID_NDK)/toolchains/$(ANDROID_GCC_TOOLCHAIN_NAME)/prebuilt/$(ANDROID_HOST_TAG)
303 ANDROID_TOOLCHAIN = $(ANDROID_NDK)/toolchains/$(ANDROID_TOOLCHAIN_NAME)/prebuilt/$(ANDROID_HOST_TAG)
305 ifeq ($(CLANG),y)
306 TCPREFIX = $(ANDROID_TOOLCHAIN)/bin/
307 else
308 TCPREFIX = $(ANDROID_TOOLCHAIN)/bin/$(ANDROID_ABI4)-
309 endif
311 ifeq ($(X86),y)
312 HAVE_FPU := y
313 endif
315 ifeq ($(MIPS),y)
316 HAVE_FPU := y
317 endif
319 ifeq ($(ARMV5),y)
320 LLVM_TRIPLE = armv5te-none-linux-androideabi
321 TARGET_ARCH += -march=armv5te -mtune=xscale -msoft-float -mthumb-interwork
322 HAVE_FPU := n
323 endif
325 ifeq ($(ARMV6),y)
326 LLVM_TRIPLE = armv6-none-linux-androideabi
327 TARGET_ARCH += -march=armv6 -mtune=xscale -msoft-float -mthumb-interwork
328 HAVE_FPU := n
329 endif
331 ifeq ($(ARMV7),y)
332 LLVM_TRIPLE = armv7-none-linux-androideabi
333 TARGET_ARCH += -march=armv7-a -mfloat-abi=softfp -mthumb-interwork
334 HAVE_FPU := y
335 endif
337 ifeq ($(ARMV7)$(NEON),yy)
338 TARGET_ARCH += -mfpu=neon
339 endif
341 ifeq ($(ARMV7)$(NEON),yn)
342 TARGET_ARCH += -mfpu=vfpv3-d16
343 endif
345 TARGET_ARCH += -fpic -funwind-tables
347 TARGET_IS_LINUX := y
348 HAVE_POSIX := y
349 HAVE_WIN32 := n
350 HAVE_MSVCRT := n
351 HAVE_VASPRINTF := y
352 endif
354 ifeq ($(HAVE_CE),y)
355 TCPREFIX := arm-mingw32ce-
356 HAVE_FPU := n
358 ifeq ($(XSCALE),y)
359 TARGET_ARCH += -mcpu=xscale
360 else
361 TARGET_ARCH += -mcpu=strongarm1110
362 endif
363 endif
365 ######## target definitions
367 TARGET_INCLUDES =
368 TARGET_CPPFLAGS = -I$(TARGET_OUTPUT_DIR)/include
370 ifeq ($(TESTING),y)
371 TARGET_CPPFLAGS += -DTESTING=y
372 endif
374 ifneq ($(WINVER),)
375 TARGET_CPPFLAGS += -DWINVER=$(WINVER) -D_WIN32_WINDOWS=$(WINVER)
376 TARGET_CPPFLAGS += -D_WIN32_WINNT=$(WINVER) -D_WIN32_IE=$(WINVER)
377 endif
379 ifeq ($(HAVE_CE),y)
380 TARGET_CPPFLAGS += -D_WIN32_WCE=0x0$(CE_MAJOR)$(CE_MINOR)
381 TARGET_CPPFLAGS += -DWIN32_PLATFORM_PSPC=$(CE_MAJOR)$(CE_MINOR)
382 endif
384 ifeq ($(HAVE_WIN32),y)
385 TARGET_CPPFLAGS += -DWIN32_LEAN_AND_MEAN
386 TARGET_CPPFLAGS += -DNOMINMAX
387 ifeq ($(TARGET),CYGWIN)
388 TARGET_CPPFLAGS += -DWIN32
389 endif
390 endif
392 ifeq ($(TARGET),PPC2000)
393 TARGET_CPPFLAGS += -DNOLINETO -DNOCLEARTYPE
394 endif
396 ifeq ($(TARGET),WINE)
397 TARGET_CPPFLAGS += -D__WINE__
398 TARGET_CPPFLAGS += -DWINE_STRICT_PROTOTYPES
399 # -mno-cygwin
400 endif
402 ifeq ($(TARGET),ALTAIR)
403 TARGET_CPPFLAGS += -DGNAV
404 endif
406 ifeq ($(HAVE_POSIX),y)
407 TARGET_CPPFLAGS += -DHAVE_POSIX
408 TARGET_CPPFLAGS += -DHAVE_STDINT_H
409 TARGET_CPPFLAGS += -DHAVE_UNISTD_H
410 TARGET_CPPFLAGS += -DHAVE_VASPRINTF
411 endif
413 ifeq ($(HAVE_MSVCRT),y)
414 TARGET_CPPFLAGS += -DHAVE_MSVCRT
415 TARGET_CPPFLAGS += -DUNICODE -D_UNICODE
416 endif
418 ifeq ($(HAVE_WIN32),n)
419 TARGET_INCLUDES += -I$(SRC)/unix
420 endif
422 ifeq ($(TARGET),WINE)
423 TARGET_INCLUDES += -I$(SRC)/wine
424 endif
426 ifeq ($(HOST_IS_PI)$(TARGET_IS_PI),ny)
427 TARGET_CPPFLAGS += --sysroot=$(PI) -isystem $(PI)/usr/include/arm-linux-gnueabihf
428 endif
430 ifeq ($(TARGET_IS_KOBO),y)
431 TARGET_CPPFLAGS += -DKOBO
432 TARGET_CPPFLAGS += -isystem $(KOBO)/include
433 endif
435 ifeq ($(TARGET),ANDROID)
436 TARGET_CPPFLAGS += --sysroot=$(ANDROID_TARGET_ROOT)
437 TARGET_CPPFLAGS += -DANDROID
438 CXXFLAGS += -D__STDC_VERSION__=199901L
440 ifeq ($(X86),y)
441 # On NDK r6, the macro _BYTE_ORDER never gets defined - workaround:
442 TARGET_CPPFLAGS += -D_BYTE_ORDER=_LITTLE_ENDIAN
443 endif
444 endif
446 ####### compiler target
448 ifeq ($(HAVE_WIN32),y)
449 ifeq ($(TARGET),WINE)
450 TARGET_ARCH += -m32
451 else
452 TARGET_ARCH += -mwin32
453 endif
455 WINDRESFLAGS := -I$(SRC) $(TARGET_CPPFLAGS)
456 endif
458 ifeq ($(TARGET),PC)
459 TARGET_ARCH += -mwindows -mms-bitfields
460 endif
462 ifeq ($(TARGET),CYGWIN)
463 WINDRESFLAGS += -I./Data
464 endif
466 ####### linker configuration
468 TARGET_LDFLAGS =
469 TARGET_LDLIBS =
470 TARGET_LDADD =
472 ifeq ($(TARGET),PC)
473 TARGET_LDFLAGS += -Wl,--major-subsystem-version=5
474 TARGET_LDFLAGS += -Wl,--minor-subsystem-version=00
476 # default to "console"; see SCREEN_LDLIBS
477 TARGET_LDFLAGS += -Wl,-subsystem,console
478 endif
480 ifeq ($(HAVE_WIN32),y)
481 ifeq ($(HAVE_CE),y)
482 TARGET_LDFLAGS += -Wl,--major-subsystem-version=$(CE_MAJOR)
483 TARGET_LDFLAGS += -Wl,--minor-subsystem-version=$(CE_MINOR)
484 endif
486 ifeq ($(TARGET),WINE)
487 TARGET_LDLIBS += -lpthread
488 else
489 ifneq ($(TARGET),CYGWIN)
490 # link libstdc++-6.dll statically, so we don't have to distribute it
491 TARGET_LDFLAGS += -static
492 endif
493 endif
494 endif
496 ifeq ($(HAVE_POSIX),y)
497 ifneq ($(TARGET),ANDROID)
498 TARGET_LDLIBS += -lpthread
499 ifeq ($(TARGET_IS_LINUX),y)
500 TARGET_LDLIBS += -lrt # for clock_gettime()
501 endif
502 endif
503 endif
505 ifeq ($(HOST_IS_PI)$(TARGET_IS_PI),ny)
506 TARGET_LDFLAGS += --sysroot=$(PI) -L$(PI)/usr/lib/arm-linux-gnueabihf
507 endif
509 ifeq ($(TARGET_IS_KOBO),y)
510 TARGET_LDFLAGS += -L$(KOBO)/lib
511 TARGET_LDFLAGS += -static
512 endif
514 ifeq ($(TARGET),ANDROID)
515 TARGET_LDFLAGS += -Wl,--no-undefined
516 TARGET_LDFLAGS += --sysroot=$(ANDROID_TARGET_ROOT)
517 TARGET_LDFLAGS += -L$(ANDROID_TARGET_ROOT)/usr/lib
519 ifeq ($(ARMV7),y)
520 TARGET_LDFLAGS += -Wl,--fix-cortex-a8
521 endif
522 endif
524 ifneq ($(filter PC WINE CYGWIN,$(TARGET)),)
525 TARGET_LDLIBS += -lwinmm
526 endif
528 ifeq ($(TARGET),CYGWIN)
529 TARGET_LDLIBS += -lintl
530 endif
532 ifeq ($(HAVE_CE),y)
533 ifneq ($(TARGET),ALTAIR)
534 TARGET_CPPFLAGS += -DHAVE_NOTE_PRJ_DLL
535 TARGET_CPPFLAGS += -DHAVE_AYGSHELL_DLL
536 TARGET_CPPFLAGS += -DHAVE_IMGDECMP_DLL
537 endif
538 endif
540 ifeq ($(TARGET),UNIX)
541 ifeq ($(TARGET_IS_DARWIN),n)
542 TARGET_LDLIBS += -lm
543 endif
544 endif
546 ifeq ($(TARGET),ANDROID)
547 TARGET_LDLIBS += -lc -lm
548 TARGET_LDLIBS += -llog
549 TARGET_LDADD += $(ANDROID_GCC_TOOLCHAIN)/lib/gcc/$(ANDROID_ABI4)/$(ANDROID_GCC_VERSION2)/$(ANDROID_ABI_SUBDIR)/libgcc.a
550 endif
552 ######## output files
554 TARGET_EXEEXT = .exe
556 ifeq ($(TARGET),UNIX)
557 TARGET_EXEEXT :=
558 endif
560 ifeq ($(TARGET),ANDROID)
561 TARGET_EXEEXT :=
562 endif