advent2021

Advent of Code 2021 Solutions
git clone git://bsandro.tech/advent2021
Log | Files | Refs

commit cf69ab1ab4a79faea843cc69927e55a00953f11e
parent d195f90ecad9292e26c8bf2249b52606ad06b87e
Author: bsandro <brian.drosan@gmail.com>
Date:   Wed,  1 Dec 2021 18:15:34 +0200

GNU Makefile only (use gmake for BSD)

Diffstat:
A.gitignore | 1+
Mday01/Makefile | 24++++++++++++------------
2 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1 @@ +*.o diff --git a/day01/Makefile b/day01/Makefile @@ -1,23 +1,23 @@ -NAME!=basename ${PWD} +NAME=$(shell basename ${PWD}) CC=cc -SRC!=ls *.c -DEPS!=find . -type f -name "*.h" -maxdepth 1 -OBJ:=${SRC:.c=.o} +SRC=$(wildcard *.c) +DEPS:=$(wildcard *.h) +OBJ:=$(SRC:.c=.o) CFLAGS=-O0 -std=c99 -g -Werror -Wall -Wextra -I. -all: ${NAME} +all: $(NAME) .PHONY: clean run clean: - @rm -f ${OBJ} ${NAME} + rm -f $(OBJ) $(NAME) -$(OBJ): ${SRC} ${DEPS} - @${CC} ${CFLAGS} -c $< -o $@ +%.o : %.c $(DEPS) + $(CC) $(CFLAGS) -c $< -o $@ -${NAME}: ${OBJ} - @${CC} ${OBJ} -o $@ ${LDFLAGS} +$(NAME): $(OBJ) + $(CC) $(OBJ) -o $@ $(LDFLAGS) -run: ${NAME} - @./${NAME} input.txt +run: $(NAME) + ./$(NAME) input.txt