diff --git a/.drone.yml b/.drone.yml index 56e8554..290d8e7 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,14 +1,27 @@ --- kind: pipeline type: docker -name: default +name: build-gcc steps: -- name: build - image: ubuntu:20.04 - commands: - - apt update - - DEBIAN_FRONTEND=noninteractive apt install -y gcc make - - make clean - - make + - name: build + image: ubuntu:20.04 + commands: + - apt update + - DEBIAN_FRONTEND=noninteractive apt install -y gcc make + - make clean + - make CC=gcc CFLAGS="-Wall -Werror -Wno-unknown-warning-option -Wno-packed-bitfield-compat" +--- +kind: pipeline +type: docker +name: build-clang + +steps: + - name: build + image: ubuntu:20.04 + commands: + - apt update + - DEBIAN_FRONTEND=noninteractive apt install -y clang make + - make clean + - make CC=clang CFLAGS="-Wall -Werror -Wno-unknown-warning-option -Wno-packed-bitfield-compat" ... diff --git a/Makefile b/Makefile index dab6e5e..4666864 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,13 @@ +CC=cc +CFLAGS=-Wall -Wno-unknown-warning-option -Wno-packed-bitfield-compat default: fm10k-dump fm10k-dump.o: fm10k-dump.c - gcc -c fm10k-dump.c -o fm10k-dump.o -Wall -Wno-packed-bitfield-compat + $(CC) -c fm10k-dump.c -o fm10k-dump.o $(CFLAGS) fm10k-dump: fm10k-dump.o - gcc fm10k-dump.o -o fm10k-dump -Wall + $(CC) fm10k-dump.o -o fm10k-dump $(CFLAGS) clean: -rm -f fm10k-dump diff --git a/README.md b/README.md index 1a282d8..d37eb03 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Utility that allows dumping the SPI Flash Non-Volatile Memory of the FM10000 family of cards. ## Requirements -* GCC >= 4.4.0 +* GCC >= 4.4.0 or clang * make * [fm10k kernel module](https://git.gammaspectra.live/FM10K/fm10k) compiled with UIO. * `# cd src && make clean && make -j $(nproc) CONFIG_UIO=1 && make install CONFIG_UIO=1` @@ -11,7 +11,8 @@ Utility that allows dumping the SPI Flash Non-Volatile Memory of the FM10000 fam * If this works an UIO device (`/dev/uio0`) will exist. If not, check your bifurcation settings and/or whether the slot supports 16x PCIe 3.0 ## Compilation -* `make clean && make` +* `$ make clean && make` +* You can specify whether to use gcc or clang this way: `$ make CC=gcc` / `$ make CC=clang` * An executable named `./fm10k-dump` should now exist. ## Usage example diff --git a/fm10k-dump.c b/fm10k-dump.c index 6088f4d..5fb2651 100644 --- a/fm10k-dump.c +++ b/fm10k-dump.c @@ -57,7 +57,7 @@ #define FM10K_SPI_HEADER_COMMAND_READ_MANUFACTURER_INFORMATION 0x9F /* Test for GCC >= 4.4.0, see https://gcc.gnu.org/gcc-4.4/changes.html : Packed bit-fields of type char were not properly bit-packed on many targets prior to GCC 4.4 */ -#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 4)) +#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 4)) || __clang__ typedef union { struct {