Skip to content

Instantly share code, notes, and snippets.

@JohnnyonFlame
Last active September 1, 2022 00:05
Show Gist options
  • Save JohnnyonFlame/a9488ed855fe66e4b790e4f551803e45 to your computer and use it in GitHub Desktop.
Save JohnnyonFlame/a9488ed855fe66e4b790e4f551803e45 to your computer and use it in GitHub Desktop.
Auto-configure fbdev-mali SDL2 backend for the Odroid N2 platform.
#!/bin/bash
# You might want to change DCMAKE_TOOLCHAIN_FILE :)
cmake -B build \
-DCMAKE_TOOLCHAIN_FILE=~/aarch64.cmake \
-DCMAKE_C_FLAGS=-I\ /home/johnny/opengl-meson/include \
-DSDL_STATIC=OFF \
-DSDL_LIBC=ON \
-DSDL_GCC_ATOMICS=ON \
-DSDL_ALTIVEC=OFF \
-DSDL_OSS=OFF \
-DSDL_ALSA=ON \
-DSDL_ALSA_SHARED=ON \
-DSDL_JACK=OFF \
-DSDL_JACK_SHARED=OFF \
-DSDL_ESD=OFF \
-DSDL_ESD_SHARED=OFF \
-DSDL_ARTS=OFF \
-DSDL_ARTS_SHARED=OFF \
-DSDL_NAS=OFF \
-DSDL_NAS_SHARED=OFF \
-DSDL_LIBSAMPLERATE=OFF \
-DSDL_LIBSAMPLERATE_SHARED=OFF \
-DSDL_SNDIO=OFF \
-DSDL_DISKAUDIO=OFF \
-DSDL_DUMMYAUDIO=OFF \
-DSDL_DUMMYVIDEO=OFF \
-DSDL_WAYLAND=OFF \
-DSDL_WAYLAND_QT_TOUCH=ON \
-DSDL_WAYLAND_SHARED=OFF \
-DSDL_COCOA=OFF \
-DSDL_DIRECTFB=OFF \
-DSDL_VIVANTE=OFF \
-DSDL_DIRECTFB_SHARED=OFF \
-DSDL_FUSIONSOUND=OFF \
-DSDL_FUSIONSOUND_SHARED=OFF \
-DSDL_PTHREADS=ON \
-DSDL_PTHREADS_SEM=ON \
-DSDL_DIRECTX=OFF \
-DSDL_CLOCK_GETTIME=OFF \
-DSDL_RPATH=OFF \
-DSDL_RENDER_D3D=OFF \
-DSDL_X11=OFF \
-DSDL_OPENGLES=ON \
-DSDL_VULKAN=OFF \
-DSDL_PULSEAUDIO=ON \
-DSDL_HIDAPI_JOYSTICK=OFF \
-DSDL_MALI=ON \
-DSDL_KMSDRM=OFF \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
# **********************************************************
# Copyright (c) 2014-2017 Google, Inc. All rights reserved.
# **********************************************************
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of Google, Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE, INC. OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
# For cross-compiling on arm64 Linux using gcc-aarch64-linux-gnu package:
# - install AArch64 tool chain:
# $ sudo apt-get install g++-aarch64-linux-gnu
# - cross-compiling config
# $ cmake -DCMAKE_TOOLCHAIN_FILE=../dynamorio/make/toolchain-arm64.cmake ../dynamorio
# You may have to set CMAKE_FIND_ROOT_PATH to point to the target enviroment, e.g.
# by passing -DCMAKE_FIND_ROOT_PATH=/usr/aarch64-linux-gnu on Debian-like systems.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(TARGET_ABI "linux-gnu")
# specify the cross compiler
SET(CMAKE_C_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-gcc)
SET(CMAKE_CXX_COMPILER ${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-g++)
# To build the tests, we need to set where the target environment containing
# the required library is. On Debian-like systems, this is
# /usr/aarch64-linux-gnu.
SET(CMAKE_FIND_ROOT_PATH "/usr/lib/${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}")
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
# SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
# SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# Set additional variables.
# If we don't set some of these, CMake will end up using the host version.
# We want the full path, however, so we can pass EXISTS and other checks in
# the our CMake code.
find_program(GCC_FULL_PATH ${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-gcc)
if (NOT GCC_FULL_PATH)
message(FATAL_ERROR "Cross-compiler ${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-gcc not found")
endif ()
get_filename_component(GCC_DIR ${GCC_FULL_PATH} PATH)
SET(CMAKE_LINKER ${GCC_DIR}/${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-ld CACHE FILEPATH "linker")
SET(CMAKE_ASM_COMPILER ${GCC_DIR}/${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-as CACHE FILEPATH "assembler")
SET(CMAKE_OBJCOPY ${GCC_DIR}/${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-objcopy CACHE FILEPATH "objcopy")
SET(CMAKE_STRIP ${GCC_DIR}/${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-strip CACHE FILEPATH "strip")
SET(CMAKE_CPP ${GCC_DIR}/${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-cpp CACHE FILEPATH "cpp")
set(PKG_CONFIG_EXECUTABLE "/usr/bin/${CMAKE_SYSTEM_PROCESSOR}-${TARGET_ABI}-pkg-config")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment