Added *.pc.in and uninstall command

This commit is contained in:
lexborisov 2017-03-16 16:38:01 +03:00
parent 2017f8454c
commit 43ab0fd013
3 changed files with 65 additions and 12 deletions

View File

@ -12,6 +12,8 @@ CC ?= gcc
.DEFAULT_GOAL := all
DESCRIPTION := Modest is a fast HTML renderer implemented as a pure C99 library with no outside dependencies
#********************
# other Makefile
#***************
@ -23,6 +25,7 @@ include Makefile.cfg
MODEST_BUILD_MODULES ?= $(dir $(wildcard $(SRCDIR)/*/))
MODEST_BUILD_MODULES := $(patsubst %myport/,%myport/$(strip $(MODEST_PORT_NAME))/,$(MODEST_BUILD_MODULES))
MODEST_BUILD_MODULES_LIST := $(foreach dir,$(MODEST_BUILD_MODULES),$(word 2, $(subst $(MODEST_DIR_SEPARATOR), , $(dir))) )
MODEST_BUILD_MODULES_LIST_WITHOUT_PORT := $(strip $(foreach dir,$(MODEST_BUILD_MODULES_LIST),$(patsubst myport,,$(dir))))
MODEST_BUILD_MODULES_MAKEFILES_LIST := $(foreach dir,$(MODEST_BUILD_MODULES),$(dir)Makefile.mk)
#********************
@ -74,10 +77,42 @@ BUILD_SUB_DIRS := examples $(TEST_DIR)
#********************
# Install
#***************
MODEST_INSTALL_LIB ?= lib
MODEST_INSTALL_HEADER ?= include
MODEST_INSTALL_CREATE_DIR := mkdir -p $(PREFIX)/$(MODEST_INSTALL_HEADER) $(PREFIX)/$(MODEST_INSTALL_LIB)
MODEST_INSTALL_COMMAND := $(MODEST_INSTALL_CREATE_DIR) $(MODEST_UTILS_NEW_LINE) cp -av $(LIB_DIR_BASE)/* $(PREFIX)/$(MODEST_INSTALL_LIB) $(MODEST_UTILS_NEW_LINE) cp -r $(INCLUDE_DIR_API)/* $(PREFIX)/$(MODEST_INSTALL_HEADER)
MODEST_INSTALL_LIBRARY := lib
MODEST_INSTALL_HEADER := include
libdir ?= $(prefix)/$(MODEST_INSTALL_LIBRARY)
includedir ?= $(prefix)/$(MODEST_INSTALL_HEADER)
MODEST_INSTALL_CREATE_DIR := mkdir -p $(prefix)/$(MODEST_INSTALL_HEADER) $(prefix)/$(MODEST_INSTALL_LIBRARY)
MODEST_INSTALL_COMMAND := $(MODEST_INSTALL_CREATE_DIR) $(MODEST_UTILS_NEW_LINE) cp -av $(LIB_DIR_BASE)/* $(libdir) $(MODEST_UTILS_NEW_LINE) cp -r $(INCLUDE_DIR_API)/* $(includedir)
#********************
# Uninstall
#***************
MODEST_UNINSTALL_MK_COMMAND :=
MODEST_UNINSTALL_FILE := uninstal.mk
MODEST_UNINSTALL_HEADERS := $(foreach name,$(MODEST_BUILD_MODULES_LIST_WITHOUT_PORT),rm -rf $(includedir)/$(name) \$$(MODEST_UTILS_NEW_LINE))
MODEST_UNINSTALL_LIBRARY := $(foreach path,$(wildcard $(LIB_DIR_BASE)/lib*),rm -rf $(libdir)/$(notdir $(path)) \$$(MODEST_UTILS_NEW_LINE))
MODEST_UNINSTALL_COMMAND = echo "MODEST_UNINSTALL_MK_COMMAND = $(MODEST_UNINSTALL_HEADERS) $(MODEST_UNINSTALL_LIBRARY)" > $(MODEST_UNINSTALL_FILE)
-include $(MODEST_UNINSTALL_FILE)
#********************
# PKG-CONFIG
#***************
MODEST_PKG_CONFIG_FILE := modest.pc
MODEST_PKG_CONFIG_CFLAGS := $(foreach name,$(MODEST_BUILD_MODULES_LIST_WITHOUT_PORT),-I$\{includedir}/$(name))
MODEST_PKG_CONFIG_PROCESS = \
$(SED) \
-e 's,@version\@,$(MODEST_VERSION_STRING),g' \
-e 's,@prefix\@,$(prefix),g' \
-e 's,@exec_prefix\@,$(exec_prefix),g' \
-e 's,@libdir\@,$(MODEST_INSTALL_LIBRARY),g' \
-e 's,@includedir\@,$(MODEST_INSTALL_HEADER),g' \
-e 's,@cflags\@,$(MODEST_PKG_CONFIG_CFLAGS),g' \
-e 's,@libname\@,$(LIB_NAME),g' \
-e 's,@description\@,$(DESCRIPTION),g' \
$1 > $2
#********************
# Target options
@ -113,8 +148,15 @@ create:
install:
$(MODEST_INSTALL_COMMAND)
$(MODEST_UNINSTALL_COMMAND)
uninstall:
$(MODEST_UNINSTALL_MK_COMMAND)
test: library
$(MAKE) -C $(TEST_DIR) run
make-pc-file:
$(call MODEST_PKG_CONFIG_PROCESS,$(MODEST_PKG_CONFIG_FILE).in, $(MODEST_PKG_CONFIG_FILE))
.PHONY: all clean clone test $(MODEST_BUILD_MODULES_TARGET_ALL)

View File

@ -69,8 +69,8 @@ MODEST_BUILD_CLEAN_AFTER :=
#********************
# DEFAULT
#***************
SED ?= sed
MODEST_DIR_SEPARATOR ?= /
MODEST_PORT_NAME ?= posix
# flags
@ -79,7 +79,8 @@ MODEST_CFLAGS += -I$(INCLUDE_DIR)
MODEST_LDFLAGS +=
OS ?= $(shell uname -s)
PREFIX ?= /usr/local
prefix ?= /usr/local
exec_prefix ?= $(prefix)
#********************
# Set -D
@ -135,9 +136,9 @@ ifeq ($(OS),Darwin)
MODEST_CFLAGS += $(MODEST_OPTIMIZATION_LEVEL) -Wno-unused-variable -Wno-unused-function -std=c99
LIB_NAME_SUFFIX := .dylib
MODEST_BUILD_SHARED_AFTER += ln -s $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -s $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -s $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR_MINOR) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR_MINOR) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)
@ -158,9 +159,9 @@ ifeq ($(MODEST_BUILD_OS),UNDEF)
MODEST_CFLAGS += -D_POSIX_C_SOURCE=199309L
MODEST_CFLAGS += $(MODEST_OPTIMIZATION_LEVEL) -Wno-unused-variable -Wno-unused-function -std=c99
MODEST_BUILD_SHARED_AFTER += ln -s $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -s $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -s $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR_MINOR) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_SHARED_AFTER += ln -sf $(call MODEST_LIBRARY_NAME_WITH_VERSION) $(call MODEST_LIBRARY_WITH_VERSION_MAJOR_MINOR) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY) $(MODEST_UTILS_NEW_LINE)
MODEST_BUILD_CLEAN_AFTER += rm -f $(call MODEST_LIBRARY_WITH_VERSION_MAJOR) $(MODEST_UTILS_NEW_LINE)

10
modest.pc.in Normal file
View File

@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
includedir=${prefix}/@includedir@
libdir=${prefix}/@libdir@
Name: @libname@
Description: @description@
Version: @version@
Cflags: @cflags@
Libs: -L${libdir} -l@libname@