mirror of
https://github.com/raspberrypi/userland.git
synced 2025-12-06 04:49:12 +00:00
Initial import of userland code
This commit is contained in:
123
makefiles/cmake/arm-linux.cmake
Normal file
123
makefiles/cmake/arm-linux.cmake
Normal file
@@ -0,0 +1,123 @@
|
||||
# setup environment for cross compile to arm-linux
|
||||
|
||||
if (DEFINED CMAKE_TOOLCHAIN_FILE)
|
||||
else()
|
||||
message(FATAL_ERROR
|
||||
" *********************************************************\n"
|
||||
" * CMAKE_TOOLCHAIN_FILE not defined *\n"
|
||||
" * Please DELETE the build directory and re-run with: *\n"
|
||||
" * -DCMAKE_TOOLCHAIN_FILE=toolchain_file.cmake *\n"
|
||||
" * *\n"
|
||||
" * Toolchain files are in makefiles/cmake/toolchains. *\n"
|
||||
" *********************************************************"
|
||||
)
|
||||
endif()
|
||||
|
||||
# pull in headers for android
|
||||
if(ANDROID)
|
||||
#
|
||||
# work out where android headers and library are
|
||||
#
|
||||
|
||||
set(ANDROID_NDK_ROOT $ENV{ANDROID_NDK_ROOT} CACHE INTERNAL "" FORCE)
|
||||
set(ANDROID_LIBS $ENV{ANDROID_LIBS} CACHE INTERNAL "" FORCE)
|
||||
set(ANDROID_BIONIC $ENV{ANDROID_BIONIC} CACHE INTERNAL "" FORCE)
|
||||
set(ANDROID_LDSCRIPTS $ENV{ANDROID_LDSCRIPTS} CACHE INTERNAL "" FORCE)
|
||||
|
||||
if("${ANDROID_NDK_ROOT}" STREQUAL "")
|
||||
find_program(ANDROID_COMPILER arm-eabi-gcc)
|
||||
get_filename_component(ANDROID_BIN ${ANDROID_COMPILER} PATH CACHE)
|
||||
find_path(_ANDROID_ROOT Makefile PATHS ${ANDROID_BIN}
|
||||
PATH_SUFFIXES ../../../../..
|
||||
NO_DEFAULT_PATH)
|
||||
if("${_ANDROID_ROOT}" STREQUAL "_ANDROID_ROOT-NOTFOUND")
|
||||
set(_ANDROID_ROOT "" CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
if("${_ANDROID_ROOT}" STREQUAL "")
|
||||
message(FATAL_ERROR "Cannot find android root directory")
|
||||
endif()
|
||||
get_filename_component(ANDROID_ROOT ${_ANDROID_ROOT} ABSOLUTE CACHE)
|
||||
#
|
||||
# top level of cross-compiler target include and lib directory structure
|
||||
#
|
||||
set(ANDROID_NDK_ROOT
|
||||
"${ANDROID_ROOT}/prebuilt/ndk" CACHE INTERNAL "" FORCE)
|
||||
set(ANDROID_BIONIC
|
||||
"${ANDROID_ROOT}/bionic" CACHE INTERNAL "" FORCE)
|
||||
set(ANDROID_LDSCRIPTS
|
||||
"${ANDROID_ROOT}/build/core" CACHE INTERNAL "" FORCE)
|
||||
set(ANDROID_LIBS
|
||||
"${ANDROID_ROOT}/out/target/product/${ANDROID_PRODUCT}/obj/lib"
|
||||
CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
|
||||
if("${ANDROID_NDK_ROOT}" STREQUAL "")
|
||||
message(FATAL_ERROR "Cannot find Android NDK root directory")
|
||||
endif()
|
||||
if("${ANDROID_BIONIC}" STREQUAL "")
|
||||
message(FATAL_ERROR "Cannot find Android BIONIC directory")
|
||||
endif()
|
||||
if("${ANDROID_LDSCRIPTS}" STREQUAL "")
|
||||
message(FATAL_ERROR "Cannot find Android LD scripts directory")
|
||||
endif()
|
||||
|
||||
set(CMAKE_SYSTEM_PREFIX_PATH "${ANDROID_NDK_ROOT}/android-ndk-r${ANDROID_NDK_RELEASE}/platforms/android-${ANDROID_NDK_PLATFORM}/arch-${CMAKE_SYSTEM_PROCESSOR}/usr")
|
||||
|
||||
if("${ANDROID_LIBS}" STREQUAL "")
|
||||
set(ANDROID_LIBS "${CMAKE_SYSTEM_PREFIX_PATH}/lib"
|
||||
CACHE INTERNAL "" FORCE)
|
||||
# message(FATAL_ERROR "Cannot find android libraries")
|
||||
endif()
|
||||
|
||||
#
|
||||
# add include directories for pthreads
|
||||
#
|
||||
include_directories("${CMAKE_SYSTEM_PREFIX_PATH}/include" BEFORE SYSTEM)
|
||||
include_directories("${ANDROID_BIONIC}/libc/include" BEFORE SYSTEM)
|
||||
include_directories("${ANDROID_BIONIC}/libc/include/arch-arm/include" BEFORE SYSTEM)
|
||||
include_directories("${ANDROID_BIONIC}/libc/kernel/arch-arm" BEFORE SYSTEM)
|
||||
include_directories("${ANDROID_BIONIC}/libc/kernel/common" BEFORE SYSTEM)
|
||||
include_directories("${ANDROID_BIONIC}/libm/include" BEFORE SYSTEM)
|
||||
include_directories("${ANDROID_BIONIC}/libm/include/arch/arm" BEFORE SYSTEM)
|
||||
include_directories("${ANDROID_BIONIC}/libstdc++/include" BEFORE SYSTEM)
|
||||
|
||||
|
||||
#
|
||||
# Pull in Android link options manually
|
||||
#
|
||||
set(ANDROID_CRTBEGIN "${ANDROID_LIBS}/crtbegin_dynamic.o")
|
||||
set(ANDROID_CRTEND "${ANDROID_LIBS}/crtend_android.o")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-nostdlib ${ANDROID_CRTBEGIN} -Wl,-Bdynamic -Wl,-T${ANDROID_LDSCRIPTS}/armelf.x")
|
||||
|
||||
link_directories(${ANDROID_LIBS})
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-nostdlib ${ANDROID_CRTBEGIN} -nostdlib -Wl,-z,noexecstack")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-dynamic-linker,/system/bin/linker -Wl,-rpath,${CMAKE_INSTALL_PREFIX}/lib")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-T${ANDROID_LDSCRIPTS}/armelf.x -Wl,--gc-sections")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,nocopyreloc -Wl,-z,noexecstack -Wl,--fix-cortex-a8 -Wl,--no-undefined")
|
||||
|
||||
set(CMAKE_C_STANDARD_LIBRARIES "-llog -lc -lgcc ${ANDROID_CRTEND}" CACHE INTERNAL "" FORCE)
|
||||
|
||||
set(SHARED "")
|
||||
else()
|
||||
set(SHARED "SHARED")
|
||||
endif()
|
||||
|
||||
|
||||
# All linux systems have sbrk()
|
||||
add_definitions(-D_HAVE_SBRK)
|
||||
|
||||
# pull in declarations of lseek64 and friends
|
||||
add_definitions(-D_LARGEFILE64_SOURCE)
|
||||
|
||||
# test for glibc malloc debugging extensions
|
||||
try_compile(HAVE_MTRACE
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/makefiles/cmake/srcs/test-mtrace.c
|
||||
OUTPUT_VARIABLE foo)
|
||||
|
||||
add_definitions(-DHAVE_CMAKE_CONFIG)
|
||||
configure_file (
|
||||
"makefiles/cmake/cmake_config.h.in"
|
||||
"${PROJECT_BINARY_DIR}/cmake_config.h"
|
||||
)
|
||||
|
||||
12
makefiles/cmake/cmake_config.h.in
Normal file
12
makefiles/cmake/cmake_config.h.in
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef CMAKE_CONFIG_H
|
||||
#define CMAKE_CONFIG_H
|
||||
|
||||
/*
|
||||
* Autogenerated by cmake from makefiles/cmake/cmake_config.h.in
|
||||
*/
|
||||
|
||||
/** Do we have support for GLIBC mtrace() ? */
|
||||
#cmakedefine HAVE_MTRACE
|
||||
|
||||
#endif
|
||||
|
||||
83
makefiles/cmake/global_settings.cmake
Normal file
83
makefiles/cmake/global_settings.cmake
Normal file
@@ -0,0 +1,83 @@
|
||||
# Run this file only once per cmake run. This is so that
|
||||
# users projects can override those global settings before
|
||||
# parsing subdirectories (which can also include this file
|
||||
# directly so that they can be built as standalone projects).
|
||||
if (DEFINED GLOBAL_SETTINGS_SET)
|
||||
return ()
|
||||
endif ()
|
||||
set (GLOBAL_SETTINGS_SET "TRUE")
|
||||
|
||||
if (NOT DEFINED VIDEOCORE_ROOT)
|
||||
message (FATAL_ERROR
|
||||
" **************************************************\n"
|
||||
" * Variable VIDEOCORE_ROOT is not defined. please *\n"
|
||||
" * define it before including this cmake file. *\n"
|
||||
" * this variable has to be set to the *absolute* *\n"
|
||||
" * path to the top of the videocore source tree *\n"
|
||||
" **************************************************\n"
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (NOT IS_ABSOLUTE "${VIDEOCORE_ROOT}")
|
||||
message (FATAL_ERROR
|
||||
" **************************************************\n"
|
||||
" * Variable VIDEOCORE_ROOT doesn't contain *\n"
|
||||
" * absolute path *\n"
|
||||
" **************************************************\n"
|
||||
)
|
||||
endif ()
|
||||
|
||||
set (VIDEOCORE_RTOSES threadx none win32 pthreads nucleus)
|
||||
foreach (possible_rtos ${VIDEOCORE_RTOSES})
|
||||
set (VIDEOCORE_RTOSES_STR "${possible_rtos}, ${VIDEOCORE_RTOSES_STR}")
|
||||
set (VIDEOCORE_RTOSES_RE "${VIDEOCORE_RTOSES_RE}|(${possible_rtos})")
|
||||
endforeach ()
|
||||
|
||||
if (NOT DEFINED RTOS)
|
||||
# Guess which OS we are on to maintain backwards compatibility
|
||||
if (WIN32)
|
||||
set (RTOS win32)
|
||||
else ()
|
||||
set (RTOS pthreads)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT ${RTOS} MATCHES ${VIDEOCORE_RTOSES_RE})
|
||||
message (FATAL_ERROR
|
||||
" **************************************************\n"
|
||||
" * RTOS incorrectly defined. Please define it *\n"
|
||||
" * correctly and rerun cmake (possibly after *\n"
|
||||
" * removing files from this run). *\n"
|
||||
" * Possible options are: ${VIDEOCORE_RTOSES_STR}\n"
|
||||
" **************************************************\n"
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (NOT DEFINED VIDEOCORE_BUILD_DIR)
|
||||
set (VIDEOCORE_BUILD_DIR "${VIDEOCORE_ROOT}/build")
|
||||
endif ()
|
||||
set (VIDEOCORE_ARCHIVE_BUILD_DIR "${VIDEOCORE_BUILD_DIR}/lib")
|
||||
set (VIDEOCORE_HEADERS_BUILD_DIR "${VIDEOCORE_BUILD_DIR}/inc")
|
||||
set (VIDEOCORE_RUNTIME_BUILD_DIR "${VIDEOCORE_BUILD_DIR}/bin")
|
||||
if (VIDEOCORE_ALL_RUNTIMES_AND_LIBRARIES_IN_SAME_DIRECTORY)
|
||||
# this is useful on windows to avoid problems with dlls not being found at
|
||||
# runtime...
|
||||
set (VIDEOCORE_LIBRARY_BUILD_DIR "${VIDEOCORE_BUILD_DIR}/bin")
|
||||
set (VIDEOCORE_TESTAPP_BUILD_DIR "${VIDEOCORE_BUILD_DIR}/bin")
|
||||
else ()
|
||||
set (VIDEOCORE_LIBRARY_BUILD_DIR "${VIDEOCORE_BUILD_DIR}/lib")
|
||||
set (VIDEOCORE_TESTAPP_BUILD_DIR "${VIDEOCORE_BUILD_DIR}/test")
|
||||
endif ()
|
||||
|
||||
set (VCOS_HEADERS_BUILD_DIR "${VIDEOCORE_HEADERS_BUILD_DIR}/interface/vcos")
|
||||
|
||||
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${VIDEOCORE_ARCHIVE_BUILD_DIR}")
|
||||
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${VIDEOCORE_LIBRARY_BUILD_DIR}")
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${VIDEOCORE_RUNTIME_BUILD_DIR}")
|
||||
|
||||
include_directories ("${VIDEOCORE_HEADERS_BUILD_DIR}")
|
||||
|
||||
function (add_testapp_subdirectory name)
|
||||
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${VIDEOCORE_TESTAPP_BUILD_DIR}")
|
||||
add_subdirectory (${name})
|
||||
endfunction ()
|
||||
35
makefiles/cmake/srcs/test-mtrace.c
Normal file
35
makefiles/cmake/srcs/test-mtrace.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
Copyright (c) 2012, Broadcom Europe Ltd
|
||||
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 the copyright holder 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 THE COPYRIGHT HOLDER 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.
|
||||
*/
|
||||
|
||||
#include <mcheck.h>
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
mtrace();
|
||||
muntrace();
|
||||
}
|
||||
|
||||
5
makefiles/cmake/srcs/vmcs.conf.in
Normal file
5
makefiles/cmake/srcs/vmcs.conf.in
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
# dropped into ld.so.conf.d to setup shared library path
|
||||
${CMAKE_INSTALL_PREFIX}/lib
|
||||
|
||||
|
||||
22
makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake
Normal file
22
makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
#
|
||||
# CMake defines to cross-compile to ARM/Linux on BCM2708 using glibc.
|
||||
#
|
||||
|
||||
SET(CMAKE_SYSTEM_NAME Linux)
|
||||
SET(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
|
||||
SET(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
|
||||
SET(CMAKE_ASM_COMPILER arm-linux-gnueabihf-as)
|
||||
SET(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
|
||||
#ADD_DEFINITIONS("-march=armv6")
|
||||
add_definitions("-mcpu=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard")
|
||||
|
||||
# rdynamic means the backtrace should work
|
||||
IF (CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
add_definitions(-rdynamic)
|
||||
ENDIF()
|
||||
|
||||
# avoids annoying and pointless warnings from gcc
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -U_FORTIFY_SOURCE")
|
||||
|
||||
57
makefiles/cmake/vmcs.cmake
Normal file
57
makefiles/cmake/vmcs.cmake
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
|
||||
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||
SET(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||
SET(CPACK_PACKAGE_VERSION_PATCH "pre-1")
|
||||
|
||||
INCLUDE(CPack)
|
||||
|
||||
# Where shall we install?
|
||||
if (ANDROID)
|
||||
SET(VMCS_INSTALL_PREFIX "/vendor/brcm/islands" CACHE PATH "Prefix prepended to install directories" FORCE)
|
||||
else()
|
||||
SET(VMCS_INSTALL_PREFIX "/opt/vc" CACHE PATH "Prefix prepended to install directories" FORCE)
|
||||
endif()
|
||||
|
||||
SET(CMAKE_INSTALL_PREFIX "${VMCS_INSTALL_PREFIX}" CACHE INTERNAL "Prefix
|
||||
prepended to install directories" FORCE)
|
||||
SET(VMCS_PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_SHARED_LIBRARY_PREFIX}/plugins)
|
||||
|
||||
# What kind of system are we?
|
||||
if (${UNIX})
|
||||
set (VMCS_TARGET linux)
|
||||
elseif (${SYMBIAN})
|
||||
set (VMCS_TARGET symbian)
|
||||
elseif (${WIN32})
|
||||
set (VMCS_TARGET win32)
|
||||
else()
|
||||
message(FATAL_ERROR,"Unknown system type")
|
||||
endif()
|
||||
|
||||
# construct the vmcs config header file
|
||||
add_definitions(-DHAVE_VMCS_CONFIG)
|
||||
configure_file (
|
||||
"${vmcs_root}/host_applications/vmcs/vmcs_config.h.in"
|
||||
"${PROJECT_BINARY_DIR}/vmcs_config.h"
|
||||
)
|
||||
|
||||
# install an ld.so.conf file to pick up our shared libraries
|
||||
configure_file (${vmcs_root}/makefiles/cmake/srcs/vmcs.conf.in
|
||||
${PROJECT_BINARY_DIR}/vmcs.conf)
|
||||
if(NOT DEFINED ANDROID)
|
||||
install(FILES ${PROJECT_BINARY_DIR}/vmcs.conf DESTINATION /etc/ld.so.conf.d)
|
||||
endif()
|
||||
|
||||
# also put it in /opt/vc for access by install script
|
||||
install(FILES ${PROJECT_BINARY_DIR}/vmcs.conf
|
||||
DESTINATION ${VMCS_INSTALL_PREFIX}/share/install)
|
||||
# provide headers the libraries need in /opt/vc too
|
||||
install(DIRECTORY interface/khronos/include
|
||||
DESTINATION ${VMCS_INSTALL_PREFIX})
|
||||
install(DIRECTORY interface/vmcs_host/khronos/IL
|
||||
DESTINATION ${VMCS_INSTALL_PREFIX}/include)
|
||||
# provide an install script
|
||||
install(PROGRAMS ${vmcs_root}/makefiles/cmake/scripts/install_vmcs
|
||||
DESTINATION ${VMCS_INSTALL_PREFIX}/sbin
|
||||
PERMISSIONS OWNER_WRITE WORLD_READ)
|
||||
|
||||
Reference in New Issue
Block a user