2023-12-24 17:13:17 -07:00
|
|
|
|
# Copyright (c) 2023 Emma Tebibyte <emma@tebibyte.media>
|
|
|
|
|
# Copyright (c) 2023 DTB <trinity@trinity.moe>
|
2023-12-24 19:22:05 -07:00
|
|
|
|
# Copyright (c) 2023 Sasha Koshka <sashakoshka@tebibyte.media>
|
2023-12-24 17:13:17 -07:00
|
|
|
|
# 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 can’t use ifeq
|
|
|
|
|
# .POSIX:
|
|
|
|
|
# .PRAGMA: posix_202x
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
.PHONY: install
|
|
|
|
|
.PHONY: test
|
|
|
|
|
|
|
|
|
|
PREFIX=/usr/local
|
|
|
|
|
CC=cc
|
2023-12-24 19:17:24 -07:00
|
|
|
|
CFLAGS=-O3 -Lbuild/lib
|
2023-12-25 17:11:34 -07:00
|
|
|
|
RUSTC=rustc
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|
|
|
|
|
ifeq ($(CC), gcc)
|
2023-12-24 19:30:05 -07:00
|
|
|
|
CFLAGS=-O3 -s -Wl,-z,noseparate-code,-z,nosectionheader -flto \
|
|
|
|
|
-Lbuild/lib
|
2023-12-24 17:13:17 -07:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifeq ($(CC), clang)
|
2023-12-24 19:17:24 -07:00
|
|
|
|
CFLAGS=-O3 -Wall -Lbuild/lib
|
2023-12-24 17:13:17 -07:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifeq ($(CC), tcc)
|
2023-12-24 19:17:24 -07:00
|
|
|
|
CFLAGS=-O3 -s -Wl -flto -Lbuild/lib
|
2023-12-24 17:13:17 -07:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
build: build_dir false intcmp scrut str strcmp true
|
|
|
|
|
|
|
|
|
|
build_dir:
|
2023-12-24 19:17:24 -07:00
|
|
|
|
mkdir -p build/o build/lib build/bin
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
|
rm -rf build/
|
|
|
|
|
|
|
|
|
|
install: build
|
2023-12-24 19:30:05 -07:00
|
|
|
|
mkdir -p $(PREFIX)/bin $(PREFIX)/lib
|
|
|
|
|
mkdir -p $(PREFIX)/man/man1 $(PREFIX)/man/man3
|
2023-12-24 19:17:24 -07:00
|
|
|
|
cp -f build/lib/*.so $(PREFIX)/lib/
|
|
|
|
|
cp -f build/bin/* $(PREFIX)/bin/
|
2023-12-24 17:13:17 -07:00
|
|
|
|
cp -f docs/*.1 $(PREFIX)/man/man1/
|
|
|
|
|
cp -f docs/*.3 $(PREFIX)/man/man3/
|
|
|
|
|
|
|
|
|
|
test: build
|
|
|
|
|
tests/cc-compat.sh
|
|
|
|
|
tests/posix-compat.sh
|
|
|
|
|
|
2023-12-25 17:11:34 -07:00
|
|
|
|
false: src/false.rs build_dir
|
|
|
|
|
$(RUSTC) -o build/bin/false src/false.rs
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|
|
|
|
|
intcmp: src/intcmp.c build_dir
|
2023-12-24 19:17:24 -07:00
|
|
|
|
$(CC) $(CFLAGS) -o build/bin/intcmp src/intcmp.c
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|
|
|
|
|
scrut: src/scrut.c libfileis build_dir
|
2023-12-24 19:17:24 -07:00
|
|
|
|
$(CC) $(CFLAGS) -lfileis -o build/bin/scrut src/scrut.c
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|
|
|
|
|
str: src/str.c build_dir
|
2023-12-24 19:17:24 -07:00
|
|
|
|
$(CC) $(CFLAGS) -o build/bin/str src/str.c
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|
|
|
|
|
strcmp: src/strcmp.c build_dir
|
2023-12-24 19:17:24 -07:00
|
|
|
|
$(CC) $(CFLAGS) -o build/bin/strcmp src/strcmp.c
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|
|
|
|
|
true: src/true.c build_dir
|
2023-12-24 19:17:24 -07:00
|
|
|
|
$(CC) $(CFLAGS) -o build/bin/true src/true.c
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|
|
|
|
|
libfileis: src/libfileis.c src/libfileis.h build_dir
|
2023-12-24 19:17:24 -07:00
|
|
|
|
$(CC) $(CFLAGS) -c -fPIC -o build/o/libfileis.o src/libfileis.c
|
|
|
|
|
$(CC) -shared -o build/lib/libfileis.so build/o/libfileis.o
|
2023-12-24 17:13:17 -07:00
|
|
|
|
|