aboutsummaryrefslogblamecommitdiff
path: root/Makefile
blob: db0e8ab04fc60bcf3db992a38d1694fe34ed4ca0 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                
             
           
                    
             




                                                                                
                      


                                                                                

                                                                                           
 

                                                                                    
                        
 
                                                                                
 

                       
     
                                               

                     




                          
 

                                                                                
                                           
 
                  
                                  












                                                     
TEST += bitfield
TEST += option
TEST += timer
TEST += log
TEST += owning_mutex
TEST += latch

# -- INTERNALS -----------------------------------------------------------------

BINS = $(TEST:%=build/%)
DEPS = $(TEST:%=build/%.d)
RUNS = $(TEST:%=run/%)

# -- FLAGS ---------------------------------------------------------------------

DEPS_GEN  = -MMD
SANITIZER = -fsanitize=address -fsanitize=undefined -fsanitize=leak -fno-omit-frame-pointer

STD      ?= 14
CXXFLAGS  = -Og -g -Wall -Wextra -Werror -I. -std=c++$(STD) $(DEPS_GEN) $(SANITIZER)
LDFLAGS   = $(SANITIZER)

# -- RULES ---------------------------------------------------------------------

all: lint build $(BINS)

bear:
	bear intercept -- $(MAKE) build $(BINS)
	bear citnames

run: $(RUNS)

run/%: build build/%
	@echo "==> run $*"
	build/$*

lint:
	clang-format --dry-run -Werror $(shell find -name '*.cc' -o -name '*.h')
	clang-tidy test/*.cc -- $(CXXFLAGS)

build/%: build/%.o
	$(CXX) -o $@ $< $(LDFLAGS)

build/%.o: test/%.cc
	$(CXX) -c -o $@ $< $(CXXFLAGS)

build:
	mkdir -p build

clean:
	$(RM) -r build
	$(RM) compile_commands.json events.json

# Since DEPS files contain rules, include at the end.
-include $(DEPS)