aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/contrib/examples/extract-keys/Makefile
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-08-24 17:44:41 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-08-26 04:52:50 +0200
commit7234d7339f570be46b3d916fd7d2561b970b68e8 (patch)
treec9edbcceaf07da2718923c8c9ca48c8cd1f3ef22 /contrib/examples/extract-keys/Makefile
parentexamples: add nat-hole-punching (diff)
downloadwireguard-monolithic-historical-7234d7339f570be46b3d916fd7d2561b970b68e8.tar.xz
wireguard-monolithic-historical-7234d7339f570be46b3d916fd7d2561b970b68e8.zip
examples: add key extractor
Diffstat (limited to 'contrib/examples/extract-keys/Makefile')
-rw-r--r--contrib/examples/extract-keys/Makefile27
1 files changed, 27 insertions, 0 deletions
diff --git a/contrib/examples/extract-keys/Makefile b/contrib/examples/extract-keys/Makefile
new file mode 100644
index 0000000..a1dd7a2
--- /dev/null
+++ b/contrib/examples/extract-keys/Makefile
@@ -0,0 +1,27 @@
+ifeq ($(KERNELRELEASE),)
+KERNELDIR ?= /lib/modules/$(shell uname -r)/build
+PWD := $(shell pwd)
+CFLAGS ?= -O3 -march=native
+CFLAGS += -Wall -pedantic -std=gnu11
+
+extract-keys: extract-keys.c config.h
+ $(CC) $(CFLAGS) $(CPPFLAGS) -D_FILE_OFFSET_BITS=64 -o $@ -lresolv $<
+
+config.o: config.c
+ $(MAKE) -C $(KERNELDIR) M=$(PWD) $@
+ objcopy -j '.rodata*' $@ $@
+
+config: config.c config.o
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^
+
+config.h: config
+ ./$< > $@
+
+clean:
+ rm -f extract-keys config config.h
+ $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
+
+.PHONY: clean
+else
+config-m := config.o
+endif