#!/usr/bin/make -f
# Pure POSIX makefile for smol c libraries
#
#
# Copyright (c) 2021 nytpu <alex [at] nytpu.com>
# SPDX-License-Identifier: MPL-2.0
# The orginal source for this file is available at <https://git.sr.ht/~nytpu/arena.c>.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
.POSIX:
.SILENT:
.SUFFIXES: .t .c
PROGNAME = arena.c
VERSION = 3.0.0
CC = cc
MAKE = make
CFLAGS = -Wall -Wextra -pedantic -Wfatal-errors -Og -g -I. \
-Wno-missing-field-initializers -Wno-unused-parameter -Werror=return-type \
-Werror=conversion -Werror=strict-prototypes -Wno-error=unused-function \
-std=c99
LDFLAGS =
LDLIBS =
TESTS = arena.t
test: $(TESTS)
printf 'Running tests:\n'
set -e; $(TESTS:%=./%;)
.c.t:
printf 'Compiling test\t$<\n'
$(CC) $(CFLAGS) -DTEST $(LDFLAGS) -o $@ $< $(LDLIBS)
clean:
rm -rf $(TESTS)
# requires clang's scan-build
# https://clang-analyzer.llvm.org/
scan:
printf 'Cleaning build directory and re-running make with scan-build'
$(MAKE) clean
scan-build $(MAKE)
# requires include-what-you-use
# https://github.com/include-what-you-use/include-what-you-use
test-includes:
find . -type f \( -name "*.c" -o -name "*.h" \) -not -path './.ccls-cache/*'\
-exec include-what-you-use -Xiwyu --quoted_includes_first ${CFLAGS} {} \;
.PHONY: test clean scan test-includes