16cd6a6acSopenharmony_ci#!/bin/bash
26cd6a6acSopenharmony_ci
36cd6a6acSopenharmony_cifunction except() {
46cd6a6acSopenharmony_cicase $1 in
56cd6a6acSopenharmony_ci    selinux_file_context_cmp) # ignore
66cd6a6acSopenharmony_ci    ;;
76cd6a6acSopenharmony_ci    *)
86cd6a6acSopenharmony_ciecho "
96cd6a6acSopenharmony_ci%exception $1 {
106cd6a6acSopenharmony_ci  \$action
116cd6a6acSopenharmony_ci  if (result < 0) {
126cd6a6acSopenharmony_ci     PyErr_SetFromErrno(PyExc_OSError);
136cd6a6acSopenharmony_ci     SWIG_fail;
146cd6a6acSopenharmony_ci  }
156cd6a6acSopenharmony_ci}"
166cd6a6acSopenharmony_ci;;
176cd6a6acSopenharmony_ciesac
186cd6a6acSopenharmony_ci}
196cd6a6acSopenharmony_ci
206cd6a6acSopenharmony_ci# Make sure that selinux.h is included first in order not to depend on the order
216cd6a6acSopenharmony_ci# in which "#include <selinux/selinux.h>" appears in other files.
226cd6a6acSopenharmony_ciFILE_LIST=(
236cd6a6acSopenharmony_ci    ../include/selinux/selinux.h
246cd6a6acSopenharmony_ci    ../include/selinux/avc.h
256cd6a6acSopenharmony_ci    ../include/selinux/context.h
266cd6a6acSopenharmony_ci    ../include/selinux/get_context_list.h
276cd6a6acSopenharmony_ci    ../include/selinux/get_default_type.h
286cd6a6acSopenharmony_ci    ../include/selinux/label.h
296cd6a6acSopenharmony_ci    ../include/selinux/restorecon.h
306cd6a6acSopenharmony_ci)
316cd6a6acSopenharmony_ciif ! cat "${FILE_LIST[@]}" | ${CC:-gcc} -x c -c -I../include -o temp.o - -aux-info temp.aux
326cd6a6acSopenharmony_cithen
336cd6a6acSopenharmony_ci    # clang does not support -aux-info so fall back to gcc
346cd6a6acSopenharmony_ci    cat "${FILE_LIST[@]}" | gcc -x c -c -I../include -o temp.o - -aux-info temp.aux
356cd6a6acSopenharmony_cifi
366cd6a6acSopenharmony_cifor i in `awk '/<stdin>.*extern int/ { print $6 }' temp.aux`; do except $i ; done 
376cd6a6acSopenharmony_cirm -f -- temp.aux temp.o
38