xref: /aosp_15_r20/external/libbpf/ci/managers/test_compile.sh (revision f7c14bbac8cf49633f2740db462ea43457973ec4)
1*f7c14bbaSAndroid Build Coastguard Worker#!/bin/bash
2*f7c14bbaSAndroid Build Coastguard Workerset -euox pipefail
3*f7c14bbaSAndroid Build Coastguard Worker
4*f7c14bbaSAndroid Build Coastguard WorkerEXTRA_CFLAGS=${EXTRA_CFLAGS:-}
5*f7c14bbaSAndroid Build Coastguard WorkerEXTRA_LDFLAGS=${EXTRA_LDFLAGS:-}
6*f7c14bbaSAndroid Build Coastguard Worker
7*f7c14bbaSAndroid Build Coastguard Workercat << EOF > main.c
8*f7c14bbaSAndroid Build Coastguard Worker#include <bpf/libbpf.h>
9*f7c14bbaSAndroid Build Coastguard Workerint main() {
10*f7c14bbaSAndroid Build Coastguard Worker  return bpf_object__open(0) < 0;
11*f7c14bbaSAndroid Build Coastguard Worker}
12*f7c14bbaSAndroid Build Coastguard WorkerEOF
13*f7c14bbaSAndroid Build Coastguard Worker
14*f7c14bbaSAndroid Build Coastguard Worker# static linking
15*f7c14bbaSAndroid Build Coastguard Worker${CC:-cc} ${EXTRA_CFLAGS} ${EXTRA_LDFLAGS} -o main -I./include/uapi -I./install/usr/include main.c ./build/libbpf.a -lelf -lz
16