diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-29 17:39:58 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-29 17:41:17 +0100 |
commit | c251842e350f5b130f689910461ab85fbe556e7b (patch) | |
tree | bfc9eb5db9c9d686ba53052ca2b932ea54ceaf05 /openpgp-ffi/examples | |
parent | fc514ce424f71f0146f70727a548ec8009a06f1b (diff) |
openpgp-ffi: Build examples below CARGO_TARGET_DIR.
- Addresses #172.
Diffstat (limited to 'openpgp-ffi/examples')
-rw-r--r-- | openpgp-ffi/examples/.gitignore | 7 | ||||
-rw-r--r-- | openpgp-ffi/examples/Makefile | 12 |
2 files changed, 11 insertions, 8 deletions
diff --git a/openpgp-ffi/examples/.gitignore b/openpgp-ffi/examples/.gitignore deleted file mode 100644 index 3370781f..00000000 --- a/openpgp-ffi/examples/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -armor -encrypt-for -example -parser -reader -type-safety-demo -use-after-free-demo diff --git a/openpgp-ffi/examples/Makefile b/openpgp-ffi/examples/Makefile index 3b659e50..7986d7d6 100644 --- a/openpgp-ffi/examples/Makefile +++ b/openpgp-ffi/examples/Makefile @@ -5,13 +5,23 @@ CARGO_TARGET_DIR ?= $(shell pwd)/../../target # We currently only support absolute paths. CARGO_TARGET_DIR := $(abspath $(CARGO_TARGET_DIR)) -TARGETS = example reader parser encrypt-for armor type-safety-demo use-after-free-demo +# We are producing binaries here. +EXAMPLE_TARGET_DIR ?= $(CARGO_TARGET_DIR)/debug/c-examples/openpgp-ffi + +EXAMPLES = example reader parser encrypt-for armor type-safety-demo use-after-free-demo CFLAGS = -I../include -O0 -g -Wall -Werror LDFLAGS = -L$(CARGO_TARGET_DIR)/debug -lsequoia_openpgp_ffi +# Prefix our target directory. +TARGETS := $(foreach example,$(EXAMPLES),$(EXAMPLE_TARGET_DIR)/$(example)) + all: $(TARGETS) clean: rm -f $(TARGETS) $(TARGETS): ../include/sequoia/openpgp.h + +$(EXAMPLE_TARGET_DIR)/%: %.c + mkdir -p $(EXAMPLE_TARGET_DIR) + $(CC) $(CFLAGS) $(LDFLAGS) -o "$@" "$<" |