cake
/
p7utils
Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
p7utils/Makefile.vars

127 lines
4.0 KiB
Makefile
Executable File

#!/usr/bin/make -f
#******************************************************************************#
# Include configuration #
#******************************************************************************#
-include Makefile.cfg
# Correct target and adapt
TARGET := $(if $(TARGET),$(TARGET)-)
FOR_WINDOWS := $(if $(findstring mingw,$(TARGET)),y)
#******************************************************************************#
# Project main information #
#******************************************************************************#
# Project name.
NAME := p7utils
# Required packages
LIBS := libp7 sdl
# Author information.
AUTHOR_NAME := Thomas \"Cakeisalie5\" Touhey
AUTHOR_MAIL := thomas@touhey.fr
# Project license.
LICENSE := GPLv2
# Project version.
MAJOR := 2
MINOR := 0
INDEV := yes
# Project version string.
VERSION := $(MAJOR).$(MINOR)$(if $(INDEV),-indev)
#******************************************************************************#
# Project directories #
#******************************************************************************#
# Sources directory
SRCDIR := ./src
# Objects directory
OBJDIR := ./obj
# Manpages sources directory
DOCDIR := ./doc
# Manpages directory
MANDIR := ./man
#******************************************************************************#
# Binary utilities #
#******************************************************************************#
# Package configuration
PKGCONFIG := $(TARGET)pkg-config
# C Compiler
CC := $(TARGET)gcc
# - Check flags (enable warnings)
CWARN := -Wall -Wextra
# - More flags (profiling, ...)
#CMOREFLAGS :=
# - All C Compiler flags
CFLAGS := $(CWARN) -std=gnu11 -fPIC -O2 \
-D LICENSE="$(LICENSE)" -D VERSION="$(VERSION)" \
-D AUTHOR="$(AUTHOR_NAME) <$(AUTHOR_MAIL)>" \
-D DEFAULT_STORAGE="$(DEFAULT_STORAGE)" \
-D DEFAULT_ZOOM="$(DEFAULT_ZOOM)" \
$(shell $(PKGCONFIG) --cflags $(LIBS) 2>/dev/null) \
$(CMOREFLAGS)
# Linker
LD := $(TARGET)gcc
# - Specific linker flags
LDFLAGS_Linux := -Wl,-z,relro
# - Linker flags
LDFLAGS := $(shell $(PKGCONFIG) --libs $(LIBS) 2>/dev/null) \
$(if $(FOR_WINDOWS),,$(LDFLAGS_Linux))
# Directory maker
MD := mkdir -p
# File remover
RM := rm -f
# Installer
INSTALL := install
# Asciidoc
A2X := a2x
#******************************************************************************#
# Binaries and sources #
#******************************************************************************#
# Look for binaries
BINARIES := $(notdir $(shell find $(SRCDIR) -mindepth 1 -maxdepth 1 \
-type d | sort))
# Look for their sources
define get-binary-sources
SRC_$1 := $(basename $(shell find $(SRCDIR)/$1 \
-maxdepth 1 -mindepth 1 -type f -name "*.c" -printf "%P\n" | sort))
endef
$(foreach bin,$(BINARIES), \
$(eval $(call get-binary-sources,$(bin))))
#******************************************************************************#
# Look for manpages #
#******************************************************************************#
# Get the manpages sections and contents
MAN_SECTIONS :=
define check-man
MAN_SECTIONS += $1
MAN_$1 += $2
endef
$(foreach doc, $(basename $(shell find $(DOCDIR) \
-maxdepth 1 -mindepth 1 -printf "%P\n" -type f -or -type l -name "*.*.txt")), \
$(eval $(call check-man,$(patsubst .%,%,$(suffix $(doc))),$(basename $(doc)))))
# Remove duplicate sections.
MAN_SECTIONS := $(sort $(MAN_SECTIONS))
#******************************************************************************#
# Check for DESTDIR (add as prefix to installation root) #
#******************************************************************************#
define add-dest-dir
$1 = $(DESTDIR)$($1)
endef
$(if $(DESTDIR), $(foreach idir,IBINDIR IMANDIR, \
$(eval $(call add-dest-dir,$(idir)))))