add makefile to git
This commit is contained in:
parent
b8064e8309
commit
075f0ca632
2 changed files with 40 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -7,4 +7,6 @@
|
|||
# Unignore all dirs
|
||||
!*/
|
||||
|
||||
!Makefile
|
||||
|
||||
*.o
|
38
day 1/Makefile
Normal file
38
day 1/Makefile
Normal file
|
@ -0,0 +1,38 @@
|
|||
# select all cpp files, for future use
|
||||
SRC := ${wildcard *.c}
|
||||
BIN := $(SRC:.c=)
|
||||
|
||||
# -pedantic means using gnu extentions will throw an error
|
||||
# this allows for better code portability between compilers
|
||||
CFLAGS := -std=c17
|
||||
CFLAGS_ERRORS := -Werror -Wall -Wextra -Wconversion -Wdouble-promotion -Wunreachable-code -Wshadow -Wpedantic -pedantic-errors -pedantic
|
||||
|
||||
# debug is enabled by default
|
||||
# debug can be disabled with `make DEBUG=0`
|
||||
DEBUG := 1
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
# -Og compiles with debug specific optimizations
|
||||
# -g3 compiles with max debug information
|
||||
CFLAGS += -Og -g3
|
||||
else
|
||||
# -O3 compiles with extreme optimizations for performance
|
||||
# -flto compiles with link time optimizations (LTO), supposed to improve performance by ~5%
|
||||
CFLAGS += -O3 -flto
|
||||
# -s when run on the linker will strip out debug symbols for a smaller file size
|
||||
LDFLAGS += -s -flto
|
||||
endif
|
||||
|
||||
# I believe using c++ is better since not every installation has gcc
|
||||
# this can always be overridden with `make CC=gcc` if needed
|
||||
CC := cc
|
||||
|
||||
all: $(BIN)
|
||||
|
||||
.c:
|
||||
$(CC) $(CFLAGS) $(CFLAGS_ERRORS) $(LDFLAGS) -o $@ $^
|
||||
|
||||
clean:
|
||||
$(DEL) $(TARGET) $(OBJ)
|
||||
|
||||
.PHONY: clean
|
Loading…
Reference in a new issue