1#!/bin/sh 2# 3# Copyright The Mbed TLS Contributors 4# SPDX-License-Identifier: Apache-2.0 5# 6# Licensed under the Apache License, Version 2.0 (the "License"); you may 7# not use this file except in compliance with the License. 8# You may obtain a copy of the License at 9# 10# http://www.apache.org/licenses/LICENSE-2.0 11# 12# Unless required by applicable law or agreed to in writing, software 13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15# See the License for the specific language governing permissions and 16# limitations under the License. 17 18set -eu 19 20if [ -d include/mbedtls ]; then :; else 21 echo "$0: must be run from root" >&2 22 exit 1 23fi 24 25if grep -i cmake Makefile >/dev/null; then 26 echo "$0: not compatible with cmake" >&2 27 exit 1 28fi 29 30cp include/mbedtls/config.h include/mbedtls/config.h.bak 31scripts/config.py full 32make clean 33make_ret= 34CFLAGS=-fno-asynchronous-unwind-tables make lib \ 35 >list-symbols.make.log 2>&1 || 36 { 37 make_ret=$? 38 echo "Build failure: CFLAGS=-fno-asynchronous-unwind-tables make lib" 39 cat list-symbols.make.log >&2 40 } 41rm list-symbols.make.log 42mv include/mbedtls/config.h.bak include/mbedtls/config.h 43if [ -n "$make_ret" ]; then 44 exit "$make_ret" 45fi 46 47if uname | grep -F Darwin >/dev/null; then 48 nm -gUj library/libmbed*.a 2>/dev/null | sed -n -e 's/^_//p' | grep -v -e ^FStar -e ^Hacl 49elif uname | grep -F Linux >/dev/null; then 50 nm -og library/libmbed*.a | grep -v '^[^ ]*: *U \|^$\|^[^ ]*:$' | sed 's/^[^ ]* . //' | grep -v -e ^FStar -e ^Hacl 51fi | sort > exported-symbols 52make clean 53 54wc -l exported-symbols 55