# Copyright (C) 2023 - 2024: # The Trinitrix Project # SPDX-License-Identifier: LGPL-3.0-or-later # # This file is part of the Trixy crate for Trinitrix. # # Trixy is free software: you can redistribute it and/or modify # it under the terms of the Lesser GNU General Public License as # published by the Free Software Foundation, either version 3 of # the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # and the Lesser GNU General Public License along with this program. # If not, see . PREFIX := /usr/local BINPREFIX := $(DESTDIR)$(PREFIX)/bin MANPREFIX := $(DESTDIR)$(PREFIX)/share/man/man1 BIN_NAME := c_test # This version is set automatically on `cog bump --auto`; BIN_VERSION := "v0.1.0" # GUIDING VERSION STRING # The trailing slash is important BUILD_DIR := ./target/ BIN_PATH := $(BUILD_DIR)$(BIN_NAME) SRC := $(wildcard src/*.c) OBJ := $(SRC:.c=.o) DEP := $(OBJ:.o=.d) LIBS := ALL_CFLAGS := -O3 -MMD -Wall -Wextra -Wno-unused-parameter $(CFLAGS) $(CPPFLAGS) ALL_LDFLAGS := $(addprefix -l,$(LIBS)) -L $(LD_LIBRARY_PATH) $(LDFLAGS) default: all all: $(BIN_NAME) $(BIN_NAME): $(OBJ) $(CC) $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) -o $(addprefix $(BUILD_DIR),$(notdir $(BIN_NAME))) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(OBJ): $(SRC) mkdir --parents $(BUILD_DIR) $(CC) -c $< -o $(addprefix $(BUILD_DIR),$(notdir $(OBJ))) $(ALL_CFLAGS) manual: mkdir --parents $(BUILD_DIR)docs pandoc "./docs/$(BIN_NAME).1.md" -s -t man > $(BUILD_DIR)docs/$(BIN_NAME).1 .PHONY : clean options install memory_leak_test options: @echo "PREFIX = $(PREFIX)" @echo "BINPREFIX = $(BINPREFIX)" @echo "MANPREFIX = $(MANPREFIX)" @echo "" @echo "BIN_NAME = $(BIN_NAME)" @echo "BUILD_DIR = $(BUILD_DIR)" @echo "BIN_PATH = $(BIN_PATH)" @echo "" @echo "SRC = $(SRC)" @echo "OBJ = $(OBJ)" @echo "DEP = $(DEP)" @echo "" @echo "LIBS = $(LIBS)" @echo "" @echo "ALL_CFLAGS = $(ALL_CFLAGS)" @echo "ALL_LDFLAGS = $(ALL_LDFLAGS)" @echo "" clean : rm --recursive $(BUILD_DIR) install: $(BIN_NAME) manual install -D $(BUILD_DIR)docs/$(BIN_NAME).1 $(MANPREFIX)/$(BIN_NAME); install -D $(BUILD_DIR)$(BIN_NAME) $(BINPREFIX)/$(BIN_NAME); memory_leak_test: sh ./scripts/valgrind_test.sh $(BIN_NAME)