2023-09-08 20:42:06 +00:00
|
|
|
# Interface:
|
|
|
|
# make
|
|
|
|
# make build
|
|
|
|
# make format
|
|
|
|
|
|
|
|
# Compiler
|
|
|
|
CC=gcc
|
|
|
|
# CC=tcc # <= faster compilation
|
|
|
|
|
|
|
|
# Main file
|
|
|
|
SRC=wc.c
|
|
|
|
OUTPUT=wc
|
|
|
|
|
|
|
|
## Flags
|
|
|
|
DEBUG= #'-g'
|
|
|
|
STANDARD=-std=c99
|
|
|
|
WARNINGS=-Wall
|
|
|
|
OPTIMIZED=-O0
|
|
|
|
# OPTIMIZED=-O3 #-Ofast
|
|
|
|
|
|
|
|
## Formatter
|
|
|
|
STYLE_BLUEPRINT=webkit
|
|
|
|
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
|
|
|
|
|
|
|
|
## make build
|
|
|
|
build: $(SRC)
|
|
|
|
$(CC) $(OPTIMIZED) $(DEBUG) $(SRC) -o $(OUTPUT)
|
|
|
|
|
|
|
|
format: $(SRC)
|
|
|
|
$(FORMATTER) $(SRC)
|
2023-09-08 21:02:54 +00:00
|
|
|
|
|
|
|
test: $(OUTPUT)
|
|
|
|
/bin/echo -e "123\n45 67" | ./$(OUTPUT)
|
2023-09-08 21:22:57 +00:00
|
|
|
/bin/echo -n "" | ./wc
|
|
|
|
./$(OUTPUT) $(SRC)
|
|
|
|
./$(OUTPUT) nonexistent_file || true
|