lib: media: Allow thumbnails to be cropped
[vlc.git] / contrib / src / main.mak
blob5ad7ff59a86131c708d26bf76cd8c47b39ddfa48
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) -g
186 CXXFLAGS := $(CXXFLAGS) $(EXTRA_CFLAGS) $(EXTRA_CXXFLAGS) -g
187 LDFLAGS := $(LDFLAGS) -L$(PREFIX)/lib $(EXTRA_LDFLAGS)
189 ifdef ENABLE_PDB
190 CFLAGS := $(CFLAGS) -gcodeview
191 CXXFLAGS := $(CXXFLAGS) -gcodeview
192 endif
194 ifndef WITH_OPTIMIZATION
195 CFLAGS := $(CFLAGS) -O0
196 CXXFLAGS := $(CXXFLAGS) -O0
197 else
198 CFLAGS := $(CFLAGS) -O2
199 CXXFLAGS := $(CXXFLAGS) -O2
200 endif
202 # Do not export those! Use HOSTVARS.
204 # Do the FPU detection, after we have figured out our compilers and flags.
205 ifneq ($(findstring $(ARCH),aarch64 i386 ppc ppc64 sparc sparc64 x86_64),)
206 # This should be consistent with include/vlc_cpu.h
207 HAVE_FPU = 1
208 else ifneq ($(findstring $(ARCH),arm),)
209 ifneq ($(call cppcheck, __VFP_FP__)),)
210 ifeq ($(call cppcheck, __SOFTFP__),)
211 HAVE_FPU = 1
212 endif
213 endif
214 else ifneq ($(call cppcheck, __mips_hard_float),)
215 HAVE_FPU = 1
216 endif
218 ACLOCAL_AMFLAGS += -I$(PREFIX)/share/aclocal
219 ifneq ($(wildcard $(VLC_TOOLS)/share/aclocal/*),)
220 ACLOCAL_AMFLAGS += -I$(abspath $(VLC_TOOLS)/share/aclocal)
221 endif
222 export ACLOCAL_AMFLAGS
224 #########
225 # Tools #
226 #########
228 PKG_CONFIG ?= pkg-config
229 ifdef HAVE_CROSS_COMPILE
230 # This inhibits .pc file from within the cross-compilation toolchain sysroot.
231 # Hopefully, nobody ever needs that.
232 PKG_CONFIG_PATH := /usr/share/pkgconfig
233 PKG_CONFIG_LIBDIR := /usr/$(HOST)/lib/pkgconfig
234 export PKG_CONFIG_LIBDIR
235 endif
236 PKG_CONFIG_PATH := $(PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH)
237 ifeq ($(findstring mingw32,$(BUILD)),mingw32)
238 PKG_CONFIG_PATH := $(shell cygpath -pm ${PKG_CONFIG_PATH})
239 endif
240 export PKG_CONFIG_PATH
242 ifndef GIT
243 ifeq ($(shell git --version >/dev/null 2>&1 || echo FAIL),)
244 GIT = git
245 endif
246 endif
247 GIT ?= $(error git not found)
249 ifndef SVN
250 ifeq ($(shell svn --version >/dev/null 2>&1 || echo FAIL),)
251 SVN = svn
252 endif
253 endif
254 SVN ?= $(error subversion client (svn) not found)
256 ifeq ($(shell curl --version >/dev/null 2>&1 || echo FAIL),)
257 download = curl -f -L -- "$(1)" > "$@"
258 else ifeq ($(shell wget --version >/dev/null 2>&1 || echo FAIL),)
259 download = (rm -f $@.tmp && \
260 wget --passive -c -p -O $@.tmp "$(1)" && \
261 touch $@.tmp && \
262 mv $@.tmp $@ )
263 else ifeq ($(which fetch >/dev/null 2>&1 || echo FAIL),)
264 download = (rm -f $@.tmp && \
265 fetch -p -o $@.tmp "$(1)" && \
266 touch $@.tmp && \
267 mv $@.tmp $@)
268 else
269 download = $(error Neither curl nor wget found)
270 endif
272 download_pkg = $(call download,$(CONTRIB_VIDEOLAN)/$(2)/$(lastword $(subst /, ,$(@)))) || \
273 ( $(call download,$(1)) && echo "Please upload this package $(lastword $(subst /, ,$(@))) to our FTP" )
275 ifeq ($(shell which xz >/dev/null 2>&1 || echo FAIL),)
276 XZ = xz
277 else
278 XZ ?= $(error XZ (LZMA) compressor not found)
279 endif
281 ifeq ($(shell sha512sum --version >/dev/null 2>&1 || echo FAIL),)
282 SHA512SUM = sha512sum --check
283 else ifeq ($(shell shasum --version >/dev/null 2>&1 || echo FAIL),)
284 SHA512SUM = shasum -a 512 --check
285 else ifeq ($(shell openssl version >/dev/null 2>&1 || echo FAIL),)
286 SHA512SUM = openssl dgst -sha512
287 else
288 SHA512SUM = $(error SHA-512 checksumming not found)
289 endif
291 ifeq ($(shell protoc --version >/dev/null 2>&1 || echo FAIL),)
292 PROTOC = protoc
293 else
294 PROTOC ?= $(error Protobuf compiler (protoc) not found)
295 endif
298 # Common helpers
300 HOSTCONF := --prefix="$(PREFIX)"
301 HOSTCONF += --datarootdir="$(PREFIX)/share"
302 HOSTCONF += --includedir="$(PREFIX)/include"
303 HOSTCONF += --libdir="$(PREFIX)/lib"
304 HOSTCONF += --build="$(BUILD)" --host="$(HOST)" --target="$(HOST)"
305 HOSTCONF += --program-prefix=""
306 # libtool stuff:
307 HOSTCONF += --enable-static --disable-shared --disable-dependency-tracking
308 ifdef HAVE_WIN32
309 HOSTCONF += --without-pic
310 PIC :=
311 else
312 HOSTCONF += --with-pic
313 PIC := -fPIC
314 endif
316 HOSTTOOLS := \
317 CC="$(CC)" CXX="$(CXX)" LD="$(LD)" \
318 AR="$(AR)" CCAS="$(CCAS)" RANLIB="$(RANLIB)" STRIP="$(STRIP)" \
319 PATH="$(PREFIX)/bin:$(PATH)"
320 HOSTVARS := $(HOSTTOOLS) \
321 CPPFLAGS="$(CPPFLAGS)" \
322 CFLAGS="$(CFLAGS)" \
323 CXXFLAGS="$(CXXFLAGS)" \
324 LDFLAGS="$(LDFLAGS)"
325 HOSTVARS_PIC := $(HOSTTOOLS) \
326 CPPFLAGS="$(CPPFLAGS) $(PIC)" \
327 CFLAGS="$(CFLAGS) $(PIC)" \
328 CXXFLAGS="$(CXXFLAGS) $(PIC)" \
329 LDFLAGS="$(LDFLAGS)"
331 # For cross-compilation with meson, do not set compiler and flags
332 # in HOSTVARS as meson will always use them for the BUILD machine compiler!
333 ifdef HAVE_CROSS_COMPILE
334 HOSTVARS_MESON := PATH="$(PREFIX)/bin:$(PATH)"
335 else
336 HOSTVARS_MESON := $(HOSTVARS)
337 endif
339 download_git = \
340 rm -Rf -- "$(@:.tar.xz=)" && \
341 $(GIT) init --bare "$(@:.tar.xz=)" && \
342 (cd "$(@:.tar.xz=)" && \
343 $(GIT) remote add origin "$(1)" && \
344 $(GIT) fetch origin "$(2)") && \
345 (cd "$(@:.tar.xz=)" && \
346 $(GIT) archive --prefix="$(notdir $(@:.tar.xz=))/" \
347 --format=tar "$(3)") > "$(@:.xz=)" && \
348 echo "$(3) $(@)" > "$(@:.tar.xz=.githash)" && \
349 rm -Rf -- "$(@:.tar.xz=)" && \
350 $(XZ) --stdout "$(@:.xz=)" > "$@.tmp" && \
351 rm -f "$(@:.xz=)" && \
352 mv -f -- "$@.tmp" "$@"
353 check_githash = \
354 h=`sed -e "s,^\([0-9a-fA-F]\{40\}\) .*/$(notdir $<),\1,g" \
355 < "$(<:.tar.xz=.githash)"` && \
356 test "$$h" = "$1"
358 checksum = \
359 $(foreach f,$(filter $(TARBALLS)/%,$^), \
360 grep -- " $(f:$(TARBALLS)/%=%)$$" \
361 "$(SRC)/$(patsubst .sum-%,%,$@)/$(2)SUMS" &&) \
362 (cd $(TARBALLS) && $(1) /dev/stdin) < \
363 "$(SRC)/$(patsubst .sum-%,%,$@)/$(2)SUMS"
364 CHECK_SHA512 = $(call checksum,$(SHA512SUM),SHA512)
365 UNPACK = $(RM) -R $@ \
366 $(foreach f,$(filter %.tar.gz %.tgz,$^), && tar xvzfo $(f)) \
367 $(foreach f,$(filter %.tar.bz2,$^), && tar xvjfo $(f)) \
368 $(foreach f,$(filter %.tar.xz,$^), && tar xvJfo $(f)) \
369 $(foreach f,$(filter %.zip,$^), && unzip $(f))
370 UNPACK_DIR = $(patsubst %.tar,%,$(basename $(notdir $<)))
371 APPLY = (cd $(UNPACK_DIR) && patch -fp1) <
372 pkg_static = (cd $(UNPACK_DIR) && $(SRC_BUILT)/pkg-static.sh $(1))
373 MOVE = mv $(UNPACK_DIR) $@ && touch $@
375 AUTOMAKE_DATA_DIRS=$(foreach n,$(foreach n,$(subst :, ,$(shell echo $$PATH)),$(abspath $(n)/../share)),$(wildcard $(n)/automake*))
376 UPDATE_AUTOCONFIG = for dir in $(AUTOMAKE_DATA_DIRS); do \
377 if test -f "$${dir}/config.sub" -a -f "$${dir}/config.guess"; then \
378 cp "$${dir}/config.sub" "$${dir}/config.guess" $(UNPACK_DIR); \
379 break; \
380 fi; \
381 done
383 ifdef HAVE_DARWIN_OS
384 AUTORECONF = AUTOPOINT=true autoreconf
385 else
386 AUTORECONF = autoreconf
387 endif
388 RECONF = mkdir -p -- $(PREFIX)/share/aclocal && \
389 cd $< && $(AUTORECONF) -fiv $(ACLOCAL_AMFLAGS)
390 CMAKE = cmake . -DCMAKE_TOOLCHAIN_FILE=$(abspath toolchain.cmake) \
391 -DCMAKE_INSTALL_PREFIX=$(PREFIX) $(CMAKE_GENERATOR) -DCMAKE_DEBUG_POSTFIX:STRING=
392 ifdef MSYS_BUILD
393 CMAKE += -DCMAKE_LINK_LIBRARY_SUFFIX:STRING=.a
394 endif
396 ifeq ($(V),1)
397 CMAKE += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
398 endif
400 MESON = meson --default-library static --prefix "$(PREFIX)" --backend ninja \
401 -Dlibdir=lib
402 ifndef WITH_OPTIMIZATION
403 MESON += --buildtype debug
404 else
405 MESON += --buildtype release
406 endif
408 ifdef HAVE_CROSS_COMPILE
409 MESON += --cross-file $(abspath crossfile.meson)
410 endif
412 ifdef GPL
413 REQUIRE_GPL =
414 else
415 REQUIRE_GPL = @echo "Package \"$<\" requires the GPL license." >&2; exit 1
416 endif
417 ifdef GNUV3
418 REQUIRE_GNUV3 =
419 else
420 REQUIRE_GNUV3 = \
421 @echo "Package \"$<\" requires the version 3 of GNU licenses." >&2; \
422 exit 1
423 endif
426 # Per-package build rules
428 PKGS_FOUND :=
429 include $(SRC)/*/rules.mak
431 ifeq ($(PKGS_DISABLE), all)
432 PKGS :=
433 endif
435 # Targets
437 ifneq ($(filter $(PKGS_DISABLE),$(PKGS_ENABLE)),)
438 $(error Same package(s) disabled and enabled at the same time)
439 endif
440 # Apply automatic selection (= remove distro packages):
441 PKGS_AUTOMATIC := $(filter-out $(PKGS_FOUND),$(PKGS))
442 # Apply manual selection (from bootstrap):
443 PKGS_MANUAL := $(sort $(PKGS_ENABLE) $(filter-out $(PKGS_DISABLE),$(PKGS_AUTOMATIC)))
444 # Resolve dependencies:
445 PKGS_DEPS := $(filter-out $(PKGS_FOUND) $(PKGS_MANUAL),$(sort $(foreach p,$(PKGS_MANUAL),$(DEPS_$(p)))))
446 PKGS := $(sort $(PKGS_MANUAL) $(PKGS_DEPS))
448 fetch: $(PKGS:%=.sum-%)
449 fetch-all: $(PKGS_ALL:%=.sum-%)
450 install: $(PKGS:%=.%)
452 mostlyclean:
453 -$(RM) $(foreach p,$(PKGS_ALL),.$(p) .sum-$(p) .dep-$(p))
454 -$(RM) toolchain.cmake
455 -$(RM) crossfile.meson
456 -$(RM) -R "$(PREFIX)"
457 -$(RM) -R "$(BUILDBINDIR)"
458 -$(RM) -R */
460 clean: mostlyclean
461 -$(RM) $(TARBALLS)/*.*
463 distclean: clean
464 $(RM) config.mak
465 unlink Makefile
467 PREBUILT_URL=http://download.videolan.org/pub/videolan/contrib/$(HOST)/vlc-contrib-$(HOST)-latest.tar.bz2
469 vlc-contrib-$(HOST)-latest.tar.bz2:
470 $(call download,$(PREBUILT_URL))
472 prebuilt: vlc-contrib-$(HOST)-latest.tar.bz2
473 $(RM) -r $(PREFIX)
474 -$(UNPACK)
475 mv $(HOST) $(TOPDST)
476 cd $(PREFIX) && $(SRC)/change_prefix.sh
477 ifdef HAVE_WIN32
478 ifndef HAVE_CROSS_COMPILE
479 $(RM) `find $(PREFIX)/bin | file -f- | grep ELF | awk -F: '{print $$1}' | xargs`
480 endif
481 endif
483 package: install
484 rm -Rf tmp/
485 mkdir -p tmp/
486 cp -R $(PREFIX) tmp/
487 # remove useless files
488 cd tmp/$(notdir $(PREFIX)); \
489 cd share; rm -Rf man doc gtk-doc info lua projectM; cd ..; \
490 rm -Rf man sbin etc lib/lua lib/sidplay
491 cd tmp/$(notdir $(PREFIX)) && $(abspath $(SRC))/change_prefix.sh $(PREFIX) @@CONTRIB_PREFIX@@
492 (cd tmp && tar c $(notdir $(PREFIX))/) | bzip2 -c > ../vlc-contrib-$(HOST)-$(DATE).tar.bz2
494 list:
495 @echo All packages:
496 @echo ' $(PKGS_ALL)' | tr " " "\n" | sort | tr "\n" " " |fmt
497 @echo Distribution-provided packages:
498 @echo ' $(PKGS_FOUND)' | tr " " "\n" | sort | tr "\n" " " |fmt
499 @echo Automatically selected packages:
500 @echo ' $(PKGS_AUTOMATIC)' | tr " " "\n" | sort | tr "\n" " " |fmt
501 @echo Manually deselected packages:
502 @echo ' $(PKGS_DISABLE)' | tr " " "\n" | sort | tr "\n" " " |fmt
503 @echo Manually selected packages:
504 @echo ' $(PKGS_ENABLE)' | tr " " "\n" | sort | tr "\n" " " |fmt
505 @echo Depended-on packages:
506 @echo ' $(PKGS_DEPS)' | tr " " "\n" | sort | tr "\n" " " |fmt
507 @echo To-be-built packages:
508 @echo ' $(PKGS)' | tr " " "\n" | sort | tr "\n" " " |fmt
510 help:
511 @cat $(SRC)/help.txt
513 .PHONY: all fetch fetch-all install mostlyclean clean distclean package list help prebuilt
515 CMAKE_SYSTEM_NAME =
516 ifdef HAVE_WIN32
517 CMAKE_SYSTEM_NAME = Windows
518 ifdef HAVE_VISUALSTUDIO
519 ifdef HAVE_WINSTORE
520 CMAKE_SYSTEM_NAME = WindowsStore
521 endif
522 ifdef HAVE_WINDOWSPHONE
523 CMAKE_SYSTEM_NAME = WindowsPhone
524 endif
525 endif
526 endif
527 ifdef HAVE_DARWIN_OS
528 CMAKE_SYSTEM_NAME = Darwin
529 endif
531 # CMake toolchain
532 toolchain.cmake:
533 $(RM) $@
534 ifndef WITH_OPTIMIZATION
535 echo "set(CMAKE_BUILD_TYPE Debug)" >> $@
536 else
537 echo "set(CMAKE_BUILD_TYPE Release)" >> $@
538 endif
539 echo "set(CMAKE_SYSTEM_PROCESSOR $(ARCH))" >> $@
540 if test -n "$(CMAKE_SYSTEM_NAME)"; then \
541 echo "set(CMAKE_SYSTEM_NAME $(CMAKE_SYSTEM_NAME))" >> $@; \
543 ifdef HAVE_WIN32
544 ifdef HAVE_CROSS_COMPILE
545 echo "set(CMAKE_RC_COMPILER $(WINDRES))" >> $@
546 endif
547 endif
548 ifdef HAVE_DARWIN_OS
549 echo "set(CMAKE_C_FLAGS \"$(CFLAGS)\")" >> $@
550 echo "set(CMAKE_CXX_FLAGS \"$(CXXFLAGS)\")" >> $@
551 echo "set(CMAKE_LD_FLAGS \"$(LDFLAGS)\")" >> $@
552 echo "set(CMAKE_AR ar CACHE FILEPATH "Archiver")" >> $@
553 ifdef HAVE_IOS
554 echo "set(CMAKE_OSX_SYSROOT $(IOS_SDK))" >> $@
555 else
556 echo "set(CMAKE_OSX_SYSROOT $(MACOSX_SDK))" >> $@
557 endif
558 else
559 echo "set(CMAKE_AR $(AR) CACHE FILEPATH "Archiver")" >> $@
560 endif
561 ifdef HAVE_CROSS_COMPILE
562 echo "set(_CMAKE_TOOLCHAIN_PREFIX $(HOST)-)" >> $@
563 ifdef HAVE_ANDROID
564 # cmake will overwrite our --sysroot with a native (host) one on Darwin
565 # Set it to "" right away to short-circuit this behaviour
566 echo "set(CMAKE_CXX_SYSROOT_FLAG \"\")" >> $@
567 echo "set(CMAKE_C_SYSROOT_FLAG \"\")" >> $@
568 endif
569 endif
570 echo "set(CMAKE_C_COMPILER $(CC))" >> $@
571 echo "set(CMAKE_CXX_COMPILER $(CXX))" >> $@
572 ifdef MSYS_BUILD
573 echo "set(CMAKE_FIND_ROOT_PATH `cygpath -m $(PREFIX)`)" >> $@
574 else
575 echo "set(CMAKE_FIND_ROOT_PATH $(PREFIX))" >> $@
576 endif
577 echo "set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)" >> $@
578 ifdef HAVE_CROSS_COMPILE
579 echo "set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)" >> $@
580 echo "set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" >> $@
581 echo "set(PKG_CONFIG_EXECUTABLE $(PKG_CONFIG))" >> $@
582 endif
584 MESON_SYSTEM_NAME =
585 ifdef HAVE_WIN32
586 MESON_SYSTEM_NAME = windows
587 else
588 ifdef HAVE_DARWIN_OS
589 MESON_SYSTEM_NAME = darwin
590 else
591 ifdef HAVE_LINUX
592 # android has also system = linux and defines HAVE_LINUX
593 MESON_SYSTEM_NAME = linux
594 endif
595 endif
596 endif
598 crossfile.meson:
599 $(HOSTVARS) \
600 WINDRES="$(WINDRES)" \
601 PKG_CONFIG="$(PKG_CONFIG)" \
602 HOST_SYSTEM="$(MESON_SYSTEM_NAME)" \
603 HOST_ARCH="$(subst i386,x86,$(ARCH))" \
604 HOST="$(HOST)" \
605 $(SRC)/gen-meson-crossfile.py $@
607 # Default pattern rules
608 .sum-%: $(SRC)/%/SHA512SUMS
609 $(CHECK_SHA512)
610 touch $@
612 .sum-%:
613 $(error Download and check target not defined for $*)
615 # Dummy dependency on found packages
616 $(patsubst %,.dep-%,$(PKGS_FOUND)): .dep-%:
617 touch $@
619 # Real dependency on missing packages
620 $(patsubst %,.dep-%,$(filter-out $(PKGS_FOUND),$(PKGS_ALL))): .dep-%: .%
621 touch -r $< $@
623 .SECONDEXPANSION:
625 # Dependency propagation (convert 'DEPS_foo = bar' to '.foo: .bar')
626 $(foreach p,$(PKGS_ALL),.$(p)): .%: $$(foreach d,$$(DEPS_$$*),.dep-$$(d))
628 .DELETE_ON_ERROR: