examples

Toy examples in single C files.
git clone git://henryandlizzy.uk/examples
Log | Files | Refs

makefile (968B)


      1 WARNINGS := -Wall -Wextra -Werror
      2 COMMON_FLAGS := $(WARNINGS) -fdiagnostics-color=always -fsanitize=undefined,address
      3 CFLAGS := $(COMMON_FLAGS)
      4 CXXFLAGS := -std=c++20 $(COMMON_FLAGS)
      5 
      6 c_sources := $(wildcard src/*.c)
      7 cpp_sources := $(wildcard src/*.cpp)
      8 
      9 c_targets := $(addprefix bin/,$(notdir $(basename $(c_sources))))
     10 cpp_targets := $(addprefix bin/,$(notdir $(basename $(cpp_sources))))
     11 
     12 VPATH := src
     13 
     14 all: all-c all-c++
     15 
     16 all-c: $(c_targets)
     17 all-c++: $(cpp_targets)
     18 
     19 clean:
     20 	$(RM) -r $(c_targets) $(cpp_targets) bin/
     21 
     22 bin/aio: -lrt
     23 bin/alsa-simple: -lasound
     24 bin/gl-asteroids: -lglfw -lGL -lm -lasound
     25 bin/io_uring: -luring
     26 bin/pulse-async-client: -lpulse
     27 bin/pulse-simple-client: -lpulse-simple -lm
     28 bin/sqlite-saveload: -lsqlite3
     29 
     30 bin/:
     31 	mkdir -p $@
     32 
     33 bin/%: %.c | bin/
     34 	$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@
     35 
     36 bin/%: %.cpp | bin/
     37 	$(LINK.cc) $^ $(LOADLIBES) $(LDLIBS) -o $@
     38 
     39 wait:
     40 	inotifywait -qe close_write makefile src
     41 
     42 .PHONY: clean all all-c all-c++ wait