util  Artifact [11c34eecc9]

Artifact 11c34eecc995ee06808eb29e170085c2820426be90d9227ae427502d3650a6b1:


B = build
E = ext

pq-inc != pkg-config --cflags libpq
pq-lib != pkg-config --libs libpq

wg-inc = -I$E/wglib

dbg-flags = $(if $(debug),-g -D_cfg_debug,)
cc-flags = -std=c2x $(pq-inc) $(wg-inc) $(dbg-flags)
ld-flags = $(pq-lib) $(dbg-flags)


# link rule 
.PHONY: wgsync
$B/wgsync: $B/wgsync.o $B/pqp.o $B/def.o $B/wireguard.o | $B/
	$(CC) $(ld-flags) $^ -o $@

# build rules 
$B/%.o: src/%.c | $B/
	$(CC) $(cc-flags) -c $< -o $@

$B/wireguard.o: $E/wglib/wireguard.c $E/wglib/wireguard.h | $B/
	$(CC) -std=c11 -c $< -o $@

# dep listings
$B/wgsync.o: $E/wglib/wireguard.h src/pqp.h src/def.h
$B/pqp.o: src/pqp.h src/def.h 
$B/def.o: src/def.h

# fetch rules
%/:
	mkdir -p $@

wg-lib-uri = https://git.zx2c4.com/wireguard-tools/plain/contrib/embeddable-wg-library
$E/wglib/%: | $E/wglib/
	curl $(wg-lib-uri)/$* >$@