# -iquote (not -I) locates the vendored agec headers: they are all included with
# the quoted form (#include "io.h"), and -iquote adds the directory ONLY for
# quoted includes. This matters on Windows, where agec ships a header named
# io.h: with -Iagec on the angle-bracket path, the system <unistd.h>/<fcntl.h>'s
# internal #include <io.h> would resolve to agec/io.h instead of the real Win32
# <io.h>, breaking the build. -iquote keeps <...> resolving to system headers.
PKG_CPPFLAGS = -iquote agec -iquote agec/crypto

OBJECTS = \
	init.o \
	binding.o \
	memio.o \
	platform.o \
	fileio.o \
	agec/agecore.o \
	agec/base64.o \
	agec/bech32.o \
	agec/header.o \
	agec/io.o \
	agec/keyenc.o \
	agec/parse.o \
	agec/payload.o \
	agec/scrypt.o \
	agec/util.o \
	agec/x25519.o \
	agec/crypto/chacha20poly1305.o \
	agec/crypto/curve25519.o \
	agec/crypto/hkdf.o \
	agec/crypto/hmac.o \
	agec/crypto/scrypt.o \
	agec/crypto/sha256.o

# R CMD SHLIB passes this file to make BEFORE shlib.mk, so the first rule here
# becomes make's default goal. Restating shlib.mk's own default keeps the clean
# target below from hijacking the build. Keep `all` first among the rules.
all: $(SHLIB)

# R CMD build's src cleanup only globs *.o in src/ itself; the vendored agec
# objects are compiled into subdirectories and would otherwise be shipped in the
# tarball ("Found the following apparent object files/libraries" NOTE). Build
# runs this as `make -f Makeconf -f clean.mk -f Makevars clean`, where $(SHLIB)
# is unset and the top-level src/*.o and src/*.so are removed by build itself.
.PHONY: all clean
clean:
	rm -f $(OBJECTS) $(SHLIB)
