2016-10-30 20:18:15 +01:00
|
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
#******************************************************************************#
|
|
|
|
|
# Include configuration #
|
|
|
|
|
#******************************************************************************#
|
|
|
|
|
-include Makefile.cfg
|
|
|
|
|
|
|
|
|
|
#******************************************************************************#
|
|
|
|
|
# Project main information #
|
|
|
|
|
#******************************************************************************#
|
|
|
|
|
# Project name
|
|
|
|
|
NAME := g1m
|
|
|
|
|
|
|
|
|
|
# Author information
|
|
|
|
|
AUTHOR := Thomas \"Cakeisalie5\" Touhey
|
|
|
|
|
AUTHOR_MAIL := thomas@touhey.fr
|
|
|
|
|
|
|
|
|
|
# Project license
|
|
|
|
|
LICENSE := GPLv2
|
|
|
|
|
|
|
|
|
|
# Project version
|
2016-11-19 12:05:54 +01:00
|
|
|
|
MAJOR := 0
|
|
|
|
|
MINOR := 1
|
2016-10-30 20:18:15 +01:00
|
|
|
|
INDEV := yes
|
2016-11-19 12:05:54 +01:00
|
|
|
|
VERSION := $(MAJOR).$(MINOR)$(if $(INDEV),-indev)
|
2016-10-30 20:18:15 +01:00
|
|
|
|
|
|
|
|
|
#******************************************************************************#
|
|
|
|
|
# Project directories #
|
|
|
|
|
#******************************************************************************#
|
|
|
|
|
# Headers directory - where all the headers are.
|
|
|
|
|
INCDIR := ./include
|
|
|
|
|
|
|
|
|
|
# Sources directory - where all the sources are.
|
|
|
|
|
SRCDIR := ./src
|
|
|
|
|
|
|
|
|
|
# Objects directory - where the objects will be put.
|
|
|
|
|
OBJDIR := ./obj
|
|
|
|
|
|
|
|
|
|
# Documentation directory - where the asciidoc sources for the manpages are.
|
|
|
|
|
DOCDIR := ./doc
|
|
|
|
|
|
|
|
|
|
# Manpages directory - where the manpages will be put.
|
|
|
|
|
MANDIR := ./man
|
|
|
|
|
|
|
|
|
|
#******************************************************************************#
|
|
|
|
|
# Binary utilities #
|
|
|
|
|
#******************************************************************************#
|
|
|
|
|
# Compiler
|
|
|
|
|
CC := gcc
|
|
|
|
|
# - Check flags (warnings)
|
|
|
|
|
CHKFLAGS := -Wall -Wextra -Wno-attributes
|
|
|
|
|
# - For random manipulations (profiling, ...)
|
|
|
|
|
CMOREFLAGS :=
|
|
|
|
|
# - All C compiling flags
|
|
|
|
|
CFLAGS := -I $(INCDIR) $(CHKFLAGS) -std=gnu11 -fPIC -O2 \
|
|
|
|
|
-fstack-protector-strong -D LOGLEVEL="ll_$(LOG_LEVEL)" \
|
|
|
|
|
-D AUTHOR="$(AUTHOR)" -D AUTHOR_MAIL="$(AUTHOR_MAIL)" \
|
|
|
|
|
-D LICENSE="$(LICENSE)" -D VERSION="$(VERSION)" \
|
|
|
|
|
$(CMOREFLAGS)
|
|
|
|
|
|
|
|
|
|
# Linker
|
|
|
|
|
LD := gcc
|
|
|
|
|
# - Linker flags
|
2016-11-23 06:10:45 +01:00
|
|
|
|
LDFLAGS := -shared -lz \
|
2016-10-30 20:18:15 +01:00
|
|
|
|
-e __lib$(NAME)_version \
|
2016-11-19 12:05:54 +01:00
|
|
|
|
-Wl,-soname,lib$(NAME).so.$(MAJOR) \
|
2016-10-30 20:18:15 +01:00
|
|
|
|
-Wl,-z,relro -Wl,-z,combreloc -Wl,-z,defs
|
|
|
|
|
|
|
|
|
|
# Directory maker
|
|
|
|
|
MD := mkdir -p
|
|
|
|
|
# Symbolic link maker
|
|
|
|
|
LN := ln -sf
|
|
|
|
|
# File remover
|
|
|
|
|
RM := rm -f
|
|
|
|
|
# Documentation creator
|
|
|
|
|
A2X := a2x
|
|
|
|
|
# Installer
|
|
|
|
|
INST := install
|
|
|
|
|
# GZipper
|
|
|
|
|
GZIP := gzip -f
|
|
|
|
|
|
|
|
|
|
#******************************************************************************#
|
2016-11-02 16:32:30 +01:00
|
|
|
|
# Look for modules and modules sources #
|
2016-10-30 20:18:15 +01:00
|
|
|
|
#******************************************************************************#
|
2016-11-02 16:32:30 +01:00
|
|
|
|
# Look for modules first
|
|
|
|
|
MODULES := $(notdir $(shell find $(SRCDIR) -mindepth 1 -maxdepth 1 \
|
|
|
|
|
-type d | sort))
|
|
|
|
|
|
|
|
|
|
# Then look for their content
|
|
|
|
|
define get-module-source
|
|
|
|
|
SRC_$1 := $(basename $(shell find $(SRCDIR)/$1 \
|
|
|
|
|
-maxdepth 1 -mindepth 1 -type f -name "*.[cs]" -printf "%P\n" | sort))
|
|
|
|
|
endef
|
|
|
|
|
$(foreach mod,$(MODULES), \
|
|
|
|
|
$(eval $(call get-module-source,$(mod))))
|
2016-10-30 20:18:15 +01:00
|
|
|
|
|
|
|
|
|
#******************************************************************************#
|
2016-11-25 13:47:03 +01:00
|
|
|
|
# Look for headers #
|
2016-10-30 20:18:15 +01:00
|
|
|
|
#******************************************************************************#
|
2016-11-25 13:47:03 +01:00
|
|
|
|
# All headers
|
|
|
|
|
INC := \
|
|
|
|
|
$(basename $(shell find $(INCDIR) -name "*.h" -printf "%P\n"))
|
|
|
|
|
|
|
|
|
|
# Public headers only (not internals.h or internals/**/*.h)
|
|
|
|
|
INCPUB := \
|
|
|
|
|
$(basename $(shell find $(INCDIR) \
|
|
|
|
|
\( -name "*.h" -and -not -path "*internals*" \) \
|
|
|
|
|
-printf "%P\n" | sort))
|
2016-10-30 20:18:15 +01:00
|
|
|
|
|
|
|
|
|
#******************************************************************************#
|
|
|
|
|
# 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,ILIBDIR IINCDIR IMANDIR UDEVDIR, \
|
|
|
|
|
$(eval $(call add-dest-dir,$(idir)))))
|
|
|
|
|
|
|
|
|
|
# END OF FILE
|