From 920f830facb072ed91500ac951e09909dd69355f Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Tue, 11 Oct 2022 17:44:06 +0200 Subject: [PATCH] Re-use 2019 latest Makefile --- 2020/day19/Makefile | 94 +++++++++++++++++++++++++++++++++++++-------- 2020/day24/Makefile | 94 +++++++++++++++++++++++++++++++++++++-------- 2 files changed, 154 insertions(+), 34 deletions(-) diff --git a/2020/day19/Makefile b/2020/day19/Makefile index 224acfb..b66bb2c 100644 --- a/2020/day19/Makefile +++ b/2020/day19/Makefile @@ -1,30 +1,90 @@ -INPUT := INPUT.txt -SHELL := /bin/bash -CFLAGS := -w -g -#CFLAGS := -w -g -pg -#CFLAGS := -w -O3 -TIME := \time -f "\ttime: %E real, %U user, %S sys\n\tcontext-switch:\t%c+%w, page-faults: %F+%R\n" +# AOC daily Makefile - GNU make only. +# +# Copyright (C) 2022 Bruno Raoult ("br") +# Licensed under the GNU General Public License v3.0 or later. +# Some rights reserved. See COPYING. +# +# You should have received a copy of the GNU General Public License along with this +# program. If not, see . +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +INPUT := INPUT.txt +SHELL := /bin/bash + +CC := gcc +BEAR := bear + +#LIB := aoc_$(shell uname -m) +#INCDIR := ../include +INCDIR := . +#LIBDIR := ../lib +#LDFLAGS := -L$(LIBDIR) +#LDLIB := -l$(LIB) -lm +#LDLIB := -l$(LIB) + +#export LD_LIBRARY_PATH = $(LIBDIR) + +CFLAGS += -std=gnu11 +CFLAGS += -O2 +CFLAGS += -g +# for gprof +#CFLAGS += -pg +CFLAGS += -Wall +CFLAGS += -Wextra +CFLAGS += -march=native +# Next one may be useful for valgrind (some invalid instructions) +# CFLAGS += -mno-tbm +CFLAGS += -Wmissing-declarations +CFLAGS += -Wno-unused-result + +#CFLAGS += -DDEBUG_DEBUG # activate general debug (debug.c) +#CFLAGS += -DDEBUG_POOL # memory pools management + +TIME := \time -f "\ttime: %E real, %U user, %S sys\n\tcontext-switch:\t%c+%w, page-faults: %F+%R\n" export PATH := .:$(PATH) -.PHONY: clean all compile deploy ex1 ex2 +.PHONY: clean all compile assembly memcheck memcheck1 memcheck2 ex1 ex2 bear all: ex1 ex2 -output: - @$(MAKE) --no-print-directory all 2>&1 > OUTPUT +memcheck: memcheck1 memcheck2 -compile: ex1-c ex2-c +memcheck1: aoc-c + @valgrind -q -s --track-origins=yes aoc-c -p 1 < $(INPUT) -ex1: +memcheck2: aoc-c + @valgrind -q -s --track-origins=yes aoc-c -p 2 < $(INPUT) + +compile: aoc-c + +assembly: aoc-c.s + +ex1: aoc-c @$(TIME) ex1.bash < $(INPUT) 2>&1 - @#$(TIME) ex1-c 2020 < $(INPUT) 2>&1 + @$(TIME) aoc-c -p 1 < $(INPUT) 2>&1 -ex2: +ex2: aoc-c @$(TIME) ex2.bash < $(INPUT) 2>&1 - @#$(TIME) ex1-c 30000000 < $(INPUT) 2>&1 + @$(TIME) aoc-c -p 2 < $(INPUT) 2>&1 clean: - @rm -f ex1-c ex2-c core + @rm -f aoc-c core* vgcore* gmon.out aoc-c.s compile_commands.json -deploy: - @$(MAKE) -C .. deploy +.c: + @echo compiling $< + $(CC) $(CFLAGS) $(LDFLAGS) -I $(INCDIR) $< $(LDLIB) -o $@ + +# generate pre-processed file (.i) and assembler (.s) +%.i: %.c + @echo generating $@ + @$(CC) -E $(CFLAGS) -I $(INCDIR) $< -o $@ + +%.s: %.c + @echo generating $@ + @$(CC) -S -fverbose-asm $(CFLAGS) -I $(INCDIR) $< -o $@ + +bear: clean + @$(BEAR) -- make compile + @touch .ccls-root diff --git a/2020/day24/Makefile b/2020/day24/Makefile index 224acfb..b66bb2c 100644 --- a/2020/day24/Makefile +++ b/2020/day24/Makefile @@ -1,30 +1,90 @@ -INPUT := INPUT.txt -SHELL := /bin/bash -CFLAGS := -w -g -#CFLAGS := -w -g -pg -#CFLAGS := -w -O3 -TIME := \time -f "\ttime: %E real, %U user, %S sys\n\tcontext-switch:\t%c+%w, page-faults: %F+%R\n" +# AOC daily Makefile - GNU make only. +# +# Copyright (C) 2022 Bruno Raoult ("br") +# Licensed under the GNU General Public License v3.0 or later. +# Some rights reserved. See COPYING. +# +# You should have received a copy of the GNU General Public License along with this +# program. If not, see . +# +# SPDX-License-Identifier: GPL-3.0-or-later +# + +INPUT := INPUT.txt +SHELL := /bin/bash + +CC := gcc +BEAR := bear + +#LIB := aoc_$(shell uname -m) +#INCDIR := ../include +INCDIR := . +#LIBDIR := ../lib +#LDFLAGS := -L$(LIBDIR) +#LDLIB := -l$(LIB) -lm +#LDLIB := -l$(LIB) + +#export LD_LIBRARY_PATH = $(LIBDIR) + +CFLAGS += -std=gnu11 +CFLAGS += -O2 +CFLAGS += -g +# for gprof +#CFLAGS += -pg +CFLAGS += -Wall +CFLAGS += -Wextra +CFLAGS += -march=native +# Next one may be useful for valgrind (some invalid instructions) +# CFLAGS += -mno-tbm +CFLAGS += -Wmissing-declarations +CFLAGS += -Wno-unused-result + +#CFLAGS += -DDEBUG_DEBUG # activate general debug (debug.c) +#CFLAGS += -DDEBUG_POOL # memory pools management + +TIME := \time -f "\ttime: %E real, %U user, %S sys\n\tcontext-switch:\t%c+%w, page-faults: %F+%R\n" export PATH := .:$(PATH) -.PHONY: clean all compile deploy ex1 ex2 +.PHONY: clean all compile assembly memcheck memcheck1 memcheck2 ex1 ex2 bear all: ex1 ex2 -output: - @$(MAKE) --no-print-directory all 2>&1 > OUTPUT +memcheck: memcheck1 memcheck2 -compile: ex1-c ex2-c +memcheck1: aoc-c + @valgrind -q -s --track-origins=yes aoc-c -p 1 < $(INPUT) -ex1: +memcheck2: aoc-c + @valgrind -q -s --track-origins=yes aoc-c -p 2 < $(INPUT) + +compile: aoc-c + +assembly: aoc-c.s + +ex1: aoc-c @$(TIME) ex1.bash < $(INPUT) 2>&1 - @#$(TIME) ex1-c 2020 < $(INPUT) 2>&1 + @$(TIME) aoc-c -p 1 < $(INPUT) 2>&1 -ex2: +ex2: aoc-c @$(TIME) ex2.bash < $(INPUT) 2>&1 - @#$(TIME) ex1-c 30000000 < $(INPUT) 2>&1 + @$(TIME) aoc-c -p 2 < $(INPUT) 2>&1 clean: - @rm -f ex1-c ex2-c core + @rm -f aoc-c core* vgcore* gmon.out aoc-c.s compile_commands.json -deploy: - @$(MAKE) -C .. deploy +.c: + @echo compiling $< + $(CC) $(CFLAGS) $(LDFLAGS) -I $(INCDIR) $< $(LDLIB) -o $@ + +# generate pre-processed file (.i) and assembler (.s) +%.i: %.c + @echo generating $@ + @$(CC) -E $(CFLAGS) -I $(INCDIR) $< -o $@ + +%.s: %.c + @echo generating $@ + @$(CC) -S -fverbose-asm $(CFLAGS) -I $(INCDIR) $< -o $@ + +bear: clean + @$(BEAR) -- make compile + @touch .ccls-root