Basic set of changes to compile on FreeBSD that are hard to shim around in compat headers. - The compare function passed to fts_open takes (const FTSENT * const *) arguments in FreeBSD. - Add a NO_SHA384 option since FreeBSD has support for 256 and 512 but not 384. (It might make sense to allow all three to be disabled individually.) - Explicitly include in compare.c. The required symbols are not pulled in by another header in FreeBSD. - Don't declare sflag twice. - FreeBSD has __dead2 not __dead. Index: create.c =================================================================== --- create.c (revision 240705) +++ create.c (revision 240706) @@ -83,7 +83,7 @@ static mode_t mode; static u_long flags; -static int dcmp(const FTSENT **, const FTSENT **); +static int dcmp(const FTSENT * const *, const FTSENT * const *); static void output(int *, const char *, ...) __attribute__((__format__(__printf__, 2, 3))); static int statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *, u_long *); @@ -242,12 +242,14 @@ output(&indent, "sha256=%s", digestbuf); free(digestbuf); } +#ifndef NO_SHA384 if (keys & F_SHA384 && S_ISREG(p->fts_statp->st_mode)) { if ((digestbuf = SHA384_File(p->fts_accpath, NULL)) == NULL) mtree_err("%s: SHA384_File failed: %s", p->fts_accpath, strerror(errno)); output(&indent, "sha384=%s", digestbuf); free(digestbuf); } +#endif if (keys & F_SHA512 && S_ISREG(p->fts_statp->st_mode)) { if ((digestbuf = SHA512_File(p->fts_accpath, NULL)) == NULL) mtree_err("%s: SHA512_File failed: %s", p->fts_accpath, strerror(errno)); @@ -398,7 +400,7 @@ * Keep this in sync with nodecmp() in spec.c. */ static int -dcmp(const FTSENT **a, const FTSENT **b) +dcmp(const FTSENT * const *a, const FTSENT * const *b) { if (S_ISDIR((*a)->fts_statp->st_mode)) { Index: compare.c =================================================================== --- compare.c (revision 240705) +++ compare.c (revision 240706) @@ -43,6 +43,7 @@ #endif /* not lint */ #include +#include #include #include @@ -462,6 +463,7 @@ free(digestbuf); } } +#ifndef NO_SHA384 if (s->flags & F_SHA384) { if ((digestbuf = SHA384_File(p->fts_accpath, NULL)) == NULL) { LABEL; @@ -478,6 +480,7 @@ free(digestbuf); } } +#endif /* ! NO_SHA384 */ if (s->flags & F_SHA512) { if ((digestbuf = SHA512_File(p->fts_accpath, NULL)) == NULL) { LABEL; Index: crc.c =================================================================== --- crc.c (revision 240705) +++ crc.c (revision 240706) @@ -114,7 +114,6 @@ * locations to store the crc and the number of bytes read. It returns 0 on * success and 1 on failure. Errno is set on failure. */ -extern int sflag; u_int32_t crc_total = ~0; /* The crc over a number of files. */ int Index: extern.h =================================================================== --- extern.h (revision 240705) +++ extern.h (revision 240706) @@ -60,7 +60,7 @@ void dump_nodes(const char *, NODE *, int); void init_excludes(void); int matchtags(NODE *); -__dead __printflike(1,2) void mtree_err(const char *, ...); +__dead2 __printflike(1,2) void mtree_err(const char *, ...); const char *nodetype(u_int); u_int parsekey(const char *, int *); void parsetags(slist_t *, char *); Index: mtree.c =================================================================== --- mtree.c (revision 240705) +++ mtree.c (revision 240706) @@ -63,7 +63,7 @@ rflag, sflag, tflag, uflag, Uflag; char fullpath[MAXPATHLEN]; -__dead static void usage(void); +__dead2 static void usage(void); int main(int argc, char **argv)