diff options
author | Thomas Bertschinger <tahbertschinger@gmail.com> | 2024-01-15 23:41:00 -0700 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-16 01:46:41 -0500 |
commit | 0a284fc4ffcbb46f0a4b921415ef12a9c75fa05c (patch) | |
tree | 22aa82b7448833713ca975eb3c241f607742fc78 /Makefile | |
parent | 249bf7b9d446092e1b744c366b7e8c4563a437f0 (diff) |
convert main() from C to Rust
This moves the main() function from C to Rust. It also updates the name
of the Rust package from "bcachefs-rust" to "bcachefs-tools".
Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 21 |
1 files changed, 6 insertions, 15 deletions
@@ -77,6 +77,7 @@ PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd libudev libkeyu ifdef BCACHEFS_FUSE PKGCONFIG_LIBS+="fuse3 >= 3.7" CFLAGS+=-DBCACHEFS_FUSE + export RUSTFLAGS=--cfg fuse endif PKGCONFIG_CFLAGS:=$(shell $(PKG_CONFIG) --cflags $(PKGCONFIG_LIBS)) @@ -172,25 +173,15 @@ OBJS:=$(SRCS:.c=.o) $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< BCACHEFS_DEPS=libbcachefs.a +RUST_SRCS:=$(shell find rust-src/src rust-src/bch_bindgen/src -type f -iname '*.rs') -ifndef NO_RUST - BCACHEFS_DEPS+=rust-src/target/release/libbcachefs_rust.a -else - CFLAGS+=-DBCACHEFS_NO_RUST -endif - -bcachefs: $(BCACHEFS_DEPS) - @echo " [LD] $@" - $(Q)$(CC) $(LDFLAGS) -Wl,--whole-archive $+ $(LOADLIBES) -Wl,--no-whole-archive $(LDLIBS) -o $@ +bcachefs: $(BCACHEFS_DEPS) $(RUST_SRCS) + $(CARGO_BUILD) libbcachefs.a: $(filter-out ./tests/%.o, $(OBJS)) @echo " [AR] $@" $(Q)ar -rc $@ $+ -RUST_SRCS:=$(shell find rust-src/src rust-src/bch_bindgen/src -type f -iname '*.rs') -rust-src/target/release/libbcachefs_rust.a: $(RUST_SRCS) - $(CARGO_BUILD) - tests/test_helper: $(filter ./tests/%.o, $(OBJS)) @echo " [LD] $@" $(Q)$(CC) $(LDFLAGS) $+ $(LOADLIBES) $(LDLIBS) -o $@ @@ -210,7 +201,7 @@ cmd_version.o : .version install: INITRAMFS_HOOK=$(INITRAMFS_DIR)/hooks/bcachefs install: INITRAMFS_SCRIPT=$(INITRAMFS_DIR)/scripts/local-premount/bcachefs install: bcachefs $(optional_install) - $(INSTALL) -m0755 -D bcachefs -t $(DESTDIR)$(ROOT_SBINDIR) + $(INSTALL) -m0755 -D rust-src/target/release/bcachefs -t $(DESTDIR)$(ROOT_SBINDIR) $(INSTALL) -m0644 -D bcachefs.8 -t $(DESTDIR)$(PREFIX)/share/man/man8/ $(INSTALL) -m0755 -D initramfs/script $(DESTDIR)$(INITRAMFS_SCRIPT) $(INSTALL) -m0755 -D initramfs/hook $(DESTDIR)$(INITRAMFS_HOOK) @@ -233,7 +224,7 @@ install_systemd: $(systemd_services) $(systemd_libexecfiles) .PHONY: clean clean: @echo "Cleaning all" - $(Q)$(RM) bcachefs libbcachefs.a tests/test_helper .version *.tar.xz $(OBJS) $(DEPS) $(DOCGENERATED) + $(Q)$(RM) libbcachefs.a tests/test_helper .version *.tar.xz $(OBJS) $(DEPS) $(DOCGENERATED) $(Q)$(CARGO_CLEAN) $(Q)$(RM) -f $(built_scripts) |