blob: de6a85dc9a117101864e87c5dda4082c419a6213 [file] [log] [blame]
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +01001#!/bin/sh
Bence Szépkúti468a76f2020-05-26 00:33:31 +02002#
Bence Szépkútia2947ac2020-08-19 16:37:36 +02003# Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +02004# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
5#
6# This file is provided under the Apache License 2.0, or the
7# GNU General Public License v2.0 or later.
8#
9# **********
10# Apache License 2.0:
Bence Szépkúti51b41d52020-05-26 01:54:15 +020011#
12# Licensed under the Apache License, Version 2.0 (the "License"); you may
13# not use this file except in compliance with the License.
14# You may obtain a copy of the License at
15#
16# http://www.apache.org/licenses/LICENSE-2.0
17#
18# Unless required by applicable law or agreed to in writing, software
19# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
20# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21# See the License for the specific language governing permissions and
22# limitations under the License.
Bence Szépkúti468a76f2020-05-26 00:33:31 +020023#
Bence Szépkútif744bd72020-06-05 13:02:18 +020024# **********
25#
26# **********
27# GNU General Public License v2.0 or later:
28#
29# This program is free software; you can redistribute it and/or modify
30# it under the terms of the GNU General Public License as published by
31# the Free Software Foundation; either version 2 of the License, or
32# (at your option) any later version.
33#
34# This program is distributed in the hope that it will be useful,
35# but WITHOUT ANY WARRANTY; without even the implied warranty of
36# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37# GNU General Public License for more details.
38#
39# You should have received a copy of the GNU General Public License along
40# with this program; if not, write to the Free Software Foundation, Inc.,
41# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
42#
43# **********
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010044
45set -eu
46
Manuel Pégourié-Gonnardd1ddd292015-04-09 10:15:10 +020047if [ -d include/mbedtls ]; then :; else
48 echo "$0: must be run from root" >&2
49 exit 1
50fi
51
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010052if grep -i cmake Makefile >/dev/null; then
Manuel Pégourié-Gonnardd1ddd292015-04-09 10:15:10 +020053 echo "$0: not compatible with cmake" >&2
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010054 exit 1
55fi
56
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +020057cp include/mbedtls/config.h include/mbedtls/config.h.bak
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010058scripts/config.pl full
Jaeden Ameroada38312019-05-31 12:26:42 +010059make clean
Gilles Peskine39d7c582019-05-22 18:22:58 +020060make_ret=
Jaeden Ameroada38312019-05-31 12:26:42 +010061CFLAGS=-fno-asynchronous-unwind-tables make lib \
Gilles Peskine39d7c582019-05-22 18:22:58 +020062 >list-symbols.make.log 2>&1 ||
63 {
64 make_ret=$?
Jaeden Ameroada38312019-05-31 12:26:42 +010065 echo "Build failure: CFLAGS=-fno-asynchronous-unwind-tables make lib"
Gilles Peskine39d7c582019-05-22 18:22:58 +020066 cat list-symbols.make.log >&2
67 }
68rm list-symbols.make.log
Manuel Pégourié-Gonnard9afdc832015-08-04 17:15:13 +020069mv include/mbedtls/config.h.bak include/mbedtls/config.h
Gilles Peskine39d7c582019-05-22 18:22:58 +020070if [ -n "$make_ret" ]; then
71 exit "$make_ret"
72fi
73
Manuel Pégourié-Gonnardbf6ed082015-08-04 17:34:18 +020074if uname | grep -F Darwin >/dev/null; then
75 nm -gUj library/libmbed*.a 2>/dev/null | sed -n -e 's/^_//p'
76elif uname | grep -F Linux >/dev/null; then
77 nm -og library/libmbed*.a | grep -v '^[^ ]*: *U \|^$\|^[^ ]*:$' | sed 's/^[^ ]* . //'
78fi | sort > exported-symbols
Manuel Pégourié-Gonnard3385cf42015-04-02 17:59:30 +010079make clean
80
81wc -l exported-symbols