From 9a486ad03777b3198b6cbe7b649531dc12693e08 Mon Sep 17 00:00:00 2001 From: William Clark Date: Thu, 25 Apr 2024 22:34:17 +0100 Subject: [PATCH] makefile change --- .gitignore | 3 ++- Makefile | 21 +++++++++++++-------- README.md | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 02f9eb1..ec89c04 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ lis3dh -.vscode/ \ No newline at end of file +.vscode/ +*.o \ No newline at end of file diff --git a/Makefile b/Makefile index a30d1ed..41e1420 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,17 @@ CC=gcc -CFLAGS=-O0 -g3 -ggdb -std=c89 -W -Werror -Wall -Wextra -Wpedantic -pedantic-errors -Wformat-signedness -I. -CFLAGS+=-Wlogical-op -Wmissing-declarations -Wswitch-default -Wundef -Wformat=2 -LFLAGS=-lm -CFILES=$(wildcard *.c) -BINFILE=lis3dh +OPT=-O2 -std=c89 -Wall -Wextra -W -pedantic +CFLAGS=-I. $(OPT) +CFILES=$(wildcard ./*.c) +OBJECTS=$(patsubst %.c,%.o, $(CFILES)) +BINARY=lis3dh -all: - $(CC) $(CFLAGS) $(CFILES) -o $(BINFILE) $(LFLAGS) +all: $(BINARY) + +$(BINARY): $(OBJECTS) + $(CC) $^ -o $@ + +%.o:%.c + $(CC) $(CFLAGS) -c $< -o $@ clean: - rm -rf $(BINFILE) + @rm -rf $(OBJECTS) $(BINARY) \ No newline at end of file diff --git a/README.md b/README.md index 6a0a350..59279df 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # LIS3DH -A C89 driver for the 3-axis accelerometer LIS3DH. Supports both I2C and SPI. +A C linux driver for the 3-axis accelerometer LIS3DH. Supports both I2C and SPI. ### Features > - FIFO