star-sim

Barnes-Hut gravity simulation.
git clone git://git.amin.space/star-sim.git
Log | Files | Refs | README | LICENSE

Makefile (1180B)


      1 CC = gcc
      2 CFLAGS = -std=c99 -Wall -Wextra -Wpedantic -Wshadow -Wno-unused-parameter
      3 LDFLAGS = $(SDL_LDFLAGS) -lm
      4 
      5 SDL_CFLAGS := $(shell sdl2-config --cflags)
      6 SDL_LDFLAGS := $(shell sdl2-config --libs)
      7 
      8 override CFLAGS += $(SDL_CFLAGS)
      9 
     10 SRC_FILES = platform_sdl.c sim.c star.c barnes_hut.c
     11 SRC = $(addprefix src/, $(SRC_FILES))
     12 EXE = star-garden
     13 
     14 DBGDIR = debug
     15 DBGEXE = $(DBGDIR)/$(EXE)
     16 DBGCFLAGS = -g -Og -Werror
     17 
     18 RELDIR = release
     19 RELEXE = $(RELDIR)/$(EXE)
     20 RELCFLAGS = -O2 -Os
     21 
     22 .PHONY: all clean compile_debug compile_release debug memcheck prep run todo
     23 
     24 all: compile_debug compile_release
     25 
     26 clean:
     27 	rm -f $(RELDIR)/* $(DBGDIR)/*
     28 
     29 compile_debug: prep
     30 	$(CC) $(CFLAGS) $(DBGCFLAGS) $(SRC) -o $(DBGEXE) $(LDFLAGS)
     31 
     32 compile_release: prep
     33 	$(CC) $(CFLAGS) $(RELCFLAGS) $(SRC) -o $(RELEXE) $(LDFLAGS)
     34 
     35 debug: compile_debug
     36 	gdb $(DBGEXE)
     37 
     38 memcheck: compile_debug
     39 	valgrind --track-origins=yes ./$(DBGEXE)
     40 
     41 prep:
     42 	@mkdir -p $(DBGDIR) $(RELDIR)
     43 
     44 run: compile_release
     45 	./$(DBGEXE)
     46 
     47 todo:
     48 	@grep -FIR --colour=never --ignore-case --line-number todo src/ \
     49 	| sed -re  's/^([^:]+):[[:space:]]*(.*)/\1\x01\2/' \
     50 	| sed -re  's/^([^:]+):[[:space:]]*(.*)/\1\x01\2/' \
     51 	| column -s $$'\x01' -t