-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to build the project with Makefile for the use of the reproducible Heads build. Reprotest's small corrections. Details: #13 Fixes #14
- Loading branch information
Showing
4 changed files
with
187 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
SRCDIR=. | ||
PKGCONFIG=pkg-config | ||
|
||
SRC:= \ | ||
$(SRCDIR)/crc32.c \ | ||
$(SRCDIR)/device.c \ | ||
$(SRCDIR)/operations.c \ | ||
$(SRCDIR)/dev_commands.c \ | ||
$(SRCDIR)/base32.c \ | ||
$(SRCDIR)/random_data.c \ | ||
$(SRCDIR)/min.c \ | ||
$(SRCDIR)/version.c \ | ||
$(SRCDIR)/return_codes.c \ | ||
$(SRCDIR)/main.c | ||
|
||
SRC += \ | ||
$(SRCDIR)/hidapi/libusb/hid.c | ||
|
||
HEADERS := \ | ||
$(SRCDIR)/crc32.h \ | ||
$(SRCDIR)/structs.h \ | ||
$(SRCDIR)/device.h \ | ||
$(SRCDIR)/operations.h \ | ||
$(SRCDIR)/dev_commands.h \ | ||
$(SRCDIR)/base32.h \ | ||
$(SRCDIR)/command_id.h \ | ||
$(SRCDIR)/random_data.h \ | ||
$(SRCDIR)/min.h \ | ||
$(SRCDIR)/settings.h \ | ||
$(SRCDIR)/version.h \ | ||
$(SRCDIR)/return_codes.h \ | ||
|
||
|
||
OBJS := ${SRC:.c=.o} | ||
|
||
HIDAPI_INC=hidapi | ||
INC:= \ | ||
-I$(SRCDIR) \ | ||
-I$(HIDAPI_INC) \ | ||
-I$(HIDAPI_INC)/hidapi \ | ||
|
||
LIBUSB_FLAGS=$(shell $(PKGCONFIG) --cflags libusb-1.0) | ||
LIBUSB_LIB=$(shell $(PKGCONFIG) --libs libusb-1.0) | ||
|
||
CFLAGS= -Wall -Wextra -fno-guess-branch-probability -Wdate-time -frandom-seed=42 -O2 -gno-record-gcc-switches -DNDEBUG -fdebug-prefix-map=${PWD}=heads -c -std=gnu11 -DNK_REMOVE_PTHREAD $(LIBUSB_FLAGS) | ||
|
||
OUTDIR= | ||
OUT=nitrokey_hotp_verification | ||
OUT2=libremkey_hotp_verification | ||
LDFLAGS=$(LIBUSB_LIB) | ||
|
||
all: $(OUT) $(OUT2) | ||
ls -lh $^ | ||
sha256sum $^ | ||
|
||
clean: | ||
-rm $(OBJS) $(OUT) version.c | ||
|
||
$(OUT2): $(OUT) | ||
cp $< $@ | ||
|
||
$(OUT): $(OBJS) | ||
$(CC) $^ $(LDFLAGS) -o $@ | ||
|
||
%.o: %.c | ||
$(CC) $(CFLAGS) $(INC) -o $@ $< | ||
|
||
GITVERSION=$(shell git describe) | ||
$(SRCDIR)/version.c: $(SRCDIR)/version.c.in | ||
sed "s!@GIT_VERSION_PLACEHOLDER@!$(GITVERSION)!g" < $< >$@ | ||
|
||
.PRECIOUS: %.o | ||
|
||
INSTALL=/usr/local/ | ||
.PHONY: install | ||
install: | ||
cp -v $(OUT) $(OUT2) $(INSTALL)/bin | ||
|
||
.PHONY: github_sha | ||
GVER=$(shell git rev-parse HEAD) | ||
libremkey_url := https://github.com/Nitrokey/nitrokey-hotp-verification/archive/$(GVER).tar.gz | ||
github_sha: | ||
wget -c $(libremkey_url) | ||
sha256sum $(GVER).tar.gz | ||
@echo $(GVER) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
project('hotp-verification', 'c', | ||
version : '1.1.0', | ||
) | ||
lusb = dependency('libusb-1.0') | ||
|
||
src = [ | ||
'crc32.c', | ||
'device.c', | ||
'operations.c', | ||
'dev_commands.c', | ||
'base32.c', | ||
'random_data.c', | ||
'min.c', | ||
'version.c', | ||
'return_codes.c', | ||
'main.c', | ||
'hidapi/libusb/hid.c' | ||
] | ||
|
||
version_array = meson.project_version().split('.') | ||
version_major = version_array[0].to_int() | ||
version_minor = version_array[1].to_int() | ||
version_data = configuration_data() | ||
version_data.set('PROJECT_VERSION_MAJOR', version_major) | ||
version_data.set('PROJECT_VERSION_MINOR', version_minor) | ||
# We don't want to substitute it by noop | ||
version_data.set('GIT_VERSION_PLACEHOLDER', '@VCS_TAG@') | ||
version_cc_in = configure_file( | ||
input : 'version.c.in', | ||
output : 'version.c.in', | ||
configuration : version_data, | ||
) | ||
version_cc = vcs_tag( | ||
input : version_cc_in, | ||
output : 'version.c', | ||
fallback : 'v@0@'.format(meson.project_version()), | ||
) | ||
|
||
common_flags = [ | ||
'-DNK_REMOVE_PTHREAD', | ||
'-fdebug-prefix-map=$PWD=heads', | ||
'-gno-record-gcc-switches', | ||
'-DNDEBUG', | ||
'-fno-guess-branch-probability', | ||
'-Wdate-time', | ||
'-frandom-seed=0x42', | ||
'-O0', | ||
] | ||
|
||
incdir = ([ | ||
include_directories('.'), | ||
include_directories('hidapi/hidapi'), | ||
]) | ||
|
||
name1 = 'nitrokey-hotp-verification' | ||
name2 = 'libremkey-hotp-verification' | ||
executable(name1, src, dependencies : lusb, include_directories: incdir, c_args: common_flags) | ||
executable(name2, src, dependencies : lusb, include_directories: incdir, c_args: common_flags) |