1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
##################################################################
# The following variables may be overriden in the command line: #
# #
BZERO ?=
MUSL ?= 0
BUNDLED_LIBBSD ?= 0
PLEDGE ?= noop
PKG_CONFIG ?= pkg-config
WGET ?= wget
libbsd_VERSION ?= 0.10.0
libbsd_BASEURL ?= http://libbsd.freedesktop.org/releases/
# #
##################################################################
CFLAGS += $(EXTRA_CFLAGS)
LDFLAGS += $(EXTRA_LDFLAGS)
CPPFLAGS += -include compat.h
S := crypto_api.c \
mod_ed25519.c \
mod_ge25519.c \
fe25519.c \
sc25519.c \
bcrypt_pbkdf.c \
timingsafe_bcmp.c \
blowfish.c \
base64.c \
sha2.c \
sha256hl.c \
sha512hl.c \
sha512_256hl.c \
signify.c \
zsig.c
define SED_LAST_LINE
sed -n -e '/^[a-zA-Z_-]\+$$/p' | sed -n '$$p'
endef
BZERO := $(strip $(BZERO))
ifeq ($(BZERO),)
BZERO := $(strip $(shell $(CC) -x c -E -P explicit_bzero.h | $(SED_LAST_LINE)))
endif
ifeq ($(BZERO),bundled)
CPPFLAGS += -DBUNDLED_BZERO=1
S += explicit_bzero.c
endif
PLEDGE := $(strip $(PLEDGE))
ifneq ($(PLEDGE),)
S += pledge_$(PLEDGE).c
endif
MUSL := $(strip $(MUSL))
ifeq ($(MUSL),1)
CC ?= musl-gcc
BUNDLED_LIBBSD := 1
endif
BUNDLED_LIBBSD := $(strip $(BUNDLED_LIBBSD))
all: signify
clean:
ifeq ($(BUNDLED_LIBBSD),1)
S += libbsd/arc4random.c \
libbsd/freezero.c \
libbsd/progname.c \
libbsd/readpassphrase.c \
libbsd/strlcpy.c
libbsd-config.h:
for i in $(patsubst conf/%.c,%,$(wildcard conf/*.c)); do \
if $(CC) $(LDFLAGS) -o conf-$$i conf/$$i.c > /dev/null 2>&1 ; then \
echo "#define $$i" ; \
fi ; \
$(RM) conf-$$i ; \
done > $@
clean: clean-libbsd-config
clean-libbsd-config:
$(RM) libbsd-config.h
.PHONY: clean-libbsd-config
$S: libbsd-config.h
LIBBSD_DEPS :=
LIBBSD_CFLAGS := -isystem libbsd/bsd -DLIBBSD_OVERLAY -include libbsd-config.h
LIBBSD_LDFLAGS :=
else
LIBBSD_PKG_VERSION := 0.7
LIBBSD_PKG_CHECK := $(shell $(PKG_CONFIG) libbsd --atleast-version=$(LIBBSD_PKG_VERSION) && echo ok)
ifneq ($(strip $(LIBBSD_PKG_CHECK)),ok)
$(error libbsd is not installed or version is older than $(LIBBSD_PKG_VERSION))
endif
LIBBSD_DEPS :=
LIBBSD_CFLAGS := $(shell $(PKG_CONFIG) libbsd-overlay --cflags)
LIBBSD_LDFLAGS := $(shell $(PKG_CONFIG) libbsd-overlay --libs)
endif
# In order to use libwaive, we need libseccomp and making sure that the
# Git submodule corresponding to libwaive is properly checked out.
#
ifeq ($(PLEDGE),waive)
SECCOMP_CFLAGS := $(shell $(PKG_CONFIG) libseccomp --cflags)
SECCOMP_LIBS := $(shell $(PKG_CONFIG) libseccomp --libs)
CFLAGS += $(SECCOMP_CFLAGS) -pthread
LDFLAGS += $(SECCOMP_LIBS) -pthread
S += libwaive/waive.c
ifneq ($(wildcard .gitmodules),)
libwaive/waive.c: .gitmodules
git submodule init && git submodule update libwaive
touch $@
endif
endif
ifeq ($(strip $(VERIFY_ONLY)),)
S += ohash.c
else
CPPFLAGS += -DVERIFY_ONLY=1
$(warning )
$(warning ******************************************************)
$(warning )
$(warning Building with VERIFY_ONLY enabled is unsupported, YMMV)
$(warning )
$(warning ******************************************************)
$(warning )
endif
ifeq ($(strip $(BOUNDS_CHECKING)),1)
CPPFLAGS += -DCOMPAT_BOUNDS_CHECKING
endif
ifneq ($(strip $(LTO)),)
CFLAGS += -flto
LDFLAGS += -flto
endif
O := $(patsubst %.c,%.o,$S)
signify: override CFLAGS += $(LIBBSD_CFLAGS) -Wall
signify: $O $(LIBBSD_DEPS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBBSD_LDFLAGS) $(LDLIBS)
zsig.o signify.o bcrypt_pbkdf.o: override CFLAGS += -Wno-pointer-sign
clean-signify:
$(RM) $O signify signify.1.gz sha256hl.c sha512hl.c sha512_256hl.c
clean: clean-signify
.PHONY: clean-signify
signify.1.gz: signify.1
gzip -9c $< > $@
sha256hl.c: helper.c
sed -e 's/hashinc/sha2.h/g' \
-e 's/HASH/SHA256/g' \
-e 's/SHA[0-9][0-9][0-9]_CTX/SHA2_CTX/g' $< > $@
sha512hl.c: helper.c
sed -e 's/hashinc/sha2.h/g' \
-e 's/HASH/SHA512/g' \
-e 's/SHA[0-9][0-9][0-9]_CTX/SHA2_CTX/g' $< > $@
sha512_256hl.c: helper.c
sed -e 's/hashinc/sha2.h/g' \
-e 's/HASH/SHA512_256/g' \
-e 's/SHA512_256_CTX/SHA2_CTX/g' $< > $@
install: signify signify.1.gz
install -m 755 -d $(DESTDIR)$(PREFIX)/bin
install -m 755 -t $(DESTDIR)$(PREFIX)/bin signify
install -m 755 -d $(DESTDIR)$(PREFIX)/share/man/man1
install -m 644 -t $(DESTDIR)$(PREFIX)/share/man/man1 signify.1.gz
.PHONY: install
ifneq ($(wildcard .git/),)
GIT_TAG = $(shell git describe --tags HEAD)
dist: T := $(GIT_TAG)
dist: V := $(patsubst v%,%,$T)
dist:
git archive-all --force-submodules --prefix=signify-$V/ signify-$V.tar
xz -f9 signify-$V.tar
.PHONY: dist
endif
check: signify
@sh regress/run
.PHONY: check
static:
$(MAKE) EXTRA_CFLAGS='$(EXTRA_CFLAGS) -pthread' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS) -pthread -static' BUNDLED_LIBBSD=1
static-musl:
$(MAKE) EXTRA_CFLAGS='$(EXTRA_CFLAGS) -pthread' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS) -pthread -static' MUSL=1 CC=musl-gcc LD=musl-gcc
.PHONY: static static-musl
|