PROG	=	tarsnap-recrypt
SRCS	=	recrypt.c
MAN1	=	tarsnap-recrypt.1
WARNS	?=	6
CFLAGS	+=	-DUSERAGENT=\"${PROG}-${TARVERSION}\"
CFLAGS	+=	-DTSSERVER=\"${TSSERVER}\"
CFLAGS	+=	-DPLATFORM_CONFIG_H=\"config_freebsd.h\"
CFLAGS	+=	-I ../tar

# Tarsnap library code
.if defined(PROFILE)
LDADD	+=	../lib/libtarsnap_p.a
${PROG}	:	../lib/libtarsnap_p.a
.else
LDADD	+=	../lib/libtarsnap.a
${PROG}	:	../lib/libtarsnap.a
.endif

# Other libraries used
LDADD	+=	-lz -lcrypto

# Multitape code
.PATH.c	:	../tar/multitape
SRCS	+=	multitape_transaction.c
SRCS	+=	multitape_metadata.c
CFLAGS	+=	-I ../tar/multitape

# Chunk layer (mostly link pollution from multitape code)
.PATH.c	:	../tar/chunks
SRCS	+=	chunks_write.c
SRCS	+=	chunks_stats.c
SRCS	+=	chunks_delete.c 
SRCS	+=	chunks_transaction.c
SRCS	+=	chunks_stats_internal.c
SRCS	+=	chunks_directory.c
CFLAGS	+=	-I ../tar/chunks

# Storage layer
.PATH.c	:	../tar/storage
SRCS	+=	storage_write.c
SRCS	+=	storage_read.c
SRCS	+=	storage_delete.c
SRCS	+=	storage_directory.c
SRCS	+=	storage_transaction.c
CFLAGS	+=	-I ../tar/storage

# Client-server protocol layer
CFLAGS	+=	-I ../lib/netpacket

# Packet transport layer
CFLAGS	+=	-I ../lib/netproto

# Network layer
CFLAGS	+=	-I ../lib/network

# Data structures
CFLAGS	+=	-I ../lib/datastruct

# Cryptographic code
CFLAGS	+=	-I ../lib/crypto

# Keyfile handling code
CFLAGS	+=	-I ../lib/keyfile

# Utility code
CFLAGS	+=	-I ../lib/util

# Compiler flags for profiling
.if defined(PROFILE)
CFLAGS	+=	-g -pg -DPROFILE
.endif

# Debugging flags
.if defined(DEBUG)
CFLAGS	+=	-g
CFLAGS	+=	-DDEBUG
CFLAGS	+=	-O1
.endif
.if defined(DEBUG_SELECTSTATS)
CFLAGS	+=	-DDEBUG_SELECTSTATS
.endif

.include <bsd.prog.mk>
