其他分享
首页 > 其他分享> > 最新版本libdrm(2.4.109)编译

最新版本libdrm(2.4.109)编译

作者:互联网

drm的atomic操作在老版本的libdrm中没有支持,需要下载最新的libdrm,我这里下载的是libdrm-2.4.109版本

下载链接:https://dri.freedesktop.org/libdrm/

新版本的libdrm不再采用configure && make的方式编译,而是改用meson && ninja编译方式。

meson 与ninja的安装如下:

sudo apt-get install python3 python3-pip ninja-build
pip3 install --user meson

我的编译环境是ubuntu16.04, 可能是版本太老的缘故,安装的ninja版本是1.5,而libdrm-2.4.109需要ninja的版本大于1.8.2,所以只能手动下载编译,如下:

#ninja依赖re2c,需要先安装
apt-get install re2c

#下载ninja
git clone https://github.com/ninja-build/ninja.git

#进入ninja目录,编译
./configure.py --bootstrap
cp ./ninja /usr/bin

我下载的ninja版本为1.10.2.git

安装好meson及ninja之后,进入libdrm-2.4.109目录下,创建如下编译脚本:

#!/bin/bash
set -e
 
if [ -d _build ];then
    rm -r _build
fi
mkdir _build
if [ -d _bin ];then
    rm -r _bin
fi
mkdir _bin

arch='arm-linux-gnueabi-'
prefix_path=`pwd`/_bin
#sys_root='/home/username/build_root/devel'
#创建交叉编译配置文件cross_file.txt
 
#还可设置c_args等等类似 CFLAGS
echo "[constants]" > cross_file.txt
echo "arch = '${arch}'" >> cross_file.txt

echo "[binaries]" >> cross_file.txt
echo "c = arch + 'gcc'" >> cross_file.txt
echo "cpp = arch + 'g++'" >> cross_file.txt
echo "ar = arch + 'ar'" >> cross_file.txt
echo "ld = arch + 'ld'" >> cross_file.txt
echo "srtip = arch + 'strip'" >> cross_file.txt
#e#cho "sys_root = '${sys_root}'" >> cross_file.txt
#echo "pkg_config_libdir = '${sys_root}/usr/lib/pkgconfig'" >> cross_file.txt
 
#编译结果可运行平台的架构
echo "[host_machine]" >> cross_file.txt
echo "system = 'linux'" >> cross_file.txt
echo "cpu_family = 'arm'" >> cross_file.txt
echo "cpu = 'armv7hl'" >> cross_file.txt
echo "endian = 'little'" >> cross_file.txt
 
#类似于configure功能 meson configure 获取到可配置项
echo "[project options]" >> cross_file.txt
#echo "selinux = 'disabled'" >> cross_file.txt
#echo "libelf = 'disabled'" >> cross_file.txt
 
#类似于执行configure
meson setup _build --prefix=${prefix_path} --cross-file cross_file.txt

cd _build
#编译 类似于make
/bin/ninja
#类似于make install, *.h  *.a *.so install to prefix dir
/bin/ninja install
cd ../ 

该脚本主要创建了_build编译目录,和_bin安装目录, 运行该脚本后,相关头文件和库会被安装到_bin目录下。

注意默认编译出来的是动态库, 如果想要编译出静态库的话,需要修改libdrm-2.4.109目录下的meson.build文件, 在其default_options中,增加'default_library=static'选项,这样编译出来的就是静态库libdrm.a了

project(
  'libdrm',
  ['c'],
  version : '2.4.109',
  license : 'MIT',
  meson_version : '>= 0.46',
  default_options : ['buildtype=debugoptimized', 'c_std=gnu99', 'default_library=static'],
)

标签:cross,echo,libdrm,109,file,ninja,txt,2.4
来源: https://blog.csdn.net/M120674/article/details/122540134