input: Don't send an VLC_INPUT_TITLE_SELECTED event
[vlc.git] / contrib / src / main.mak
blob7eef7b85b689590e60299ea708cc75809d97dab7
1 # Main makefile for VLC 3rd party libraries ("contrib")
2 # Copyright (C) 2003-2011 the VideoLAN team
4 # This file is under the same license as the vlc package.
6 all: install
8 SRC := $(TOPSRC)/src
9 SRC_BUILT := $(TOPSRC_BUILT)/src
10 TARBALLS := $(TOPSRC)/tarballs
11 VLC_TOOLS ?= $(TOPSRC)/../extras/tools/build
13 PATH :=$(abspath $(VLC_TOOLS)/bin):$(PATH)
14 export PATH
16 PKGS_ALL := $(patsubst $(SRC)/%/rules.mak,%,$(wildcard $(SRC)/*/rules.mak))
17 DATE := $(shell date +%Y%m%d)
18 VPATH := $(TARBALLS)
20 # Common download locations
21 GNU ?= http://ftp.gnu.org/gnu
22 SF := https://netcologne.dl.sourceforge.net/
23 VIDEOLAN := http://downloads.videolan.org/pub/videolan
24 CONTRIB_VIDEOLAN := http://downloads.videolan.org/pub/contrib
25 GITHUB := https://github.com/
28 # Machine-dependent variables
31 PREFIX ?= $(TOPDST)/$(HOST)
32 PREFIX := $(abspath $(PREFIX))
33 BUILDPREFIX ?= $(TOPDST)
34 BUILDPREFIX := $(abspath $(BUILDPREFIX))
35 BUILDBINDIR ?= $(BUILDPREFIX)/bin
36 ifneq ($(HOST),$(BUILD))
37 HAVE_CROSS_COMPILE = 1
38 endif
39 ARCH := $(shell $(SRC)/get-arch.sh $(HOST))
41 ifeq ($(ARCH)-$(HAVE_WIN32),x86_64-1)
42 HAVE_WIN64 := 1
43 endif
44 ifeq ($(ARCH)-$(HAVE_WIN32),aarch64-1)
45 HAVE_WIN64 := 1
46 endif
48 ifdef HAVE_CROSS_COMPILE
49 need_pkg = 1
50 else
51 ifeq ($(findstring mingw32,$(BUILD)),mingw32)
52 need_pkg = $(shell PKG_CONFIG_LIBDIR="${PKG_CONFIG_PATH}" $(PKG_CONFIG) $(1) || echo 1)
53 else
54 need_pkg = $(shell $(PKG_CONFIG) $(1) || echo 1)
55 endif
56 endif
58 ifeq ($(findstring mingw32,$(BUILD)),mingw32)
59 MSYS_BUILD := 1
60 endif
61 ifeq ($(findstring msys,$(BUILD)),msys)
62 MSYS_BUILD := 1
63 endif
66 # Default values for tools
68 ifndef HAVE_CROSS_COMPILE
69 ifneq ($(findstring $(origin CC),undefined default),)
70 CC := gcc
71 endif
72 ifneq ($(findstring $(origin CXX),undefined default),)
73 CXX := g++
74 endif
75 ifneq ($(findstring $(origin LD),undefined default),)
76 LD := ld
77 endif
78 ifneq ($(findstring $(origin AR),undefined default),)
79 AR := ar
80 endif
81 ifneq ($(findstring $(origin RANLIB),undefined default),)
82 RANLIB := ranlib
83 endif
84 ifneq ($(findstring $(origin STRIP),undefined default),)
85 STRIP := strip
86 endif
87 ifneq ($(findstring $(origin WIDL),undefined default),)
88 WIDL := widl
89 endif
90 ifneq ($(findstring $(origin WINDRES),undefined default),)
91 WINDRES := windres
92 endif
93 else
94 ifneq ($(findstring $(origin CC),undefined default),)
95 CC := $(HOST)-gcc
96 endif
97 ifneq ($(findstring $(origin CXX),undefined default),)
98 CXX := $(HOST)-g++
99 endif
100 ifneq ($(findstring $(origin LD),undefined default),)
101 LD := $(HOST)-ld
102 endif
103 ifneq ($(findstring $(origin AR),undefined default),)
104 AR := $(HOST)-ar
105 endif
106 ifneq ($(findstring $(origin RANLIB),undefined default),)
107 RANLIB := $(HOST)-ranlib
108 endif
109 ifneq ($(findstring $(origin STRIP),undefined default),)
110 STRIP := $(HOST)-strip
111 endif
112 ifneq ($(findstring $(origin WIDL),undefined default),)
113 WIDL := $(HOST)-widl
114 endif
115 ifneq ($(findstring $(origin WINDRES),undefined default),)
116 WINDRES := $(HOST)-windres
117 endif
118 endif
120 ifdef HAVE_ANDROID
121 ifneq ($(findstring $(origin CC),undefined default),)
122 CC := clang
123 endif
124 ifneq ($(findstring $(origin CXX),undefined default),)
125 CXX := clang++
126 endif
127 endif
129 ifdef HAVE_MACOSX
130 EXTRA_CXXFLAGS += -stdlib=libc++
131 ifeq ($(ARCH),x86_64)
132 EXTRA_CFLAGS += -m64
133 EXTRA_LDFLAGS += -m64
134 else
135 EXTRA_CFLAGS += -m32
136 EXTRA_LDFLAGS += -m32
137 endif
139 XCODE_FLAGS += -arch $(ARCH)
141 endif
143 CCAS=$(CC) -c
145 ifdef HAVE_IOS
146 ifdef HAVE_NEON
147 AS=perl $(abspath $(VLC_TOOLS)/bin/gas-preprocessor.pl) $(CC)
148 CCAS=gas-preprocessor.pl $(CC) -c
149 endif
150 endif
152 LN_S = ln -s
153 ifdef HAVE_WIN32
154 ifneq ($(shell $(CC) $(CFLAGS) -E -dM -include _mingw.h - < /dev/null | grep -E __MINGW64_VERSION_MAJOR),)
155 HAVE_MINGW_W64 := 1
156 endif
157 ifndef HAVE_CROSS_COMPILE
158 LN_S = cp -R
159 endif
160 endif
162 ifdef HAVE_SOLARIS
163 ifeq ($(ARCH),x86_64)
164 EXTRA_CFLAGS += -m64
165 EXTRA_LDFLAGS += -m64
166 else
167 EXTRA_CFLAGS += -m32
168 EXTRA_LDFLAGS += -m32
169 endif
170 endif
172 ifdef HAVE_WINSTORE
173 EXTRA_CFLAGS += -DWINSTORECOMPAT
174 EXTRA_LDFLAGS += -lwinstorecompat
175 endif
177 ifneq ($(findstring clang, $(shell $(CC) --version 2>/dev/null)),)
178 HAVE_CLANG := 1
179 endif
181 cppcheck = $(shell $(CC) $(CFLAGS) -E -dM - < /dev/null | grep -E $(1))
183 EXTRA_CFLAGS += -I$(PREFIX)/include
184 CPPFLAGS := $(CPPFLAGS) $(EXTRA_CFLAGS)
185 CFLAGS := $(CFLAGS) $(EXTRA_CFLAGS)
186 CXXFLAGS := $(CXXFLAGS) $(EXTRA_CFLAGS) $(EXTRA_CXXFLAGS)
187 LDFLAGS := $(LDFLAGS) -L$(PREFIX)/lib $(EXTRA_LDFLAGS)
189 ifdef ENABLE_PDB
190 CFLAGS := $(CFLAGS) -gcodeview
191 CXXFLAGS := $(CXXFLAGS) -gcodeview
192 endif
194 # Do not export those! Use HOSTVARS.
196 # Do the FPU detection, after we have figured out our compilers and flags.
197 ifneq ($(findstring $(ARCH),aarch64 i386 ppc ppc64 sparc sparc64 x86_64),)
198 # This should be consistent with include/vlc_cpu.h
199 HAVE_FPU = 1
200 else ifneq ($(findstring $(ARCH),arm),)
201 ifneq ($(call cppcheck, __VFP_FP__)),)
202 ifeq ($(call cppcheck, __SOFTFP__),)
203 HAVE_FPU = 1
204 endif
205 endif
206 else ifneq ($(call cppcheck, __mips_hard_float),)
207 HAVE_FPU = 1
208 endif
210 ACLOCAL_AMFLAGS += -I$(PREFIX)/share/aclocal
211 ifneq ($(wildcard $(VLC_TOOLS)/share/aclocal/*),)
212 ACLOCAL_AMFLAGS += -I$(abspath $(VLC_TOOLS)/share/aclocal)
213 endif
214 export ACLOCAL_AMFLAGS
216 #########
217 # Tools #
218 #########
220 PKG_CONFIG ?= pkg-config
221 ifdef HAVE_CROSS_COMPILE
222 # This inhibits .pc file from within the cross-compilation toolchain sysroot.
223 # Hopefully, nobody ever needs that.
224 PKG_CONFIG_PATH := /usr/share/pkgconfig
225 PKG_CONFIG_LIBDIR := /usr/$(HOST)/lib/pkgconfig
226 export PKG_CONFIG_LIBDIR
227 endif
228 PKG_CONFIG_PATH := $(PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)
229 ifeq ($(findstring mingw32,$(BUILD)),mingw32)
230 PKG_CONFIG_PATH := $(shell cygpath -pm ${PKG_CONFIG_PATH})
231 endif
232 export PKG_CONFIG_PATH
234 ifndef GIT
235 ifeq ($(shell git --version >/dev/null 2>&1 || echo FAIL),)
236 GIT = git
237 endif
238 endif
239 GIT ?= $(error git not found)
241 ifndef SVN
242 ifeq ($(shell svn --version >/dev/null 2>&1 || echo FAIL),)
243 SVN = svn
244 endif
245 endif
246 SVN ?= $(error subversion client (svn) not found)
248 ifeq ($(shell curl --version >/dev/null 2>&1 || echo FAIL),)
249 download = curl -f -L -- "$(1)" > "$@"
250 else ifeq ($(shell wget --version >/dev/null 2>&1 || echo FAIL),)
251 download = (rm -f $@.tmp && \
252 wget --passive -c -p -O $@.tmp "$(1)" && \
253 touch $@.tmp && \
254 mv $@.tmp $@ )
255 else ifeq ($(which fetch >/dev/null 2>&1 || echo FAIL),)
256 download = (rm -f $@.tmp && \
257 fetch -p -o $@.tmp "$(1)" && \
258 touch $@.tmp && \
259 mv $@.tmp $@)
260 else
261 download = $(error Neither curl nor wget found)
262 endif
264 download_pkg = $(call download,$(CONTRIB_VIDEOLAN)/$(2)/$(lastword $(subst /, ,$(@)))) || \
265 ( $(call download,$(1)) && echo "Please upload this package $(lastword $(subst /, ,$(@))) to our FTP" )
267 ifeq ($(shell which xz >/dev/null 2>&1 || echo FAIL),)
268 XZ = xz
269 else
270 XZ ?= $(error XZ (LZMA) compressor not found)
271 endif
273 ifeq ($(shell sha512sum --version >/dev/null 2>&1 || echo FAIL),)
274 SHA512SUM = sha512sum --check
275 else ifeq ($(shell shasum --version >/dev/null 2>&1 || echo FAIL),)
276 SHA512SUM = shasum -a 512 --check
277 else ifeq ($(shell openssl version >/dev/null 2>&1 || echo FAIL),)
278 SHA512SUM = openssl dgst -sha512
279 else
280 SHA512SUM = $(error SHA-512 checksumming not found)
281 endif
283 ifeq ($(shell protoc --version >/dev/null 2>&1 || echo FAIL),)
284 PROTOC = protoc
285 else
286 PROTOC ?= $(error Protobuf compiler (protoc) not found)
287 endif
290 # Common helpers
292 HOSTCONF := --prefix="$(PREFIX)"
293 HOSTCONF += --datarootdir="$(PREFIX)/share"
294 HOSTCONF += --includedir="$(PREFIX)/include"
295 HOSTCONF += --libdir="$(PREFIX)/lib"
296 HOSTCONF += --build="$(BUILD)" --host="$(HOST)" --target="$(HOST)"
297 HOSTCONF += --program-prefix=""
298 # libtool stuff:
299 HOSTCONF += --enable-static --disable-shared --disable-dependency-tracking
300 ifdef HAVE_WIN32
301 HOSTCONF += --without-pic
302 PIC :=
303 else
304 HOSTCONF += --with-pic
305 PIC := -fPIC
306 endif
308 # For cross-compilation with meson, do not set compiler and flags
309 # in HOSTVARS as meson will always use them for the BUILD machine compiler!
310 MESON_HOST_FLAGS := \
311 CPPFLAGS="$(CPPFLAGS)" \
312 CFLAGS="$(CFLAGS)" \
313 CXXFLAGS="$(CXXFLAGS)" \
314 LDFLAGS="$(LDFLAGS)"
315 ifdef HAVE_CROSS_COMPILE
316 HOSTVARS_MESON := PATH="$(PREFIX)/bin:$(PATH)"
317 else
318 HOSTVARS_MESON := $(HOSTTOOLS) $(MESON_HOST_FLAGS)
319 endif
321 # Add these flags after Meson consumed the CFLAGS/CXXFLAGS
322 ifndef WITH_OPTIMIZATION
323 CFLAGS := $(CFLAGS) -g -O0
324 CXXFLAGS := $(CXXFLAGS) -g -O0
325 else
326 CFLAGS := $(CFLAGS) -g -O2
327 CXXFLAGS := $(CXXFLAGS) -g -O2
328 endif
330 HOSTTOOLS := \
331 CC="$(CC)" CXX="$(CXX)" LD="$(LD)" \
332 AR="$(AR)" CCAS="$(CCAS)" RANLIB="$(RANLIB)" STRIP="$(STRIP)" \
333 PATH="$(PREFIX)/bin:$(PATH)"
334 HOSTVARS := $(HOSTTOOLS) \
335 CPPFLAGS="$(CPPFLAGS)" \
336 CFLAGS="$(CFLAGS)" \
337 CXXFLAGS="$(CXXFLAGS)" \
338 LDFLAGS="$(LDFLAGS)"
339 HOSTVARS_PIC := $(HOSTTOOLS) \
340 CPPFLAGS="$(CPPFLAGS) $(PIC)" \
341 CFLAGS="$(CFLAGS) $(PIC)" \
342 CXXFLAGS="$(CXXFLAGS) $(PIC)" \
343 LDFLAGS="$(LDFLAGS)"
345 download_git = \
346 rm -Rf -- "$(@:.tar.xz=)" && \
347 $(GIT) init --bare "$(@:.tar.xz=)" && \
348 (cd "$(@:.tar.xz=)" && \
349 $(GIT) remote add origin "$(1)" && \
350 $(GIT) fetch origin "$(2)") && \
351 (cd "$(@:.tar.xz=)" && \
352 $(GIT) archive --prefix="$(notdir $(@:.tar.xz=))/" \
353 --format=tar "$(3)") > "$(@:.xz=)" && \
354 echo "$(3) $(@)" > "$(@:.tar.xz=.githash)" && \
355 rm -Rf -- "$(@:.tar.xz=)" && \
356 $(XZ) --stdout "$(@:.xz=)" > "$@.tmp" && \
357 rm -f "$(@:.xz=)" && \
358 mv -f -- "$@.tmp" "$@"
359 check_githash = \
360 h=`sed -e "s,^\([0-9a-fA-F]\{40\}\) .*/$(notdir $<),\1,g" \
361 < "$(<:.tar.xz=.githash)"` && \
362 test "$$h" = "$1"
364 checksum = \
365 $(foreach f,$(filter $(TARBALLS)/%,$^), \
366 grep -- " $(f:$(TARBALLS)/%=%)$$" \
367 "$(SRC)/$(patsubst .sum-%,%,$@)/$(2)SUMS" &&) \
368 (cd $(TARBALLS) && $(1) /dev/stdin) < \
369 "$(SRC)/$(patsubst .sum-%,%,$@)/$(2)SUMS"
370 CHECK_SHA512 = $(call checksum,$(SHA512SUM),SHA512)
371 UNPACK = $(RM) -R $@ \
372 $(foreach f,$(filter %.tar.gz %.tgz,$^), && tar xvzfo $(f)) \
373 $(foreach f,$(filter %.tar.bz2,$^), && tar xvjfo $(f)) \
374 $(foreach f,$(filter %.tar.xz,$^), && tar xvJfo $(f)) \
375 $(foreach f,$(filter %.zip,$^), && unzip $(f))
376 UNPACK_DIR = $(patsubst %.tar,%,$(basename $(notdir $<)))
377 APPLY = (cd $(UNPACK_DIR) && patch -fp1) <
378 pkg_static = (cd $(UNPACK_DIR) && $(SRC_BUILT)/pkg-static.sh $(1))
379 MOVE = mv $(UNPACK_DIR) $@ && touch $@
381 AUTOMAKE_DATA_DIRS=$(foreach n,$(foreach n,$(subst :, ,$(shell echo $$PATH)),$(abspath $(n)/../share)),$(wildcard $(n)/automake*))
382 UPDATE_AUTOCONFIG = for dir in $(AUTOMAKE_DATA_DIRS); do \
383 if test -f "$${dir}/config.sub" -a -f "$${dir}/config.guess"; then \
384 cp "$${dir}/config.sub" "$${dir}/config.guess" $(UNPACK_DIR); \
385 break; \
386 fi; \
387 done
389 ifdef HAVE_DARWIN_OS
390 AUTORECONF = AUTOPOINT=true autoreconf
391 else
392 AUTORECONF = autoreconf
393 endif
394 RECONF = mkdir -p -- $(PREFIX)/share/aclocal && \
395 cd $< && $(AUTORECONF) -fiv $(ACLOCAL_AMFLAGS)
396 CMAKE = cmake . -DCMAKE_TOOLCHAIN_FILE=$(abspath toolchain.cmake) \
397 -DCMAKE_INSTALL_PREFIX=$(PREFIX) $(CMAKE_GENERATOR) -DCMAKE_DEBUG_POSTFIX:STRING=
398 ifdef MSYS_BUILD
399 CMAKE += -DCMAKE_LINK_LIBRARY_SUFFIX:STRING=.a
400 endif
402 ifeq ($(V),1)
403 CMAKE += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
404 endif
406 MESON = meson --default-library static --prefix "$(PREFIX)" --backend ninja \
407 -Dlibdir=lib
408 ifndef WITH_OPTIMIZATION
409 MESON += --buildtype debug
410 else
411 MESON += --buildtype release
412 endif
414 ifdef HAVE_CROSS_COMPILE
415 MESON += --cross-file $(abspath crossfile.meson)
416 endif
418 ifdef GPL
419 REQUIRE_GPL =
420 else
421 REQUIRE_GPL = @echo "Package \"$<\" requires the GPL license." >&2; exit 1
422 endif
423 ifdef GNUV3
424 REQUIRE_GNUV3 =
425 else
426 REQUIRE_GNUV3 = \
427 @echo "Package \"$<\" requires the version 3 of GNU licenses." >&2; \
428 exit 1
429 endif
432 # Per-package build rules
434 PKGS_FOUND :=
435 include $(SRC)/*/rules.mak
437 ifeq ($(PKGS_DISABLE), all)
438 PKGS :=
439 endif
441 # Targets
443 ifneq ($(filter $(PKGS_DISABLE),$(PKGS_ENABLE)),)
444 $(error Same package(s) disabled and enabled at the same time)
445 endif
446 # Apply automatic selection (= remove distro packages):
447 PKGS_AUTOMATIC := $(filter-out $(PKGS_FOUND),$(PKGS))
448 # Apply manual selection (from bootstrap):
449 PKGS_MANUAL := $(sort $(PKGS_ENABLE) $(filter-out $(PKGS_DISABLE),$(PKGS_AUTOMATIC)))
450 # Resolve dependencies:
451 PKGS_DEPS := $(filter-out $(PKGS_FOUND) $(PKGS_MANUAL),$(sort $(foreach p,$(PKGS_MANUAL),$(DEPS_$(p)))))
452 PKGS := $(sort $(PKGS_MANUAL) $(PKGS_DEPS))
454 fetch: $(PKGS:%=.sum-%)
455 fetch-all: $(PKGS_ALL:%=.sum-%)
456 install: $(PKGS:%=.%)
458 mostlyclean:
459 -$(RM) $(foreach p,$(PKGS_ALL),.$(p) .sum-$(p) .dep-$(p))
460 -$(RM) toolchain.cmake
461 -$(RM) crossfile.meson
462 -$(RM) -R "$(PREFIX)"
463 -$(RM) -R "$(BUILDBINDIR)"
464 -$(RM) -R */
466 clean: mostlyclean
467 -$(RM) $(TARBALLS)/*.*
469 distclean: clean
470 $(RM) config.mak
471 unlink Makefile
473 PREBUILT_URL=http://download.videolan.org/pub/videolan/contrib/$(HOST)/vlc-contrib-$(HOST)-latest.tar.bz2
475 vlc-contrib-$(HOST)-latest.tar.bz2:
476 $(call download,$(PREBUILT_URL))
478 prebuilt: vlc-contrib-$(HOST)-latest.tar.bz2
479 $(RM) -r $(PREFIX)
480 -$(UNPACK)
481 mv $(HOST) $(TOPDST)
482 cd $(PREFIX) && $(SRC)/change_prefix.sh
483 ifdef HAVE_WIN32
484 ifndef HAVE_CROSS_COMPILE
485 $(RM) `find $(PREFIX)/bin | file -f- | grep ELF | awk -F: '{print $$1}' | xargs`
486 endif
487 endif
489 package: install
490 rm -Rf tmp/
491 mkdir -p tmp/
492 cp -R $(PREFIX) tmp/
493 # remove useless files
494 cd tmp/$(notdir $(PREFIX)); \
495 cd share; rm -Rf man doc gtk-doc info lua projectM; cd ..; \
496 rm -Rf man sbin etc lib/lua lib/sidplay
497 cd tmp/$(notdir $(PREFIX)) && $(abspath $(SRC))/change_prefix.sh $(PREFIX) @@CONTRIB_PREFIX@@
498 (cd tmp && tar c $(notdir $(PREFIX))/) | bzip2 -c > ../vlc-contrib-$(HOST)-$(DATE).tar.bz2
500 list:
501 @echo All packages:
502 @echo ' $(PKGS_ALL)' | tr " " "\n" | sort | tr "\n" " " |fmt
503 @echo Distribution-provided packages:
504 @echo ' $(PKGS_FOUND)' | tr " " "\n" | sort | tr "\n" " " |fmt
505 @echo Automatically selected packages:
506 @echo ' $(PKGS_AUTOMATIC)' | tr " " "\n" | sort | tr "\n" " " |fmt
507 @echo Manually deselected packages:
508 @echo ' $(PKGS_DISABLE)' | tr " " "\n" | sort | tr "\n" " " |fmt
509 @echo Manually selected packages:
510 @echo ' $(PKGS_ENABLE)' | tr " " "\n" | sort | tr "\n" " " |fmt
511 @echo Depended-on packages:
512 @echo ' $(PKGS_DEPS)' | tr " " "\n" | sort | tr "\n" " " |fmt
513 @echo To-be-built packages:
514 @echo ' $(PKGS)' | tr " " "\n" | sort | tr "\n" " " |fmt
516 help:
517 @cat $(SRC)/help.txt
519 .PHONY: all fetch fetch-all install mostlyclean clean distclean package list help prebuilt
521 CMAKE_SYSTEM_NAME =
522 ifdef HAVE_WIN32
523 CMAKE_SYSTEM_NAME = Windows
524 ifdef HAVE_VISUALSTUDIO
525 ifdef HAVE_WINSTORE
526 CMAKE_SYSTEM_NAME = WindowsStore
527 endif
528 ifdef HAVE_WINDOWSPHONE
529 CMAKE_SYSTEM_NAME = WindowsPhone
530 endif
531 endif
532 endif
533 ifdef HAVE_DARWIN_OS
534 CMAKE_SYSTEM_NAME = Darwin
535 endif
537 # CMake toolchain
538 toolchain.cmake:
539 $(RM) $@
540 ifndef WITH_OPTIMIZATION
541 echo "set(CMAKE_BUILD_TYPE Debug)" >> $@
542 else
543 echo "set(CMAKE_BUILD_TYPE Release)" >> $@
544 endif
545 echo "set(CMAKE_SYSTEM_PROCESSOR $(ARCH))" >> $@
546 if test -n "$(CMAKE_SYSTEM_NAME)"; then \
547 echo "set(CMAKE_SYSTEM_NAME $(CMAKE_SYSTEM_NAME))" >> $@; \
549 ifdef HAVE_WIN32
550 ifdef HAVE_CROSS_COMPILE
551 echo "set(CMAKE_RC_COMPILER $(WINDRES))" >> $@
552 endif
553 endif
554 ifdef HAVE_DARWIN_OS
555 echo "set(CMAKE_C_FLAGS \"$(CFLAGS)\")" >> $@
556 echo "set(CMAKE_CXX_FLAGS \"$(CXXFLAGS)\")" >> $@
557 echo "set(CMAKE_LD_FLAGS \"$(LDFLAGS)\")" >> $@
558 echo "set(CMAKE_AR ar CACHE FILEPATH \"Archiver\")" >> $@
559 ifdef HAVE_IOS
560 echo "set(CMAKE_OSX_SYSROOT $(IOS_SDK))" >> $@
561 else
562 echo "set(CMAKE_OSX_SYSROOT $(MACOSX_SDK))" >> $@
563 endif
564 else
565 echo "set(CMAKE_AR $(AR) CACHE FILEPATH \"Archiver\")" >> $@
566 endif
567 ifdef HAVE_CROSS_COMPILE
568 echo "set(_CMAKE_TOOLCHAIN_PREFIX $(HOST)-)" >> $@
569 ifdef HAVE_ANDROID
570 # cmake will overwrite our --sysroot with a native (host) one on Darwin
571 # Set it to "" right away to short-circuit this behaviour
572 echo "set(CMAKE_CXX_SYSROOT_FLAG \"\")" >> $@
573 echo "set(CMAKE_C_SYSROOT_FLAG \"\")" >> $@
574 endif
575 endif
576 echo "set(CMAKE_C_COMPILER $(CC))" >> $@
577 echo "set(CMAKE_CXX_COMPILER $(CXX))" >> $@
578 ifdef MSYS_BUILD
579 echo "set(CMAKE_FIND_ROOT_PATH `cygpath -m $(PREFIX)`)" >> $@
580 else
581 echo "set(CMAKE_FIND_ROOT_PATH $(PREFIX))" >> $@
582 endif
583 echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> $@
584 ifdef HAVE_CROSS_COMPILE
585 echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> $@
586 echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> $@
587 echo "set(PKG_CONFIG_EXECUTABLE $(PKG_CONFIG))" >> $@
588 endif
590 MESON_SYSTEM_NAME =
591 ifdef HAVE_WIN32
592 MESON_SYSTEM_NAME = windows
593 else
594 ifdef HAVE_DARWIN_OS
595 MESON_SYSTEM_NAME = darwin
596 else
597 ifdef HAVE_LINUX
598 # android has also system = linux and defines HAVE_LINUX
599 MESON_SYSTEM_NAME = linux
600 endif
601 endif
602 endif
604 crossfile.meson: $(SRC)/gen-meson-crossfile.py
605 $(HOSTTOOLS) \
606 $(MESON_HOST_FLAGS) \
607 WINDRES="$(WINDRES)" \
608 PKG_CONFIG="$(PKG_CONFIG)" \
609 HOST_SYSTEM="$(MESON_SYSTEM_NAME)" \
610 HOST_ARCH="$(subst i386,x86,$(ARCH))" \
611 HOST="$(HOST)" \
612 $(SRC)/gen-meson-crossfile.py $@
613 cat $@
615 # Default pattern rules
616 .sum-%: $(SRC)/%/SHA512SUMS
617 $(CHECK_SHA512)
618 touch $@
620 .sum-%:
621 $(error Download and check target not defined for $*)
623 # Dummy dependency on found packages
624 $(patsubst %,.dep-%,$(PKGS_FOUND)): .dep-%:
625 touch $@
627 # Real dependency on missing packages
628 $(patsubst %,.dep-%,$(filter-out $(PKGS_FOUND),$(PKGS_ALL))): .dep-%: .%
629 touch -r $< $@
631 .SECONDEXPANSION:
633 # Dependency propagation (convert 'DEPS_foo = bar' to '.foo: .bar')
634 $(foreach p,$(PKGS_ALL),.$(p)): .%: $$(foreach d,$$(DEPS_$$*),.dep-$$(d))
636 .DELETE_ON_ERROR: