overgrown/GNUmakefile

74 lines
1.8 KiB
Makefile
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Copyright (c) 2023 Emma Tebibyte <emma@tebibyte.media>
# Copyright (c) 2023 DTB <trinity@trinity.moe>
# SPDX-License-Identifier: FSFAP
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and this
# notice are preserved. This file is offered as-is, without any warranty.
# If we want to use POSIX make we cant use ifeq
# .POSIX:
# .PRAGMA: posix_202x
.PHONY: clean
.PHONY: install
.PHONY: test
PREFIX=/usr/local
CC=cc
CFLAGS=-O3 -Lbuild
ifeq ($(CC), gcc)
CFLAGS=-O3 -s -Wl,-z,noseparate-code,-z,nosectionheader -flto -Lbuild
endif
ifeq ($(CC), clang)
CFLAGS=-O3 -Wall -Lbuild
endif
ifeq ($(CC), tcc)
CFLAGS=-O3 -s -Wl -flto -Lbuild
endif
build: build_dir false intcmp scrut str strcmp true
build_dir:
mkdir -p build
clean:
rm -rf build/
install: build
mkdir -p $(PREFIX)/bin $(PREFIX)/lib $(PREFIX)/man/man1 $(PREFIX)/man/man3
cp -f build/*.o $(PREFIX)/lib/
cp -f build/*.so $(PREFIX)/lib/
cp -f build/* $(PREFIX)/bin/
cp -f docs/*.1 $(PREFIX)/man/man1/
cp -f docs/*.3 $(PREFIX)/man/man3/
test: build
tests/cc-compat.sh
tests/posix-compat.sh
false: src/false.c build_dir
$(CC) $(CFLAGS) -o build/false src/false.c
intcmp: src/intcmp.c build_dir
$(CC) $(CFLAGS) -o build/intcmp src/intcmp.c
scrut: src/scrut.c libfileis build_dir
$(CC) $(CFLAGS) -lfileis -o build/scrut src/scrut.c
str: src/str.c build_dir
$(CC) $(CFLAGS) -o build/str src/str.c
strcmp: src/strcmp.c build_dir
$(CC) $(CFLAGS) -o build/strcmp src/strcmp.c
true: src/true.c build_dir
$(CC) $(CFLAGS) -o build/true src/true.c
libfileis: src/libfileis.c src/libfileis.h build_dir
$(CC) $(CFLAGS) -c -fPIC -o build/libfileis.o src/libfileis.c
$(CC) -shared -o build/libfileis.so build/libfileis.o