jw-pkg/make/targets-tools.mk
Jan Lindemann bf16c6714b make, scripts: Re-add files necessary for building ytools
Re-add everthing needed for building and packaging ytools. This is a
big commit, 2002 lines of code. It mostly consists of C/C++ machinery,
plus some documentation-related stuff.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-14 15:59:49 +01:00

105 lines
3.1 KiB
Makefile

# generic utility modules
# (c) 2001 jannet it services
# contact@jannet.de
# $Id$
ifndef TARGETS_TOOLS_MK_INCLUDED
TARGETS_TOOLS_MK_INCLUDED = true
include $(JWBDIR)/make/rules.mk
ifneq ($(strip $(SRC_ALL_CPP)),)
# mandatory targets
all:
# all.link
install: $(ALL)
# convenience targets
#link: all.link
clean-link: clean.link
#all.link: $(HDRDIR_SCOPE_SUFFIX)
$(HDRDIR_SCOPE_SUFFIX):
mkdir -p $(dir $(HDRDIR_SCOPE_SUFFIX))
ln -s $(shell realpath -m . --relative-to $(dir $(HDRDIR_SCOPE_SUFFIX))) $@
ifeq ($(SCOPE_PREFIX),)
#all.link: $(BUILD_HDRDIR)/$(HDRDIR_SCOPE_SUFFIX)
#$(BUILD_HDRDIR)/$(HDRDIR_SCOPE_SUFFIX):
# cd $(BUILD_HDRDIR_BASE) && ln -s . $(HDRDIR_SCOPE_SUFFIX)
endif
ifneq ($(TARGET),mingw)
$(LIB_SO): $(BUILD_OBJ)
endif
all.done: $(PREREQ_DONE) $(BUILD_HDR) $(BUILD_EXE_SH) $(MEMBERS) $(LIB_A) | $(HDRDIR_SCOPE_SUFFIX)
ifneq ($(TARGET),mingw)
all.done: $(LIB_SO)
endif
endif
clean: objclean textclean localclean profclean clean.link
clean.link:
if [ -L "$(HDRDIR_SCOPE_SUFFIX)" -a "`realpath --relative-to . $(HDRDIR_SCOPE_SUFFIX) 2>/dev/null`" = . ]; then \
rm $(HDRDIR_SCOPE_SUFFIX) ;\
rmdir -p $(dir $(HDRDIR_SCOPE_SUFFIX)) 2>/dev/null || : ;\
fi
CLANG_TIDY_H_C_CPP := $(shell $(ECHO) $(LOCAL_H) | xargs -r $(GREP) -l 'extern *"C"')
CLANG_TIDY_H_C := $(wildcard [a-z]*.h)
CLANG_TIDY_H_CPP := $(wildcard [A-Z]*.h)
#CLANG_TIDY_H_CPP := $(filter-out $(CLANG_TIDY_H_C),$(LOCAL_H))
# false positives on assert(), see https://reviews.llvm.org/D31130
CLANG_TIDY_EXTRA_ARGS += -cppcoreguidelines-pro-bounds-array-to-pointer-decay
# keep va_args
CLANG_TIDY_EXTRA_ARGS += -cppcoreguidelines-pro-type-vararg
# keep pointer arithmetic
CLANG_TIDY_EXTRA_ARGS += -cppcoreguidelines-pro-bounds-pointer-arithmetic
# don't have GSL (for now)
CLANG_TIDY_EXTRA_ARGS += -cppcoreguidelines-pro-bounds-constant-array-index
CLANG_TIDY_FILTER = $(SED) 's%\[\([a-z-]\+\)\]$$%[https://clang.llvm.org/extra/clang-tidy/checks/\1.html]%'
CLANG_TIDY_CHECKS ?= -$(subst $(space),,*,clang-analyzer-*,-clang-analyzer-cplusplus*,modernize-*,portability-*,cppcoreguidelines-*$(addprefix $(comma),$(CLANG_TIDY_EXTRA_ARGS)))
CLANG_TIDY ?= clang-tidy -checks=$(CLANG_TIDY_CHECKS)
clean: clang-tidy-clean
clang-tidy-clean:
rm -f clang-tidy-cache*.tmp
CLANG_TIDY_CACHE_CPP = clang-tidy-cache-cpp.tmp
$(CLANG_TIDY_CACHE_CPP): $(LOCAL_CPP)
$(CLANG_TIDY) $(LOCAL_CPP) -- $(FINAL_INCLUDE) -x c++ | $(CLANG_TIDY_FILTER) | tee $@
clang-tidy-h-c-cpp:
ifneq ($(CLANG_TIDY_H_C_CPP),)
$(CLANG_TIDY) $(CLANG_TIDY_H_C_CPP) -- $(FINAL_INCLUDE)
endif
clang-tidy-h-c:
ifneq ($(CLANG_TIDY_H_C_C),)
$(CLANG_TIDY) $(CLANG_TIDY_H_C) -- $(FINAL_INCLUDE)
endif
clang-tidy-h-cpp:
ifneq ($(CLANG_TIDY_H_CPP),)
$(CLANG_TIDY) $(CLANG_TIDY_H_CPP) -- $(FINAL_INCLUDE) -x c++
endif
clang-tidy-h: clang-tidy-h-c clang-tidy-h-cpp clang-tidy-h-c-cpp
clang-tidy-c:
ifneq ($(LOCAL_C),)
$(CLANG_TIDY) $(LOCAL_C) -- $(FINAL_INCLUDE)
endif
clang-tidy-cpp: $(CLANG_TIDY_CACHE_CPP)
cat $<
clang-tidy: clang-tidy-h clang-tidy-c clang-tidy-cpp
endif # ifndef TARGETS_TOOLS_MK_INCLUDED