summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/examples/Makefile
blob: 6742a9a5db77455514484403eb13b3e144cb589b (plain)
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
# Makefile for examples written in C.

CARGO	?= cargo
CARGO_TARGET_DIR	?= $(shell pwd)/../../target
# We currently only support absolute paths.
CARGO_TARGET_DIR	:= $(abspath $(CARGO_TARGET_DIR))

# We are producing binaries here.
EXAMPLE_TARGET_DIR      ?= $(CARGO_TARGET_DIR)/debug/c-examples/openpgp-ffi

EXAMPLES = \
	example reader parser encrypt-for armor \
	decrypt-with \
	generate-key \
	type-safety-demo use-after-free-demo immutable-reference-demo \
	writer-cookie \
	reader-cookie \

CFLAGS  = -I../include -O0 -g -Wall -Werror
LDFLAGS = -L$(CARGO_TARGET_DIR)/debug
LDLIBS = -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 "$@" "$<" $(LDLIBS)