This repository was archived by the owner on Jul 16, 2023. It is now read-only.
forked from nmikhailov/Validity90
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (41 loc) · 1.69 KB
/
Makefile
File metadata and controls
60 lines (41 loc) · 1.69 KB
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
CFLAGS = -c -Wall -g -DG_LOG_DOMAIN=\"Validity90\"
LDFLAGS =
SOURCES = validity90/utils.c validity90/validity90.c
SOURCES_GTEST = test/rsp6-test.c test/utils-test.c
HEADERS = constants.h validity90/validity90.h
OBJECTS = $(SOURCES:.c=.o)
OBJECTS_GTEST = $(SOURCES_GTEST:.c=.o)
EXECUTABLE = prototype
LIBS = nss openssl libusb-1.0 libpng glib-2.0
CFLAGS += $(shell pkg-config --cflags $(LIBS))
LDFLAGS += $(shell pkg-config --libs $(LIBS)) -lgcrypt
ADDRESS := $(shell chmod +x findaddress.sh && ./findaddress.sh)
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS) main.o
$(CC) $(OBJECTS) main.o -o $@ $(LDFLAGS)
main.o: main.c $(HEADERS)
$(CC) $(CFLAGS) -w $< -o $@
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) $< -o $@
test/gtest.out.c: $(SOURCES_GTEST) test/gtest.c
cp test/gtest.c $@
awk '/@TEST_DEF/{ getline; print $$1 " " $$2 ";" }' $(SOURCES_GTEST) > $@.1
awk '/@TEST_DEF/{ name=$$3; getline; print "g_test_add_func(\"" name "\", " gensub(/[^[A-Za-z0-9_]/, "", "g", $$2) ");" }' $(SOURCES_GTEST) > $@.2
sed -i '/@TEST_INSERT_DEFINITION@/ r $@.1' $@
sed -i '/@TEST_INSERT_DECLARATION@/ r $@.2' $@
rm $@.1 $@.2
test/%.o: test/%.c $(HEADERS)
$(CC) -Wno-unused-variable $(CFLAGS) -I. $< -o $@
test/gtest: $(OBJECTS) $(OBJECTS_GTEST) test/gtest.out.o
$(CC) $(OBJECTS) $(OBJECTS_GTEST) test/gtest.out.o -o $@ $(LDFLAGS)
test: test/gtest
gtester -k --verbose test/gtest
permissions:
sudo chmod a+rwx $(ADDRESS)
sudo chmod a+r /sys/class/dmi/id/product_serial
$(ADDRESS) | xargs -r sudo chmod a+rw
sudo chmod a+rwx $(ADDRESS)
sudo chmod a+r /sys/class/dmi/id/product_serial
clean:
rm -f $(OBJECTS) $(OBJECTS_GTEST) $(EXECUTABLE) main.o test/gtest test/gtest.out.*
.PHONY: all permissions test clean