# The MIT License (MIT) # Copyright (c) 2020 наб # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so, # subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. include configMakefile LDDLLS := efivar efiboot crypto $(OS_LD_LIBS) LDAR := $(LNCXXAR) $(foreach l,,-L$(BLDDIR)$(l)) $(foreach dll,$(LDDLLS),-l$(dll)) INCAR := $(foreach l,$(foreach l,fmt,$(l)/include) Catch2/single_include/catch2,-isystemext/$(l)) $(foreach l,,-isystem$(BLDDIR)$(l)/include) -isystemext VERAR := $(foreach l,KLAPKI,-D$(l)_VERSION='$($(l)_VERSION)') SOURCES := $(sort $(wildcard $(SRCDIR)*.cpp $(SRCDIR)**/*.cpp $(SRCDIR)**/**/*.cpp $(SRCDIR)**/**/**/*.cpp)) TEST_SOURCES := $(sort $(wildcard $(TSTDIR)*.cpp $(TSTDIR)**/*.cpp $(TSTDIR)**/**/*.cpp $(TSTDIR)**/**/**/*.cpp)) MANPAGE_SOURCES := $(sort $(wildcard $(MANDIR)*.md $(MANDIR)**/*.md)) # Building with -flto on Clang means we can't make useful archives, so don't LIBFMT := $(patsubst ext/fmt/src/%.cc,$(BLDDIR)fmt/obj/%$(OBJ),$(wildcard ext/fmt/src/*.cc)) .PHONY : all clean build build-test man fmt all : fmt build man build-test test test: build-test $(OUTDIR)klapki-test$(EXE) clean : rm -rf $(OUTDIR) build : fmt $(OUTDIR)klapki$(EXE) build-test : fmt $(OUTDIR)klapki-test$(EXE) man : $(subst $(MANDIR),$(OUTDIR)man/,$(MANPAGE_SOURCES)) fmt : $(LIBFMT) $(OUTDIR)klapki$(EXE) : $(subst $(SRCDIR),$(OBJDIR),$(subst .cpp,$(OBJ),$(SOURCES))) $(LIBFMT) $(CXX) $(CXXAR) -o$@ $^ $(PIC) $(LDAR) $(STRIP) $(STRIPAR) $@ $(OUTDIR)klapki-test$(EXE) : $(subst $(TSTDIR),$(BLDDIR)test/,$(subst .cpp,$(OBJ),$(TEST_SOURCES))) $(subst $(SRCDIR),$(OBJDIR),$(subst .cpp,$(OBJ),$(filter-out $(SRCDIR)main.cpp,$(SOURCES)))) $(patsubst ext/fmt/src/%.cc,$(BLDDIR)fmt/obj/%$(OBJ),$(wildcard ext/fmt/src/*.cc)) $(CXX) $(CXXAR) -o$@ $^ $(PIC) $(LDAR) $(subst $(MANDIR),$(OUTDIR)man/,$(MANPAGE_SOURCES)) : $(MANDIR)index.txt $(MANPAGE_SOURCES) @rm -rf $(dir $@) && mkdir -p $(dir $@) cp $^ $(dir $@) ronn --organization="klapki developers" $@ ronn --organization="klapki developers" -f $@ $(OBJDIR)%$(OBJ) : $(SRCDIR)%.cpp @mkdir -p $(dir $@) $(CXX) $(CXXAR) $(INCAR) $(VERAR) -c -o$@ $^ $(BLDDIR)test/%$(OBJ) : $(TSTDIR)%.cpp @mkdir -p $(dir $@) $(CXX) $(CXXAR) $(INCAR) -I$(SRCDIR) $(VERAR) -c -o$@ $^ $(BLDDIR)fmt/obj/%$(OBJ) : ext/fmt/src/%.cc @mkdir -p $(dir $@) $(CXX) $(CXXAR) -Iext/fmt/include -c -o$@ $^