~nytpu/arena.c

arena.c/Makefile -rw-r--r-- 1.4 KiB
aec3da0bnytpu fix license issue 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/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