cake
/
libp7
Archived
1
0
Fork 1
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.
libp7/Makefile.vars

182 lines
6.2 KiB
Makefile
Raw Permalink Normal View History

2016-08-16 21:33:44 +02:00
#!/usr/bin/make -f
2016-10-28 14:27:03 +02:00
#******************************************************************************#
# Include configuration #
#******************************************************************************#
# Do it
-include Makefile.cfg
# Correct target
TARGET := $(if $(TARGET),$(TARGET)-)
2016-08-26 17:59:39 +02:00
#******************************************************************************#
2016-10-28 14:27:03 +02:00
# Project main information #
2016-08-26 17:59:39 +02:00
#******************************************************************************#
2016-10-28 14:27:03 +02:00
# Project name
2016-08-26 17:59:39 +02:00
NAME := p7
DESCRIPTION := Library for communicating with CASIO calculators
2016-10-28 14:27:03 +02:00
2017-01-05 23:04:17 +01:00
# Maintainer information
MAINTAINER_NAME := Thomas \"Cakeisalie5\" Touhey
MAINTAINER_MAIL := thomas@touhey.fr
2016-10-28 14:27:03 +02:00
# Project version
MAJOR := 4
MINOR := 0
2017-02-06 16:55:03 +01:00
INDEV := y
2017-01-27 22:08:07 +01:00
# Project version string
2016-11-22 15:32:25 +01:00
VERSION := $(MAJOR).$(MINOR)$(if $(INDEV),-indev)
2016-08-16 21:33:44 +02:00
2017-02-20 00:11:52 +01:00
# Runtime libs (later: libg1m and libfontcharacter)
RLIBS := libg1m
2017-02-20 00:11:52 +01:00
# Compilation time libs
LIBS := zlib $(if $(USE_LIBUSB),libusb-1.0) $(RLIBS)
2017-02-20 00:11:52 +01:00
2016-10-28 14:27:03 +02:00
#******************************************************************************#
# Project directories #
#******************************************************************************#
# Headers directory - where all the headers are.
2016-08-26 17:59:39 +02:00
INCDIR := ./include
2016-10-28 14:27:03 +02:00
# Sources directory - where all the sources are.
2016-08-26 17:59:39 +02:00
SRCDIR := ./src
2016-10-28 14:27:03 +02:00
# Objects directory - where the objects will be put.
2016-08-26 17:59:39 +02:00
OBJDIR := ./obj
2016-10-28 14:27:03 +02:00
# Documentation directory - where the asciidoc sources for manpages are.
2016-08-26 17:59:39 +02:00
DOCDIR := ./doc
2016-10-28 14:27:03 +02:00
# Manpages directory - where the manpages will be put.
2016-08-26 17:59:39 +02:00
MANDIR := ./man
2016-08-16 21:33:44 +02:00
# Web directory - where the HTML files will be put.
HTMLDIR := ./html
#******************************************************************************#
# Object names, libs #
#******************************************************************************#
# Dynamic library name
2017-01-04 23:29:53 +01:00
SONAME := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.$(MAJOR))
SONAMES := lib$(NAME).dll lib$(NAME).so.*
# Static library name
ANAME := $(if $(FOR_WINDOWS),lib$(NAME).lib,lib$(NAME).a)
ANAMES := lib$(NAME).lib lib$(NAME).a lib$(NAME).dll.a
2016-10-28 14:27:03 +02:00
#******************************************************************************#
# Binary utilities #
#******************************************************************************#
# Package configuration
PKGCONFIG := $(TARGET)pkg-config
2016-10-28 14:27:03 +02:00
# C Compiler
CC := $(TARGET)gcc
2016-10-28 14:27:03 +02:00
# - Check flags (for warnings enabling)
CWARN := -Wall -Wextra -Wno-unused-macros -Wno-vla
2016-10-28 14:27:03 +02:00
# - More flags (for profiling, ...)
2016-09-13 13:55:13 +02:00
#CMOREFLAGS :=
# - Check flags (for warnings)
2017-04-20 02:28:36 +02:00
CWERROR := all extra no-unused-macros no-vla no-nonnull-compare
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 \
stack-protector no-unused-parameter
endif
CWARN := $(CWERROR:%=-W%)
2016-10-28 14:27:03 +02:00
# - All of the C compiler flags
2017-01-18 00:26:42 +01:00
CFLAGS := -I $(INCDIR) $(CWARN) -std=gnu11 \
2017-01-21 12:33:17 +01:00
$(if $(STATIC),-Dis_static,-fPIC) $(if $(OPTIMIZE_SIZE),-Os,-O2) \
2016-12-17 01:38:10 +01:00
-D LOGLEVEL="ll_$(LOG_LEVEL)" -D INIT_TRIES="$(INIT_TRIES)" \
$(shell $(PKGCONFIG) --cflags $(LIBS) 2>/dev/null) \
2016-09-13 12:18:17 +02:00
$(CMOREFLAGS)
2016-10-28 14:27:03 +02:00
# Linker
LD := $(TARGET)gcc
# - Specific linker flags
2017-01-12 13:31:53 +01:00
LDFLAGS_Windows := -lws2_32 -lsetupapi -luuid \
-Wl,--out-implib,lib$(NAME).dll.a
2017-01-18 00:25:02 +01:00
LDFLAGS_Linux := $(if $(STATIC),,-Wl,-soname,$(SONAME) \
-e __lib$(NAME)_version \
2017-01-18 00:25:02 +01:00
-Wl,-z,relro -Wl,-z,combreloc -Wl,-z,defs)
# - Linker flags
2017-01-18 00:25:02 +01:00
LDFLAGS := $(if $(STATIC),,-shared) \
$(shell $(PKGCONFIG) --libs $(LIBS) 2>/dev/null) \
2017-01-18 00:25:02 +01:00
$(if $(FOR_WINDOWS),$(LDFLAGS_Windows),$(LDFLAGS_Linux)) \
$(LDMOREFLAGS)
2016-10-28 14:27:03 +02:00
# Archive manager
AR := $(TARGET)ar
2016-10-28 14:27:03 +02:00
# Directory maker
2016-08-26 17:59:39 +02:00
MD := mkdir -p
# Copier
CP := cp
# Mover
MV := mv
# Symbolic link maker
LN := ln -sf
2016-10-28 14:27:03 +02:00
# File remover
2016-08-26 17:59:39 +02:00
RM := rm -f
2016-10-28 14:27:03 +02:00
# Documentation manager (manpages generator)
2016-08-26 17:59:39 +02:00
A2X := a2x
2016-10-28 14:27:03 +02:00
# Installer
2016-10-27 14:36:24 +02:00
INST := install
2016-10-28 14:27:03 +02:00
# GZipper
2016-08-26 17:59:39 +02:00
GZIP := gzip -f
#******************************************************************************#
# Look up the sources and includes #
2016-08-26 17:59:39 +02:00
#******************************************************************************#
# Look up the sources
SRC := $(basename $(shell find $(SRCDIR) -mindepth 1 -type f \
-name "*.c" -printf "%P\n"))
DIRS := $(sort $(dir $(SRC)))
2016-08-26 17:59:39 +02:00
# Look up the includes
INCPUB := $(shell find $(INCDIR) -name "*.h" -and \
-not -path "*internals*" -printf "%P\n")
# Look up the includes
INC := $(shell find $(INCDIR) -name "*.h")
2016-10-28 14:27:03 +02:00
#******************************************************************************#
# Look for public headers (not internals.h or internals/**/*.h #
#******************************************************************************#
INCPUB := $(shell find $(INCDIR) \
-name "*.h" -and -not -path "*internals*" -printf "%P\n")
2016-10-12 12:55:34 +02:00
# ... and for headers (dependencies)
INC := $(shell find $(INCDIR) -name "*.h")
2016-10-28 14:27:03 +02:00
#******************************************************************************#
# Look for manpages #
#******************************************************************************#
# Get the manpages sections and contents
2016-09-15 11:05:22 +02:00
MAN_SECTIONS :=
2016-08-26 17:59:39 +02:00
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")), \
2016-08-26 17:59:39 +02:00
$(eval $(call check-man,$(patsubst .%,%,$(suffix $(doc))),$(basename $(doc)))))
2016-10-28 14:27:03 +02:00
# Remove duplicate sections.
MAN_SECTIONS := $(sort $(MAN_SECTIONS))
2016-08-16 21:33:44 +02:00
2016-10-28 14:27:03 +02:00
#******************************************************************************#
# Check for DESTDIR (add as prefix to installation root) #
2016-10-28 14:27:03 +02:00
#******************************************************************************#
# Save original library and include dir.
OIINCDIR := $(IINCDIR)
OILIBDIR := $(ILIBDIR)
# Make it.
define add-dest-dir
2016-09-15 11:05:22 +02:00
$1 = $(DESTDIR)$($1)
endef
2017-01-12 13:01:42 +01:00
$(if $(DESTDIR), $(foreach idir,IBINDIR ILIBDIR IINCDIR IMANDIR IPKGDIR IUDEVDIR, \
$(eval $(call add-dest-dir,$(idir)))))
2016-08-16 21:33:44 +02:00
# END OF FILE