diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-09-13 15:50:28 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-09-13 15:54:09 +0200 |
| commit | 08f15adc6cd9de0db8244963177505cfdd634504 (patch) | |
| tree | 6d1001690896aa92fa1a07821ece65b6b116c1aa /lang/c/Makefile | |
| parent | 1de9228fda28826c337ac09201586de1f2f248b9 (diff) | |
| download | farga-08f15adc6cd9de0db8244963177505cfdd634504.tar.gz farga-08f15adc6cd9de0db8244963177505cfdd634504.zip | |
lang/c: Add an example on flexible array checks
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'lang/c/Makefile')
| -rw-r--r-- | lang/c/Makefile | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lang/c/Makefile b/lang/c/Makefile new file mode 100644 index 0000000..4979e7a --- /dev/null +++ b/lang/c/Makefile @@ -0,0 +1,56 @@ +## +# By default everything is silent. If you want to change this behavior, simply +# assign V=1 when calling make. + +V = +ifeq ($(strip $(V)),) + E = @echo + Q = @ +else + E = @\# + Q = +endif + +## +# Compile options. You can use CROSS_COMPILE just like on the Linux Kernel. + +CC = $(CROSS_COMPILE)gcc +LD = $(CROSS_COMPILE)ld +CCFLAGS = -Werror -Wpedantic -Wall -Wextra -Wcast-align -Wcast-qual -Winit-self \ + -Wmissing-include-dirs -Wredundant-decls -Wshadow -Wsign-conversion \ + -Wswitch-default -Wundef -Wunreachable-code -Wmissing-noreturn \ + -D_FORTIFY_SOURCE=3 -fstrict-flex-arrays=3 -fsanitize=bounds-strict + # NOTE: last line: special flags for the examples :) +LDFLAGS = + + +# You can pass an optional `DEBUG` variable to manipulate the build type. +DEBUG = +ifeq ($(strip $(DEBUG)),) + CCFLAGS += -O3 +else + CCFLAGS += -g +endif + +## +# Paths. + +SRC = $(wildcard *.c) +EXES = $(SRC:.c=) + +## +# Targets + +.PHONY: all +all: clean $(EXES) + +.PHONY: build +build: $(EXES) + +.c: + $(E) " CC " $(*F) + $(Q) $(CC) $(CCFLAGS) $< -o $@ + +.PHONY: clean +clean: + $(Q) rm -f $(EXES) |
