xref: /aosp_15_r20/external/ms-tpm-20-ref/TPMCmd/bootstrap (revision 5c591343844d1f9da7da26467c4bf7efc8a7a413)
1*5c591343SA. Cody Schuffelen#!/usr/bin/env sh
2*5c591343SA. Cody Schuffelen# The copyright in this software is being made available under the BSD License,
3*5c591343SA. Cody Schuffelen# included below. This software may be subject to other third party and
4*5c591343SA. Cody Schuffelen# contributor rights, including patent rights, and no such rights are granted
5*5c591343SA. Cody Schuffelen# under this license.
6*5c591343SA. Cody Schuffelen#
7*5c591343SA. Cody Schuffelen# Copyright (c) Intel Corporation
8*5c591343SA. Cody Schuffelen#
9*5c591343SA. Cody Schuffelen# All rights reserved.
10*5c591343SA. Cody Schuffelen#
11*5c591343SA. Cody Schuffelen# BSD License
12*5c591343SA. Cody Schuffelen#
13*5c591343SA. Cody Schuffelen# Redistribution and use in source and binary forms, with or without modification,
14*5c591343SA. Cody Schuffelen# are permitted provided that the following conditions are met:
15*5c591343SA. Cody Schuffelen#
16*5c591343SA. Cody Schuffelen# Redistributions of source code must retain the above copyright notice, this list
17*5c591343SA. Cody Schuffelen# of conditions and the following disclaimer.
18*5c591343SA. Cody Schuffelen#
19*5c591343SA. Cody Schuffelen# Redistributions in binary form must reproduce the above copyright notice, this
20*5c591343SA. Cody Schuffelen# list of conditions and the following disclaimer in the documentation and/or
21*5c591343SA. Cody Schuffelen# other materials provided with the distribution.
22*5c591343SA. Cody Schuffelen#
23*5c591343SA. Cody Schuffelen# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS""
24*5c591343SA. Cody Schuffelen# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25*5c591343SA. Cody Schuffelen# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26*5c591343SA. Cody Schuffelen# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
27*5c591343SA. Cody Schuffelen# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28*5c591343SA. Cody Schuffelen# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29*5c591343SA. Cody Schuffelen# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
30*5c591343SA. Cody Schuffelen# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31*5c591343SA. Cody Schuffelen# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32*5c591343SA. Cody Schuffelen# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*5c591343SA. Cody Schuffelen
34*5c591343SA. Cody SchuffelenAUTORECONF=${AUTORECONF:-autoreconf}
35*5c591343SA. Cody Schuffelen
36*5c591343SA. Cody Schuffelen# generate list of source files for use in Makefile.am
37*5c591343SA. Cody Schuffelen# if you add new source files, you must run ./bootstrap again
38*5c591343SA. Cody Schuffelensrc_listvar () {
39*5c591343SA. Cody Schuffelen    basedir=$1
40*5c591343SA. Cody Schuffelen    suffix=$2
41*5c591343SA. Cody Schuffelen    var=$3
42*5c591343SA. Cody Schuffelen
43*5c591343SA. Cody Schuffelen    find "${basedir}" -name "${suffix}" | LC_ALL=C sort | tr '\n' ' ' | (printf "${var} = " && cat)
44*5c591343SA. Cody Schuffelen    echo ""
45*5c591343SA. Cody Schuffelen}
46*5c591343SA. Cody Schuffelen
47*5c591343SA. Cody Schuffelenecho "Generating file lists: src.mk"
48*5c591343SA. Cody Schuffelen(
49*5c591343SA. Cody Schuffelen    src_listvar "Platform" "*.c" "PLATFORM_C"
50*5c591343SA. Cody Schuffelen    src_listvar "Platform" "*.h" "PLATFORM_H"
51*5c591343SA. Cody Schuffelen    src_listvar "Simulator" "*.c" "SIMULATOR_C"
52*5c591343SA. Cody Schuffelen    src_listvar "Simulator" "*.h" "SIMULATOR_H"
53*5c591343SA. Cody Schuffelen    src_listvar "tpm" "*.c" "TPM_C"
54*5c591343SA. Cody Schuffelen    src_listvar "tpm" "*.h" "TPM_H"
55*5c591343SA. Cody Schuffelen) > src.mk
56*5c591343SA. Cody Schuffelen
57*5c591343SA. Cody Schuffelenecho "Setting up build"
58*5c591343SA. Cody Schuffelen${AUTORECONF} --install --sym
59*5c591343SA. Cody Schuffelen
60*5c591343SA. Cody Schuffelen# A freshly checked out source tree will not build. VendorString.h must have
61*5c591343SA. Cody Schuffelen# these symbols defined to build.
62*5c591343SA. Cody Schuffelenecho "Setting default vendor strings"
63*5c591343SA. Cody Schuffelensed -i 's&^\/\/\(#define[[:space:]]\+FIRMWARE_V1.*\)&\1&;
64*5c591343SA. Cody Schuffelen        s&^\/\/\(#define[[:space:]]\+MANUFACTURER.*\)&\1&;
65*5c591343SA. Cody Schuffelen        s&^\/\/\(#define[[:space:]]\+VENDOR_STRING_1.*\)&\1&' \
66*5c591343SA. Cody Schuffelen       tpm/include/VendorString.h
67