42c7160576
Mostly generated from help2man output. Signed-off-by: Jeremy Kerr <jeremy.kerr@canonical.com>
112 lines
2.4 KiB
Makefile
112 lines
2.4 KiB
Makefile
|
|
# 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
|