squiggle.c

Self-contained Monte Carlo estimation in C99
Log | Files | Refs | README

makefile (1313B)


      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 SRC=test.c ../squiggle.c
     13 OUTPUT=test
     14 
     15 ## Dependencies
     16 MATH=-lm
     17 
     18 ## Flags
     19 DEBUG= #'-g'
     20 STANDARD=-std=c99
     21 WARNINGS=-Wall
     22 OPTIMIZED=-O3  #-Ofast
     23 # OPENMP=-fopenmp
     24 
     25 ## Formatter
     26 STYLE_BLUEPRINT=webkit
     27 FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
     28 
     29 ## make build
     30 build: $(SRC)
     31 	$(CC) $(OPTIMIZED) $(DEBUG) $(SRC) $(MATH) -o $(OUTPUT)
     32 
     33 format: $(SRC)
     34 	$(FORMATTER) $(SRC)
     35 
     36 run: $(SRC) $(OUTPUT)
     37 	./$(OUTPUT)
     38 
     39 verify: $(SRC) $(OUTPUT)
     40 	./$(OUTPUT) | grep "NOT passed" -A 2 --group-separator='' || true
     41 
     42 time-linux: 
     43 	@echo "Requires /bin/time, found on GNU/Linux systems" && echo
     44 	
     45 	@echo "Running 100x and taking avg time $(OUTPUT)"
     46 	@t=$$(/usr/bin/time -f "%e" -p bash -c 'for i in {1..100}; do $(OUTPUT); done' 2>&1 >/dev/null | grep real | awk '{print $$2}' ); echo "scale=2; 1000 * $$t / 100" | bc | sed "s|^|Time using 1 thread: |" | sed 's|$$|ms|' && echo
     47 
     48 ## Profiling
     49 
     50 profile-linux: 
     51 	echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar"
     52 	echo "Must be run as sudo"
     53 	$(CC) $(SRC) $(MATH) -o $(OUTPUT)
     54 	sudo perf record ./$(OUTPUT)
     55 	sudo perf report
     56 	rm perf.data