This repository has been archived on 2026-07-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
K1NG-Driver/includes/tomlc17-R260618/simple/Makefile
T
2026-07-30 13:18:41 +02:00

60 lines
1.3 KiB
Makefile

EXEC = simple simplecpp
# set up CFLAGS / CXXFLAGS
CFLAGS = -std=c17 -Wmissing-declarations -Wall -Wextra -MMD
ifdef DEBUG
CFLAGS += -O0 -g -fsanitize=address,undefined
else
CFLAGS += -O3 -DNDEBUG
endif
# Add -fpic only for non-Windows platforms
ifneq ($(OS), Windows_NT)
CFLAGS += -fpic
endif
CXXFLAGS = $(subst -std=c17,-std=c++20,$(CFLAGS))
# Test if C++ is available
HAVE_CXX := $(shell command -v $(CXX) 2> /dev/null)
# Test for C++20 support
CXX20_SUPPORT := $(shell echo "int main(){}" | $(CXX) -std=c++20 -x c++ -c - -o /dev/null 2>/dev/null && echo yes || echo no)
all: $(EXEC)
simple: simple.c ../src/libtomlc17.a
$(CC) $(CFLAGS) -o $@ $@.c -L../src -ltomlc17
repro: repro.c ../src/libtomlc17.a
$(CC) $(CFLAGS) -o $@ $@.c -L../src -ltomlc17
simplecpp: simplecpp.cpp ../src/libtomlc17.a
ifndef HAVE_CXX
@echo "INFO: skipping $@ because no $(CXX) compiler found"
else ifeq ($(CXX20_SUPPORT),no)
@echo "INFO: skipping $@ because $(CXX) does not support C++20"
else
$(CXX) $(CXXFLAGS) -o $@ $@.cpp -L ../src -l tomlc17
endif
-include simple.d simplecpp.d
test: all
./simple > /dev/null
[ ! -x ./simplecpp ] || ./simplecpp > /dev/null
clean:
rm -f *.o *.d *.a $(EXEC)
distclean: clean
format:
clang-format -i *.[ch] *.cpp
.PHONY: all clean distclean format