[vlc-commits] [Git][videolan/vlc][master] 2 commits: contrib: add basic set of build variables for C

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Tue Jan 25 20:20:07 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
fe3a585e by Rémi Denis-Courmont at 2022-01-25T17:58:11+02:00
contrib: add basic set of build variables for C

- - - - -
250e748f by Rémi Denis-Courmont at 2022-01-25T17:58:11+02:00
contrib: luac: use BUILDVARS

Notes:
* $(BUILDVARS) _must_ be passed as Make command line arguments,
  not as environment variables. Otherwise the lua Makefiles will
  override them, e.g.: CC = gcc
* Contrary to the usual conventions, lua Makefiles expect $(AR) to
  convey not only the executable but also the keyletter "cru".

- - - - -


2 changed files:

- contrib/src/lua/rules.mak
- contrib/src/main.mak


Changes:

=====================================
contrib/src/lua/rules.mak
=====================================
@@ -111,17 +111,13 @@ endif
 .sum-luac: .sum-lua
 	touch $@
 
+LUACVARS=AR="$(BUILDAR) cru"
 ifdef HAVE_WIN32
 ifndef HAVE_CROSS_COMPILE
-LUACVARS=CPPFLAGS="-DLUA_DL_DLL"
+LUACVARS+=CPPFLAGS="$(BUILDCPPFLAGS) -DLUA_DL_DLL"
 endif
 endif
 
-ifdef HAVE_CROSS_COMPILE
-# Remove the cross-compiler environment for the native compiler
-LUACVARS+=CFLAGS="" CPPFLAGS="" LDFLAGS=""
-endif
-
 # DO NOT use the same intermediate directory as the lua target
 luac: UNPACK_DIR=luac-$(LUA_VERSION)
 luac: lua-$(LUA_VERSION).tar.gz .sum-luac
@@ -131,7 +127,7 @@ luac: lua-$(LUA_VERSION).tar.gz .sum-luac
 	$(MOVE)
 
 .luac: luac
-	cd $< && $(LUACVARS) $(MAKE) generic
+	cd $< && $(MAKE) $(BUILDVARS) $(LUACVARS) generic
 	mkdir -p -- $(BUILDBINDIR)
 	install -m 0755 -s -- $</src/luac $(BUILDBINDIR)/$(HOST)-luac
 	touch $@


=====================================
contrib/src/main.mak
=====================================
@@ -173,7 +173,39 @@ endif
 endif
 endif
 
-# Do not export those! Use HOSTVARS.
+ifeq ($(shell gcc --version >/dev/null 2>&1 || echo No GCC),)
+BUILDCC ?= gcc
+BUILDCXX ?= g++
+ifeq ($(shell gcc-ar --version >/dev/null 2>&1 || echo Prehistoric GCC),)
+BUILDAR ?= gcc-ar
+BUILDNM ?= gcc-nm
+BUILDRANLIB ?= gcc-ranlib
+endif
+else ifeq ($(shell clang --version >/dev/null 2>&1 || No LLVM/Clang),)
+BUILDCC ?= clang
+BUILDCXX ?= clang++
+ifeq ($(shell llvm-ar --version >/dev/null 2>&1 || echo Prehistoric LLVM),)
+BUILDAR ?= llvm-ar
+BUILDNM ?= llvm-nm
+BUILDRANLIB ?= llvm-ranlib
+BUILDSTRIP ?= llvm-strip
+endif
+endif
+
+BUILDCC ?= cc
+BUILDCXX ?= c++
+BUILDLD ?= $(BUILDCC)
+BUILDAR ?= ar
+BUILDNM ?= nm
+BUILDRANLIB ?= ranlib
+BUILDSTRIP ?= strip
+
+BUILDCPPFLAGS ?=
+BUILDCFLAGS ?= -O2
+BUILDCXXFLAGS ?= $(BUILDCFLAGS)
+BUILDLDFLAGS ?= $(BUILDCFLAGS)
+
+# Do not export variables above! Use HOSTVARS or BUILDVARS.
 
 # Do the FPU detection, after we have figured out our compilers and flags.
 ifneq ($(findstring $(ARCH),aarch64 i386 ppc ppc64 sparc sparc64 x86_64),)
@@ -333,6 +365,30 @@ HOSTVARS_PIC := $(HOSTTOOLS) \
 	CXXFLAGS="$(CXXFLAGS) $(PIC)" \
 	LDFLAGS="$(LDFLAGS)"
 
+BUILDCOMMONCONF := --disable-dependency-tracking
+BUILDCOMMONCONF += --prefix="$(BUILDPREFIX)"
+BUILDCOMMONCONF += --datarootdir="$(BUILDPREFIX)/share"
+BUILDCOMMONCONF += --includedir="$(BUILDPREFIX)/include"
+BUILDCOMMONCONF += --libdir="$(BUILDPREFIX)"
+BUILDCOMMONCONF += --build="$(BUILD)" --host="$(BUILD)"
+# For platform-independent tools (--target should be meaningless):
+BUILDPROGCONF := $(BUILDCOMMONCONF) \
+	--target="$(BUILD)" --program-prefix=""
+# For platform-dependent tools:
+BUILDTOOLCONF := $(BUILDCOMMONCONF) \
+	--target="$(HOST)" --program-prefix="$(HOST)-"
+
+BUILDTOOLS := \
+	CC="$(BUILDCC)" CXX="$(BUILDCXX)" LD="$(BUILDLD)" \
+	AR="$(BUILDAR)" NM="$(BUILDNM)" RANLIB="$(BUILDRANLIB)" \
+	STRIP="$(BUILDSTRIP)" PATH="$(BUILDPREFIX)/bin:$(PATH)"
+
+BUILDVARS := $(BUILDTOOLS) \
+	CPPFLAGS="$(BUILDCPPFLAGS)" \
+	CFLAGS="$(BUILDCFLAGS)" \
+	CXXFLAGS="$(BUILDCXXFLAGS)" \
+	LDFLAGS="$(BUILDLDFLAGS)"
+
 download_git = \
 	rm -Rf -- "$(@:.tar.xz=)" && \
 	$(GIT) init --bare "$(@:.tar.xz=)" && \



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a61b5c7d47a2ae5aba703b2a4dfbd31b3a9322a9...250e748fb71c7a69e399638535efbf012f2b0fb0

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/a61b5c7d47a2ae5aba703b2a4dfbd31b3a9322a9...250e748fb71c7a69e399638535efbf012f2b0fb0
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list