Files
yait/Makefile
2025-11-04 21:14:47 -05:00

70 lines
1.4 KiB
Makefile

# SPDX-License-Identifier: BSD-3-Clause
PACKAGE := yait
SRCS := $(wildcard src/*.c) $(wildcard lib/*.c)
OBJS := $(patsubst %.c,build/obj/%.o,$(SRCS))
BIN := bin/$(PACKAGE)
COMMIT := $(shell git rev-list --count --all)
FLAGS := -I. -DCOMMIT=$(COMMIT) --std=c2x -pedantic -Ibuild/include
VERSION := $(shell git describe --tags --always --dirty)
TARBALL := $(PACKAGE)-$(VERSION).tar.gz
RELEASE_FILES := doc src lib COPYING AUTHORS README $(PACKAGE).1 INSTALL Makefile configure config.h
-include config.mak
ifeq ($(wildcard config.mak),)
all:
@echo "File config.mak not found, run configure"
@exit 1
else
all: $(BIN)
bin:
@mkdir -p bin
build/obj:
@mkdir -p build/obj/src
@mkdir -p build/obj/lib
build/obj/%.o: %.c config.mak | build/obj
@printf " CC %s\n" $(notdir $@)
@$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
$(BIN): $(OBJS) | bin
@printf " LINK %s\n" "$(notdir $@)"
@$(CC) $(FLAGS) $(CFLAGS) $^ -o $@
install: $(BIN)
cp $(BIN) $(PREFIX)
endif
doc:
$(MAKE) -C doc all
uninstall:
$(RM) $(PREFIX)$(PACKAGE)
clean:
$(RM) -r bin
$(RM) -r build
$(MAKE) -C doc clean
distclean: clean
$(RM) config.mak config.status
$(RM) $(TARBALL)
$(MAKE) -C doc clean
release: distclean all
tar -czf $(TARBALL) $(RELEASE_FILES)
test:
@$(BIN) --version > /dev/null 2>&1 && echo "intact" || echo "defective"
.PHONY: all clean distclean install uninstall doc