makefile (1410B)
1 # Interface: 2 # make 3 # make build 4 # make format 5 # make run 6 7 # Compiler 8 CC=gcc 9 # CC=tcc # <= faster compilation 10 11 # Main file 12 13 SRC_ONE_THREAD=./samples-one-thread.c 14 OUTPUT_ONE_THREAD=out/samples-one-thread 15 16 ## Dependencies 17 # Has no dependencies 18 MATH=-lm 19 20 ## Flags 21 DEBUG= #'-g' 22 STANDARD=-std=c99 23 WARNINGS=-Wall 24 OPTIMIZED=-O3 #-O3 actually gives better performance than -Ofast, at least for this version 25 OPENMP=-fopenmp 26 27 ## Formatter 28 STYLE_BLUEPRINT=webkit 29 FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) 30 31 ## make build 32 build: $(SRC_ONE_THREAD) 33 mkdir -p out 34 $(CC) $(OPTIMIZED) $(DEBUG) $(SRC_ONE_THREAD) $(OPENMP) $(MATH) -o $(OUTPUT_ONE_THREAD) 35 36 format: $(SRC_ONE_THREAD) 37 $(FORMATTER) $(SRC_ONE_THREAD) 38 39 run: $(SRC_ONE_THREAD) $(OUTPUT_ONE_THREAD) 40 ./$(OUTPUT_ONE_THREAD) 41 42 time-linux: 43 @echo "Requires /bin/time, found on GNU/Linux systems" && echo 44 @echo "Running 100x and taking avg time: $(OUTPUT_ONE_THREAD)" 45 @t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT_ONE_THREAD); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time: |" | sed 's|$$|ms|' && echo 46 47 time-linux-simple: 48 @echo "Requires /bin/time, found on GNU/Linux systems" && echo 49 /bin/time -f "Time: %es" ./$(OUTPUT_ONE_THREAD) && echo 50 51 debian-install-dependencies: 52 sudo apt-get install libomp-dev 53