X-Git-Url: https://piware.de/gitweb/?p=learn-rust.git;a=blobdiff_plain;f=call-c-from-rust%2FMakefile;h=cbeefdd888c5aab771bb9475593d717fd61aa873;hp=583e2f2ff345b1df003117a3bf18418b1601b2b9;hb=HEAD;hpb=225c6b2420e01dca1f3a570d3ed664b825cf883c diff --git a/call-c-from-rust/Makefile b/call-c-from-rust/Makefile index 583e2f2..cbeefdd 100644 --- a/call-c-from-rust/Makefile +++ b/call-c-from-rust/Makefile @@ -1,7 +1,7 @@ CFLAGS += $(shell pkg-config --cflags mount) LIBMOUNT = $(shell pkg-config --libs mount) -all: c-mounts c-langinfo +all: c-mounts c-langinfo target/debug/learning-c-from-rust c-mounts: c-mounts.o $(CC) -Wall -o $@ $^ $(LIBMOUNT) @@ -9,13 +9,25 @@ c-mounts: c-mounts.o c-langinfo: c-langinfo.o $(CC) -Wall -o $@ $^ +# HACK: does not find stdarg.h (through stdio.h), missing size_t +# also avoid hundreds of "should have an upper camel case name" warnings +src/libmount.rs: + sed 's/#include.*stdio.h.*/typedef unsigned long size_t;/' /usr/include/libmount/libmount.h > libmount-hack.h + bindgen libmount-hack.h -- -I/usr/include/linux/ > $@.tmp + (echo '#![allow(non_camel_case_types,non_upper_case_globals,dead_code)]'; cat $@.tmp) > $@ + rm libmount-hack.h $@.tmp + +target/debug/learning-c-from-rust: src/libmount.rs src/main.rs + cargo build + clean: - rm -f c-mounts c-langinfo *.o + rm -f c-mounts c-langinfo *.o src/libmount.rs run: all LANG=en_US.UTF-8 ./c-langinfo LANG=en_GB.UTF-8 ./c-langinfo LANG=en_IE.UTF-8 ./c-langinfo ./c-mounts + target/debug/learning-c-from-rust .PHONY: clean run