advent2025

Advent of Code 2025 Solutions
git clone git://bsandro.tech/advent2025
Log | Files | Refs | README | LICENSE

Makefile (1034B)


      1 .SUFFIXES:
      2 MAKEFLAGS+=-rR
      3 
      4 UNAME:=$(shell uname -m)
      5 OS:=$(shell uname -s)
      6 
      7 CFLAGS=-std=c99 -Wall -Wextra -I.
      8 ifeq ($(DEBUG),1)
      9 CFLAGS+=-O0 -g
     10 else
     11 CFLAGS+=-O3 -ffast-math
     12 LTO=-flto
     13 endif
     14 
     15 ifeq ($(OS),NetBSD)
     16 CFLAGS+=-I/usr/pkg/include
     17 endif
     18 
     19 ifeq ($(OS),Darwin)
     20 CFLAGS+=-I/opt/homebrew/include
     21 endif
     22 
     23 ifeq ($(UNAME),riscv64)
     24 CFLAGS+=-mtune=sifive-u74
     25 else ifeq ($(UNAME),Power Macintosh)
     26 CFLAGS+=-mtune=native $(LTO)
     27 else ifeq ($(UNAME),i386)
     28 CFLAGS+=-mtune=native
     29 else
     30 CFLAGS+=-march=native $(LTO)
     31 endif
     32 
     33 LDFLAGS=-lc -lm
     34 
     35 ifeq ($(OS),NetBSD)
     36 LDFLAGS+=-L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib
     37 endif
     38 
     39 ifeq ($(OS),Darwin)
     40 LDFLAGS+=-L/opt/local/lib
     41 endif
     42 
     43 ifeq ($(GLPK),1)
     44 LDFLAGS+=-lglpk
     45 endif
     46 
     47 ifneq ($(shell which clang),)
     48 CC=clang
     49 else ifneq ($(shell which gcc-mp-14),)
     50 CC=gcc-mp-14
     51 else
     52 CC=cc
     53 endif
     54 
     55 .PHONY: clean
     56 
     57 %+run: %.bin
     58 	./$< < inputs/$*.txt
     59 
     60 %+test: %.bin
     61 	./$< < inputs/$*_test.txt
     62 
     63 %+test1: %.bin
     64 	./$< < inputs/$*_test1.txt
     65 
     66 .SECONDARY:
     67 %: %.bin
     68 	@:
     69 
     70 %.bin: %.c
     71 	${CC} $< $(CFLAGS) $(LDFLAGS) -o $@
     72 
     73 clean:
     74 	rm -f ./*.bin