squiggle.c

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

makefile (1236B)


      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=example.c ../../squiggle.c
     13 OUTPUT=example
     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) && echo
     38 
     39 time-linux: 
     40 	@echo "Requires /bin/time, found on GNU/Linux systems" && echo
     41 	
     42 	@echo "Running 100x and taking avg time $(OUTPUT)"
     43 	@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
     44 
     45 ## Profiling
     46 
     47 profile-linux: 
     48 	echo "Requires perf, which depends on the kernel version, and might be in linux-tools package or similar"
     49 	echo "Must be run as sudo"
     50 	$(CC) $(SRC) $(MATH) -o $(OUTPUT)
     51 	sudo perf record ./$(OUTPUT)
     52 	sudo perf report
     53 	rm perf.data