build: require explicit include paths for libbcachefs/

This removes the implicit `-I libbcachefs` argument to $(CC), which in turn
requires a set of minor changes throughout the tools. There are two advantages
to this setup:

    1) It is (arguably) easier to read, since the location of bcachefs includes
    are easier to understand at a glance ("where does util.h live?")

    2) It removes the need for a hack to include glibc's copy of
    dirent.h explicitly via '/usr/include/dirent.h', because libbcachefs/
    *also* has a dirent.h file and the compiler cannot disambiguate them.
    This has some ramifications on systems where /usr/include may not
    exist, such as NixOS.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2017-11-26 19:29:00 -06:00
parent 04035f0c7e
commit 997bb216aa
13 changed files with 39 additions and 39 deletions

View File

@ -4,7 +4,7 @@ INSTALL=install
CFLAGS+=-std=gnu89 -O2 -g -MMD -Wall \ CFLAGS+=-std=gnu89 -O2 -g -MMD -Wall \
-Wno-pointer-sign \ -Wno-pointer-sign \
-fno-strict-aliasing \ -fno-strict-aliasing \
-I. -Iinclude -Ilibbcachefs \ -I. -Iinclude \
-D_FILE_OFFSET_BITS=64 \ -D_FILE_OFFSET_BITS=64 \
-D_GNU_SOURCE \ -D_GNU_SOURCE \
-D_LGPL_SOURCE \ -D_LGPL_SOURCE \

View File

@ -7,7 +7,7 @@
#include <string.h> #include <string.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "bcachefs_ioctl.h" #include "libbcachefs/bcachefs_ioctl.h"
#include "cmds.h" #include "cmds.h"
int cmd_assemble(int argc, char *argv[]) int cmd_assemble(int argc, char *argv[])

View File

@ -8,14 +8,14 @@
#include "qcow2.h" #include "qcow2.h"
#include "tools-util.h" #include "tools-util.h"
#include "bcachefs.h" #include "libbcachefs/bcachefs.h"
#include "alloc.h" #include "libbcachefs/alloc.h"
#include "btree_cache.h" #include "libbcachefs/btree_cache.h"
#include "btree_iter.h" #include "libbcachefs/btree_iter.h"
#include "buckets.h" #include "libbcachefs/buckets.h"
#include "error.h" #include "libbcachefs/error.h"
#include "journal.h" #include "libbcachefs/journal.h"
#include "super.h" #include "libbcachefs/super.h"
static void dump_usage(void) static void dump_usage(void)
{ {

View File

@ -12,10 +12,10 @@
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include "bcachefs_ioctl.h" #include "libbcachefs/bcachefs_ioctl.h"
#include "cmds.h" #include "cmds.h"
#include "libbcachefs.h" #include "libbcachefs.h"
#include "opts.h" #include "libbcachefs/opts.h"
#include "tools-util.h" #include "tools-util.h"
/* This code belongs under show_fs */ /* This code belongs under show_fs */

View File

@ -24,9 +24,9 @@
#include "cmds.h" #include "cmds.h"
#include "libbcachefs.h" #include "libbcachefs.h"
#include "crypto.h" #include "crypto.h"
#include "opts.h" #include "libbcachefs/opts.h"
#include "super-io.h" #include "libbcachefs/super-io.h"
#include "util.h" #include "libbcachefs/util.h"
#define OPTS \ #define OPTS \
t("bcachefs format - create a new bcachefs filesystem on one or more devices") \ t("bcachefs format - create a new bcachefs filesystem on one or more devices") \

View File

@ -1,8 +1,8 @@
#include "cmds.h" #include "cmds.h"
#include "error.h" #include "libbcachefs/error.h"
#include "libbcachefs.h" #include "libbcachefs.h"
#include "super.h" #include "libbcachefs/super.h"
#include "tools-util.h" #include "tools-util.h"
static void usage(void) static void usage(void)

View File

@ -3,7 +3,7 @@
#include <uuid/uuid.h> #include <uuid/uuid.h>
#include "cmds.h" #include "cmds.h"
#include "checksum.h" #include "libbcachefs/checksum.h"
#include "crypto.h" #include "crypto.h"
#include "libbcachefs.h" #include "libbcachefs.h"

View File

@ -1,4 +1,4 @@
#include </usr/include/dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <getopt.h> #include <getopt.h>
@ -24,16 +24,16 @@
#include <linux/dcache.h> #include <linux/dcache.h>
#include <linux/generic-radix-tree.h> #include <linux/generic-radix-tree.h>
#include <linux/xattr.h> #include <linux/xattr.h>
#include "bcachefs.h" #include "libbcachefs/bcachefs.h"
#include "btree_update.h" #include "libbcachefs/btree_update.h"
#include "buckets.h" #include "libbcachefs/buckets.h"
#include "dirent.h" #include "libbcachefs/dirent.h"
#include "fs.h" #include "libbcachefs/fs.h"
#include "inode.h" #include "libbcachefs/inode.h"
#include "io.h" #include "libbcachefs/io.h"
#include "str_hash.h" #include "libbcachefs/str_hash.h"
#include "super.h" #include "libbcachefs/super.h"
#include "xattr.h" #include "libbcachefs/xattr.h"
static char *dev_t_to_path(dev_t dev) static char *dev_t_to_path(dev_t dev)
{ {

View File

@ -11,7 +11,7 @@
#include <uuid/uuid.h> #include <uuid/uuid.h>
#include "bcachefs_ioctl.h" #include "libbcachefs/bcachefs_ioctl.h"
#include "cmds.h" #include "cmds.h"
int cmd_run(int argc, char *argv[]) int cmd_run(int argc, char *argv[])

View File

@ -15,7 +15,7 @@
#include <libscrypt.h> #include <libscrypt.h>
#include <uuid/uuid.h> #include <uuid/uuid.h>
#include "checksum.h" #include "libbcachefs/checksum.h"
#include "crypto.h" #include "crypto.h"
char *read_passphrase(const char *prompt) char *read_passphrase(const char *prompt)

View File

@ -12,12 +12,12 @@
#include <uuid/uuid.h> #include <uuid/uuid.h>
#include "bcachefs_format.h" #include "libbcachefs/bcachefs_format.h"
#include "checksum.h" #include "libbcachefs/checksum.h"
#include "crypto.h" #include "crypto.h"
#include "libbcachefs.h" #include "libbcachefs.h"
#include "opts.h" #include "libbcachefs/opts.h"
#include "super-io.h" #include "libbcachefs/super-io.h"
#define NSEC_PER_SEC 1000000000L #define NSEC_PER_SEC 1000000000L

View File

@ -4,9 +4,9 @@
#include <linux/uuid.h> #include <linux/uuid.h>
#include <stdbool.h> #include <stdbool.h>
#include "bcachefs_format.h" #include "libbcachefs/bcachefs_format.h"
#include "tools-util.h" #include "tools-util.h"
#include "vstructs.h" #include "libbcachefs/vstructs.h"
struct format_opts { struct format_opts {
char *label; char *label;

View File

@ -16,10 +16,10 @@
#include <blkid.h> #include <blkid.h>
#include <uuid/uuid.h> #include <uuid/uuid.h>
#include "bcachefs_ioctl.h" #include "libbcachefs/bcachefs_ioctl.h"
#include "linux/sort.h" #include "linux/sort.h"
#include "tools-util.h" #include "tools-util.h"
#include "util.h" #include "libbcachefs/util.h"
void die(const char *fmt, ...) void die(const char *fmt, ...)
{ {