163 lines
5.7 KiB
Makefile
Executable File
163 lines
5.7 KiB
Makefile
Executable File
#!/usr/bin/make -f
|
|
#******************************************************************************#
|
|
# Include configuration #
|
|
#******************************************************************************#
|
|
# Do it
|
|
-include Makefile.cfg
|
|
|
|
# Correct target
|
|
TARGET := $(if $(TARGET),$(TARGET)-)
|
|
|
|
# Check if it is for MS-Windows (damn son)
|
|
FOR_WINDOWS := $(if $(findstring mingw,$(TARGET)),y)
|
|
|
|
#******************************************************************************#
|
|
# Project main information #
|
|
#******************************************************************************#
|
|
# Project name
|
|
NAME := p7
|
|
DESCRIPTION := Library for communicating with CASIO calculators
|
|
|
|
# Author information
|
|
AUTHOR := Thomas \"Cakeisalie5\" Touhey
|
|
AUTHOR_MAIL := thomas@touhey.fr
|
|
|
|
# Project license
|
|
LICENSE := GPLv2
|
|
|
|
# Project version
|
|
MAJOR := 2
|
|
MINOR := 0
|
|
INDEV := y
|
|
VERSION := $(MAJOR).$(MINOR)$(if $(INDEV),-indev)
|
|
|
|
#******************************************************************************#
|
|
# 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 manpages are.
|
|
DOCDIR := ./doc
|
|
|
|
# Manpages directory - where the manpages will be put.
|
|
MANDIR := ./man
|
|
|
|
#******************************************************************************#
|
|
# Object names #
|
|
#******************************************************************************#
|
|
# Dynamic library name
|
|
SONAME := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.$(MAJOR))
|
|
SONAMES := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.*)
|
|
|
|
#******************************************************************************#
|
|
# Binary utilities #
|
|
#******************************************************************************#
|
|
# Package configuration
|
|
PKGCONFIG := $(TARGET)pkg-config
|
|
|
|
# C Compiler
|
|
CC := $(TARGET)gcc
|
|
# - Check flags (for warnings enabling)
|
|
CWARN := -Wall -Wextra -Wno-unused-macros -Wno-vla
|
|
# - More flags (for profiling, ...)
|
|
#CMOREFLAGS :=
|
|
# - 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
|
|
CMOREFLAGS += $(CWERROR:%=-W%) -Wstack-protector -Wno-unused-parameter
|
|
endif
|
|
# - All of the C compiler flags
|
|
CFLAGS := -I $(INCDIR) $(CWARN) -std=gnu11 -fPIC -O2 \
|
|
-D LOGLEVEL="ll_$(LOG_LEVEL)" -D INIT_TRIES="$(INIT_TRIES)" \
|
|
-D AUTHOR="$(AUTHOR)" -D AUTHOR_MAIL="$(AUTHOR_MAIL)" \
|
|
-D LICENSE="$(LICENSE)" -D VERSION="$(VERSION)" \
|
|
$(shell $(PKGCONFIG) --cflags libusb-1.0 2>/dev/null) \
|
|
$(CMOREFLAGS)
|
|
|
|
# Linker
|
|
LD := $(TARGET)gcc
|
|
# - Specific linker flags
|
|
LDFLAGS_Windows := -lws2_32
|
|
LDFLAGS_Linux := -Wl,-soname,$(SONAME) \
|
|
-e __lib$(NAME)_version \
|
|
-Wl,-z,relro -Wl,-z,combreloc -Wl,-z,defs
|
|
# - Linker flags
|
|
LDFLAGS := -shared \
|
|
$(shell $(PKGCONFIG) --libs libusb-1.0 2>/dev/null) \
|
|
$(if $(FOR_WINDOWS),$(LDFLAGS_Windows),$(LDFLAGS_Linux))
|
|
|
|
# Directory maker
|
|
MD := mkdir -p
|
|
# Symbolic link maker
|
|
LN := ln -sf
|
|
# File remover
|
|
RM := rm -f
|
|
# Documentation manager (manpages generator)
|
|
A2X := a2x
|
|
# Installer
|
|
INST := install
|
|
# GZipper
|
|
GZIP := gzip -f
|
|
|
|
#******************************************************************************#
|
|
# Look for modules and modules sources #
|
|
#******************************************************************************#
|
|
# 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))))
|
|
|
|
#******************************************************************************#
|
|
# Look for public headers (not internals.h or internals/**/*.h #
|
|
#******************************************************************************#
|
|
INCPUB := $(basename $(shell find $(INCDIR) \
|
|
-name "*.h" -and -not -path "*internals*" -printf "%P\n" | sort))
|
|
|
|
#******************************************************************************#
|
|
# 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) #
|
|
#******************************************************************************#
|
|
# Save original library and include dir.
|
|
OIINCDIR := $(IINCDIR)
|
|
OILIBDIR := $(ILIBDIR)
|
|
|
|
# Make it.
|
|
define add-dest-dir
|
|
$1 = $(DESTDIR)$($1)
|
|
endef
|
|
$(if $(DESTDIR), $(foreach idir,IBINDIR ILIBDIR IINCDIR IMANDIR IPKGDIR, \
|
|
$(eval $(call add-dest-dir,$(idir)))))
|
|
|
|
# END OF FILE
|