improved Makefile v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 15 Apr 2025 22:44:24 +0200
branchv_0
changeset 14f02473035a66
parent 13 334b727f7516
child 15 1c74985d4c4e
improved Makefile
Makefile
     1.1 --- a/Makefile	Mon Jan 04 17:11:57 2021 +0100
     1.2 +++ b/Makefile	Tue Apr 15 22:44:24 2025 +0200
     1.3 @@ -1,5 +1,5 @@
     1.4  # DJM-Fix
     1.5 -# Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
     1.6 +# Copyright © 2025 František Kučera (Frantovo.cz, GlobalCode.info)
     1.7  #
     1.8  # This program is free software: you can redistribute it and/or modify
     1.9  # it under the terms of the GNU General Public License as published by
    1.10 @@ -13,18 +13,34 @@
    1.11  # You should have received a copy of the GNU General Public License
    1.12  # along with this program. If not, see <http://www.gnu.org/licenses/>.
    1.13  
    1.14 -CXXFLAGS=-fno-omit-frame-pointer -fsanitize=address -g -lpthread $$(pkg-config --libs --cflags alsa)
    1.15 +CXX ?= g++
    1.16 +CXXFLAGS ?= -O2 -g3 -ggdb -Wall -Wno-sign-compare
    1.17 +CXXFLAGS += --std=c++20
    1.18 +# CXXFLAGS += -Wextra
    1.19 +LIBS = alsa
    1.20 +CXXFLAGS += $(shell pkg-config --cflags $(LIBS))
    1.21 +LDFLAGS  += $(shell pkg-config --libs   $(LIBS))
    1.22 +LDFLAGS  += -lpthread
    1.23  
    1.24 -all: build/djm-fix
    1.25 +ifeq ($(MODE), dev)
    1.26 +CXXFLAGS += -fsanitize=undefined -fsanitize=address
    1.27 +endif
    1.28 +# TODO: provide debug symbols in separate files
    1.29  
    1.30 -clean:
    1.31 -	rm -rf build
    1.32 +BIN = build/djm-fix
    1.33 +SRC =     $(shell find -maxdepth 1 -name '*.cpp')
    1.34 +HEADERS = $(shell find -maxdepth 1 -name '*.h')
    1.35  
    1.36 -run: build/djm-fix
    1.37 -	build/djm-fix
    1.38 +all: $(BIN)
    1.39  
    1.40  .PHONY: all clean run
    1.41  
    1.42 -build/djm-fix: DJMFix.cpp DJMFix.h AlsaBridge.cpp AlsaBridge.h Logger.cpp Logger.h djm-fix.cpp
    1.43 +clean:
    1.44 +	$(RM) -r build
    1.45 +
    1.46 +run: $(BIN)
    1.47 +	$(<)
    1.48 +
    1.49 +$(BIN): $(SRC) $(HEADERS)
    1.50  	mkdir -p build
    1.51 -	g++ -o $@ DJMFix.cpp AlsaBridge.cpp Logger.cpp djm-fix.cpp $(CXXFLAGS)
    1.52 +	$(CXX) $(CXXFLAGS) -o $(@) $(SRC) $(LDFLAGS)