Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement autotools build for TPM and Platform code #8

Merged
merged 4 commits into from
Dec 12, 2018
Merged

Implement autotools build for TPM and Platform code #8

merged 4 commits into from
Dec 12, 2018

Conversation

flihp
Copy link
Contributor

@flihp flihp commented Jun 11, 2018

This is the minimum required to:

  • build the code under TPMCmd/tpm as a static library called libtpm.a
  • build the code under TPMCmd/Platform as a static library called libplatform.a
  • automate 32 and 64bit builds using travis-ci

The only code changes required to do this are a minor change to a preprocessor macro to accommodate GCC and clang and the generation of the RADIX_BITS value from the compiler environment. The rest of this is just the addition of build script and config for the autotools.

@msftclas
Copy link

msftclas commented Jun 11, 2018

CLA assistant check
All CLA requirements met.

@flihp
Copy link
Contributor Author

flihp commented Dec 7, 2018

Finally got the CLA stuff sorted out with my employer. This needs to be rebased since I got at least one PR from folks using my fork to do Linux stuff (a good sign).

Expecting users to change code in order to build for 64bit environments
isn't very user friendly. In the case of the RADIX_BITS we can make this
easier on users (and automated builds) by using the compiler environment
to do the detection for us. Currently the implementation is limited to
the __x86_64__ / __i386__ and _WIN64 / _WIN32 macros from linux /
windows compilers respectively.

An alternative implementation may have used the OpenSSL bn_ops values to
determine 32 vs 64bit. This ends up being awkward since Implementation.h
is included by other modules and they then end up depending on the
openssl headers.

Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
This commit adds configuration files implementing a minimal GNU Autotools
build. It follows the common `./bootstrap && ./configure && make`
convention. Currently it only builds a static library for the code under
TPMCmd/tpm/.

bootstrap:
- runs AUTORECONF configured to create symlinks to the required scripts
- generates src.mk file holding variables listing the pathes to source
files (relative to srcdir) used in the build
- uncomment the required macros in the VendorString header leaving the
default values in place

configure.ac:
- sets up basic project metadata using mostly placeholders, including
the version number
- does the typical setup for a c program
- configures libtool
- ensures we're using a compatible version of openssl
- sets up recommended compiler flags being relatively strict
  - build to 'gnu11', this is c11 with a bunch of POSIX and GNU features
  enabled
  - treat all warnings as errors
  - explicitly ignore warnings caused by the current code

Makefile.am:
- build a static library for the 'tpm' module

.gitignore: update to ignore build output on linux

Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
If travis-ci has been configured to monitor this git repo then it will
parse the .travis.yml file and build accordingly. This configuration
file will cause travis-ci to:
- configure the builder to build C code
- execute the build on the Ubuntu Trusty container (64bit)
- install dependencies
- enable cross compiling to i386 / 32bit
  - install multilib toolcain
  - configure pacakge manager to install i386 packages
  - install libssl-dev for i386
- setup the build matrix (4 builds total)
  - build for using gcc and clang compilers
  - create environments for building 64bit and 32bit builds
- bootstrap, configure and build the code

Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
This requires that we:
- add code to the bootstrap script to generate variables holding the
paths to source code and headers: PLATFORM_C and PLATFORM_H
- add rules to Makefile.am to build this code in PLATFORM_C into
libplatform.a
- add libplatform.a to .gitignore
- ignore warnings about unused results. GCC on travis-ci complains
about NVMem.c in Platform ignoring results from `fread`.

Signed-off-by: Philip Tricca <philip.b.tricca@intel.com>
@flihp
Copy link
Contributor Author

flihp commented Dec 10, 2018

Rebase onto master and an upgrade to the travis-ci build image are working. An example of the travis-ci build is here: https://travis-ci.org/flihp/ms-tpm-20-ref/builds/465836354. I don't know how Microsoft manages their CI stuff but if you can enable travis-ci for this repo the .travis.yml file added in 3a8719e should be sufficient to do 32 and 64bit builds with gcc and clang.

@amarochk amarochk merged commit 0afb667 into microsoft:master Dec 12, 2018
@amarochk
Copy link
Contributor

I've checked that the build works on Ubuntu 17.04.

One needs to make sure that the following packages are installed before running the build scripts: autoconf-archive, pkg-config, libssl-dev.

Awesome work, Philip! Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants