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

158 lines
4.9 KiB
Makefile
Raw Permalink Normal View History

2016-12-21 22:56:20 +01:00
#!/usr/bin/make -f
2017-07-05 20:22:25 +02:00
#*****************************************************************************#
# Include configuration #
#*****************************************************************************#
2016-12-21 22:56:20 +01:00
-include Makefile.cfg
2017-01-14 13:42:01 +01:00
# Correct target
2016-12-21 22:56:20 +01:00
TARGET := $(if $(TARGET),$(TARGET)-)
2017-07-05 20:22:25 +02:00
#*****************************************************************************#
# Project main information #
#*****************************************************************************#
2016-12-21 22:56:20 +01:00
# Project name.
NAME := p7utils
# Author information.
2017-01-04 16:35:07 +01:00
MAINTAINER_NAME := Thomas \"Cakeisalie5\" Touhey
MAINTAINER_MAIL := thomas@touhey.fr
2016-12-21 22:56:20 +01:00
# Project license.
LICENSE := GPLv2
# Project version.
2017-02-08 14:04:11 +01:00
MAJOR := 4
MINOR := 0
2017-02-06 16:54:31 +01:00
INDEV := y
2016-12-21 22:56:20 +01:00
# Project version string.
VERSION := $(MAJOR).$(MINOR)$(if $(INDEV),-indev)
2017-07-05 20:22:25 +02:00
#*****************************************************************************#
# Project directories #
#*****************************************************************************#
2016-12-21 22:56:20 +01:00
# Sources directory
SRCDIR := ./src
# Objects directory
OBJDIR := ./obj
# Manpages sources directory
DOCDIR := ./doc
# Manpages directory
MANDIR := ./man
2017-07-05 20:22:25 +02:00
#*****************************************************************************#
# Binary utilities #
#*****************************************************************************#
2016-12-21 22:56:20 +01:00
# Package configuration
PKGCONFIG := $(TARGET)pkg-config
# C Compiler
CC := $(TARGET)gcc
# - Check flags (enable warnings)
2017-01-05 23:08:46 +01:00
CWARN := -Wall -Wextra -Wno-unused-macros -Wno-vla
# - Maintainer flags
ifdef MORE_WARNINGS
CWERROR := shadow write-strings redundant-decls format format-nonliteral \
format-security implicit-function-declaration \
date-time missing-prototypes return-type pointer-arith
CWARN += $(CWERROR:%=-W%) -Wstack-protector -Wno-unused-parameter
endif
2016-12-21 22:56:20 +01:00
# - More flags (profiling, ...)
#CMOREFLAGS :=
# - All C Compiler flags
2017-01-11 15:46:18 +01:00
CFLAGS := $(CWARN) -std=gnu11 -O2 -D NAME="$(NAME)" -D VERSION="$(VERSION)" \
2017-01-04 16:35:07 +01:00
-D MAINTAINER="$(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>" \
2016-12-21 22:56:20 +01:00
-D DEFAULT_STORAGE="$(DEFAULT_STORAGE)" \
-D DEFAULT_ZOOM="$(DEFAULT_ZOOM)" \
$(CMOREFLAGS)
# Linker
LD := $(TARGET)gcc
# - Specific linker flags
LDFLAGS_Linux := -Wl,-z,relro
# - Linker flags
2017-01-11 15:36:42 +01:00
LDFLAGS := $(if $(FOR_WINDOWS),,$(LDFLAGS_Linux))
2016-12-21 22:56:20 +01:00
2016-12-22 17:38:55 +01:00
# Raw ELF object maker
LDR := $(TARGET)ld -r
# Maker
MAKE := make --no-print-directory
2016-12-21 22:56:20 +01:00
# Directory maker
MD := mkdir -p
# File remover
RM := rm -f
# Installer
INSTALL := install
# Asciidoc
A2X := a2x
2016-12-21 23:07:33 +01:00
# Gzipper
GZIP := gzip -f
2016-12-21 22:56:20 +01:00
2017-07-05 20:22:25 +02:00
#*****************************************************************************#
# Binaries and sources #
#*****************************************************************************#
2016-12-21 22:56:20 +01:00
# Look for binaries
BINARIES := $(notdir $(shell find $(SRCDIR) -mindepth 1 -maxdepth 1 \
-type d | sort))
2017-01-11 15:36:42 +01:00
# Get their libs
define get-binary-libs
LIBS_$1 := $(shell make -f $(SRCDIR)/$1/vars.mk libs 2>/dev/null)
DISABLE_$1 := $(shell make -f $(SRCDIR)/$1/vars.mk disable 2>/dev/null \
&& echo y)
2017-01-11 15:36:42 +01:00
endef
$(foreach bin,$(BINARIES), \
$(eval $(call get-binary-libs,$(bin))))
# Get the default binaries
DEFAULT_BINARIES := $(foreach bin,$(BINARIES), \
$(if $(DISABLE_$(bin)),,$(bin)))
2017-01-11 15:36:42 +01:00
2016-12-21 22:56:20 +01:00
# Look for their sources
define get-binary-sources
2017-07-05 20:22:25 +02:00
SRC_$1 := $(shell find $(SRCDIR)/$1 \
-mindepth 1 -name "*.c" \
-printf "%P\n" | sort)
2017-01-11 15:36:42 +01:00
# - get the flags
CFLAGS_$1 := $(CFLAGS) $(shell $(PKGCONFIG) $(LIBS_$1) --cflags 2>/dev/null) \
2017-01-11 15:36:42 +01:00
-D BIN="$1$(if $(FOR_WINDOWS),.exe)"
LDFLAGS_$1 := $(LDFLAGS) $(shell $(PKGCONFIG) $(LIBS_$1) --libs 2>/dev/null)
2016-12-21 22:56:20 +01:00
endef
$(foreach bin,$(BINARIES), \
$(eval $(call get-binary-sources,$(bin))))
2017-07-05 20:22:25 +02:00
# Get the directories
DIRS := $(sort $(dir \
$(foreach bin,$(BINARIES),$(SRC_$(bin):%=$(OBJDIR)/$(bin)/%))))
#*****************************************************************************#
# Look for manpages #
#*****************************************************************************#
2016-12-21 22:56:20 +01:00
# 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))
2017-07-05 20:22:25 +02:00
#*****************************************************************************#
# Check for DESTDIR (add as prefix to installation root) #
#*****************************************************************************#
2016-12-21 22:56:20 +01:00
define add-dest-dir
$1 = $(DESTDIR)$($1)
endef
$(if $(DESTDIR), $(foreach idir,IBINDIR IMANDIR, \
$(eval $(call add-dest-dir,$(idir)))))
2017-01-11 15:36:42 +01:00
# End of file.