From 3def2383601b1062930a5d95cbf954c766214a5e Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Thu, 24 May 2012 15:14:28 +0800 Subject: [PATCH] autoconfiscate Add autoconf & automake metadata, plus required files for automake to run without complaint. Requires an update to ccan, to get the --build-type argument to create-ccan-tree. Signed-off-by: Jeremy Kerr --- Makefile | 112 --------------------------------------------------- Makefile.am | 26 ++++++++++++ NEWS | 2 + README | 14 +++++++ autogen.sh | 33 +++++++++++++++ configure.ac | 54 +++++++++++++++++++++++++ lib/ccan.git | 2 +- 7 files changed, 130 insertions(+), 113 deletions(-) delete mode 100644 Makefile create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 README create mode 100755 autogen.sh create mode 100644 configure.ac diff --git a/Makefile b/Makefile deleted file mode 100644 index 6027969..0000000 --- a/Makefile +++ /dev/null @@ -1,112 +0,0 @@ - -# compile options -CC = gcc -CPPFLAGS = -I. $(ccan_includes) -CFLAGS = -Wall -Werror -Wextra -ggdb --std=c99 -LDFLAGS = -fwhole-program - -# build configuration -sbsign_objs = sbsign.o idc.o image.o -sbverify_objs = sbverify.o idc.o image.o -libs = -lbfd -lcrypto -objs = $(sort $(sbsign_objs) $(sbverify_objs)) -docs = docs/sbsign.1 docs/sbverify.1 - -# ccan build configuration -ccan_dir = lib/ccan -ccan_objs = $(ccan_dir)/libccan.a -ccan_includes = -I./lib/ccan -ccan_modules = talloc -ccan_stamp = $(ccan_dir)/Makefile -ccan_config = $(ccan_dir)/config.h - -# install paths -DESTDIR ?= -prefix ?= /usr -bindir ?= ${prefix}/bin -man1dir = ${prefix}/share/man/man1/ -install_dirs = install -m 755 -d $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) -install_bin = install -m 755 -t $(DESTDIR)$(bindir) -install_man1 = install -m 755 -t $(DESTDIR)$(man1dir) - -# dist -package = sbsigntool -version = 0.1 -pkgver = $(package)-$(version) -tarball = $(pkgver).tar.gz - -tools = sbsign sbverify - -all: $(tools) - -sbsign: $(sbsign_objs) $(ccan_objs) - $(LINK.o) -o $@ $^ $(libs) - -sbverify: $(sbverify_objs) $(ccan_objs) - $(LINK.o) -o $@ $^ $(libs) - -sbsign.o sbverify.o: CPPFLAGS+=-DVERSION=\"$(version)\" - -gen-keyfiles: gen-keyfiles.o $(ccan_objs) - $(LINK.o) -o $@ $^ $(libs) -gen-keyfiles: libs = -luuid - -# ccan build -$(ccan_objs): $(ccan_stamp) - cd $(@D) && $(MAKE) - -$(ccan_config): $(ccan_stamp) - cd $(@D) && $(MAKE) config.h - -# doc build -docs: $(docs) -.PHONY: docs - -$(docs): docs/%.1: docs/%.1.in % - help2man --no-info -i $< -o $@ $(patsubst %.1, ./%, $(@F)) - -# built objects may require headers from ccan -$(objs): $(ccan_stamp) $(ccan_config) - -install: $(tools) $(docs) - $(install_dirs) - $(install_bin) $(tools) - $(install_man1) $(docs) -.PHONY: install - -clean: - rm -f $(tools) - rm -f *.o - -# tarball build -tarball: $(tarball) - -$(tarball): $(ccan_stamp) - ln -s . $(pkgver) - tar -zhcvf $@ --exclude '*.tar.gz' \ - --exclude $(pkgver)/$(pkgver) \ - --exclude $(ccan_source_dir) \ - --exclude '.*.swp' \ - --exclude .git --exclude .gitmodules \ - $(pkgver) - rm $(pkgver) - -distclean: clean - rm -rf $(ccan_dir) - -# ccan import -ccan_source_dir = lib/ccan.git -ccan_source_file = $(ccan_source_dir)/Makefile - -# protect these rules with the DIST variable, as non-git checkouts will not be -# able to run the git submodule commands. -ifeq ($(DIST),1) - -$(ccan_source_file): - git submodule init - git submodule update - -$(ccan_stamp): $(ccan_source_file) - $(ccan_source_dir)/tools/create-ccan-tree --exclude-tests \ - $(@D) $(ccan_modules) -endif diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..7386f24 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,26 @@ + +bin_PROGRAMS = sbsign sbverify + +coff_headers = coff/external.h coff/pe.h coff/i386.h coff/x86_64.h + +common_SOURCES = idc.c idc.h image.c image.h $(coff_headers) +common_LDADD = lib/ccan/libccan.a $(libcrypto_LIBS) +common_CFLAGS = -I$(srcdir)/lib/ccan/ + +sbsign_SOURCES = sbsign.c $(common_SOURCES) +sbsign_LDADD = $(common_LDADD) +sbsign_CFLAGS = $(common_CFLAGS) + +sbverify_SOURCES = sbverify.c $(common_SOURCES) +sbverify_LDADD = $(common_LDADD) +sbverify_CFLAGS = $(common_CFLAGS) + +man1_MANS = docs/sbsign.1 docs/sbverify.1 + +EXTRA_DIST = docs/sbsign.1.in docs/sbverify.1.in + +$(builddir)/docs/%.1: $(srcdir)/docs/%.1.in $(builddir)/% + $(MKDIR_P) $(@D) + $(HELP2MAN) --no-info -i $< -o $@ $(builddir)/$* + +SUBDIRS = lib/ccan diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..b62c90a --- /dev/null +++ b/NEWS @@ -0,0 +1,2 @@ +v0.1: + Initial version diff --git a/README b/README new file mode 100644 index 0000000..0de60c1 --- /dev/null +++ b/README @@ -0,0 +1,14 @@ +sbsigntool - Signing utility for UEFI secure boot + + Copyright (C) 2102 Jeremy Kerr + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + +See file ./INSTALL for building and installation instructions. + +Main git repository: + git://kernel.ubuntu.com/jk/sbsigntool.git + +sbsigntool is free software. See the file COPYING for copying conditions. diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..9798a2a --- /dev/null +++ b/autogen.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +ccan_modules=talloc + +# Add ccan upstream sources +if [ ! -e lib/ccan.git/Makefile ] +then + git submodule init + git submodule update +fi + +# create ccan build tree +if [ ! -e lib/ccan ] +then + lib/ccan.git/tools/create-ccan-tree \ + --build-type=automake lib/ccan $ccan_modules +fi + +# Create generatable docs from git +( + echo "Authors of sbsigntool:" + echo + git log --format='%an' | sort -u | sed 's,^,\t,' +) > AUTHORS + +# Generate simple ChangeLog +git log --date=short --format='%ad %t %an <%ae>%n%n * %s%n' > ChangeLog + +# automagic +aclocal +autoheader +autoconf +automake --add-missing -Wno-portability diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..9b94080 --- /dev/null +++ b/configure.ac @@ -0,0 +1,54 @@ +AC_INIT([sbsigntool], [0.1], [jeremy.kerr@canonical.com]) + +AM_INIT_AUTOMAKE() + +AC_PREREQ(2.60) + +AC_CONFIG_HEADERS(config.h) +AC_CONFIG_SRCDIR(sbsign.c) + +AC_PROG_CC +AM_PROG_CC_C_O +AC_PROG_CPP +AC_PROG_RANLIB + +if test $cross_compiling = no; then + AM_MISSING_PROG(HELP2MAN, help2man) +else + HELP2MAN=: +fi + +AC_MSG_CHECKING([build system endianness]) +AC_PREPROC_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[#if __BYTE_ORDER != __LITTLE_ENDIAN]] + [[#error]] + [[#endif]])], + endian=little + little_endian=1 + big_endian=0) + +AC_PREPROC_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[#if __BYTE_ORDER != __BIG_ENDIAN]] + [[#error]] + [[#endif]])], + endian=big + little_endian=0 + big_endian=1) + + +if test x"$endian" != "xbig" -a x"$endian" != "xlittle"; then + AC_MSG_ERROR([Can't determine endianness; is endian.h present?]) +fi +AC_MSG_RESULT($endian) +AC_DEFINE_UNQUOTED(HAVE_LITTLE_ENDIAN, $little_endian, [Little-endian system]) +AC_DEFINE_UNQUOTED(HAVE_BIG_ENDIAN, $big_endian, [Big-endian system]) + +PKG_PROG_PKG_CONFIG() +PKG_CHECK_MODULES(libcrypto, libcrypto, + [], + AC_MSG_ERROR([libcrypto (from the OpenSSL package) is required])) + +AC_CONFIG_FILES([Makefile lib/ccan/Makefile]) +AC_OUTPUT diff --git a/lib/ccan.git b/lib/ccan.git index ebcbbcf..b1f28e1 160000 --- a/lib/ccan.git +++ b/lib/ccan.git @@ -1 +1 @@ -Subproject commit ebcbbcfafce6a239724c841d30b9ba345cef41e4 +Subproject commit b1f28e17227f2320d07fe052a8a48942fe17caa5