Add LCF mime types and install them
MODIFY
CMakeLists.txt
CMakeLists.txt
@@ -6,6 +6,7 @@ project(liblcf VERSION 0.5.4 LANGUAGES CXX)
option(BUILD_SHARED_LIBS "Build shared library, disable for building the static library" ON)
option(DISABLE_ICU "Disable ICU encoding detection (fallback to iconv, not recommended)" OFF)
option(DISABLE_XML "Disable XML reading support (expat)" OFF)
+option(DISABLE_UPDATE_MIMEDB "Do not run update-mime-database after install" OFF)
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Override CMAKE_DEBUG_POSTFIX.")
@@ -261,6 +262,11 @@ if(NOT DISABLE_XML)
list(APPEND LIBLCF_DEPS "expat")
endif()
+# mime types
+if(NOT DISABLE_UPDATE_MIMEDB)
+ find_program(UPDATE_MIME_DATABASE update-mime-database)
+endif()
+
# .so version
set_property(TARGET lcf PROPERTY SOVERSION 0)
@@ -305,6 +311,18 @@ install(
${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules/FindICU.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/liblcf)
+# mime types
+install(
+ FILES ${CMAKE_CURRENT_SOURCE_DIR}/mime/${PROJECT_NAME}.xml
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/mime/packages
+)
+if(NOT DISABLE_UPDATE_MIMEDB AND UPDATE_MIME_DATABASE)
+ install(CODE
+ "execute_process(COMMAND ${UPDATE_MIME_DATABASE}
+ \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/mime)"
+ )
+endif()
+
# tests
file(GLOB TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp)
add_executable(test_runner EXCLUDE_FROM_ALL ${TEST_FILES})

MODIFY
Makefile.am
Makefile.am
ACLOCAL_AMFLAGS = --install -I builds/autoconf/m4
+
EXTRA_DIST = AUTHORS.md README.md generator \
- CMakeLists.txt builds/cmake builds/Doxyfile
-pkgconfigdir = ${libdir}/pkgconfig
+ CMakeLists.txt builds/cmake mime builds/Doxyfile
+
+pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = builds/liblcf.pc
+mimedbdir = $(datadir)/mime/packages
+mimedb_DATA = mime/liblcf.xml
+
cmakeconfigdir = $(libdir)/cmake/liblcf
cmakeconfig_DATA = \
builds/liblcf-config.cmake \
@@ -228,3 +233,12 @@ test_runner_LDFLAGS = -no-install
check-local:
$(AM_V_at)./test_runner
+
+install-data-hook:
+if ENABLE_UPDATE_MIMEDB
+ $(UPDATE_MIME_DATABASE) "$(DESTDIR)$(datadir)/mime"
+endif
+
+uninstall-hook:
+ rm -f "$(DESTDIR)$(datadir)/mime/application/"*.xml
+ for f in aliases generic-icons globs globs2 icons magic mime.cache subclasses treemagic types version XMLnamespaces; do rm -f "$(DESTDIR)$(datadir)/mime/$${f}"; done

MODIFY
configure.ac
configure.ac
@@ -21,16 +21,27 @@ AC_PROG_CXX
LT_INIT([win32-dll])
# Checks for libraries.
-AC_ARG_ENABLE([icu],[AS_HELP_STRING([--disable-icu],[Disable ICU encoding detection (fallback to iconv)])])
+AC_ARG_ENABLE([icu],[AS_HELP_STRING([--disable-icu],[Disable ICU encoding detection (fallback to iconv) [default=no]])])
AS_IF([test "x$enable_icu" != "xno"],[
AX_PKG_CHECK_MODULES([ICU],[],[icu-i18n],[AC_DEFINE([LCF_SUPPORT_ICU],[1],[Enable encoding detection (ICU)])])
])
-AC_ARG_ENABLE([xml],[AS_HELP_STRING([--disable-xml],[Disable XML reading support (expat)])])
+AC_ARG_ENABLE([xml],[AS_HELP_STRING([--disable-xml],[Disable XML reading support (expat) [default=no]])])
AS_IF([test "x$enable_xml" != "xno"],[
AX_PKG_CHECK_MODULES([EXPAT],[],[expat >= 2.1],[AC_DEFINE([LCF_SUPPORT_XML],[1],[Enable XML reading support (expat)])])
])
+# Add mime types
+AC_ARG_ENABLE([update-mimedb],[AS_HELP_STRING([--disable-update-mimedb],[Do not run update-mime-database after install [default=no]])])
+AS_IF([test "x$enable_update_mimedb" != "xno"],[
+ AC_PATH_PROG(UPDATE_MIME_DATABASE, update-mime-database, no)
+ AS_IF([test "x$UPDATE_MIME_DATABASE" = "xno"],[
+ enable_update_mimedb=no
+ AC_MSG_WARN(Could not find the update-mime-database program in your PATH. Your mime database will not be updated upon install.)
+ ])
+])
+AM_CONDITIONAL(ENABLE_UPDATE_MIMEDB,[test x$enable_update_mimedb != xno])
+
# Checks for header files.
AC_CHECK_HEADERS([stdint.h],[],[AC_MSG_ERROR([cannot find stdint.h, bailing out])])

ADD
mime/liblcf.xml
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <mime-type type="application/x-lmu">
+ <comment>LCF Map Unit</comment>
+ <comment xml:lang="en">RPG Maker 2k(3) Map</comment>
+ <glob pattern="*.lmu"/>
+ <magic priority="50">
+ <match type="string" value="LcfMapUnit" offset="0"/>
+ </magic>
+ </mime-type>
+ <mime-type type="application/x-lmt">
+ <comment>LCF Map Tree</comment>
+ <comment xml:lang="en">RPG Maker 2k(3) Map Tree</comment>
+ <glob pattern="*.lmt"/>
+ <magic priority="50">
+ <match type="string" value="LcfMapTree" offset="0"/>
+ </magic>
+ </mime-type>
+ <mime-type type="application/x-ldb">
+ <comment>LCF Database</comment>
+ <comment xml:lang="en">RPG Maker 2k(3) Database</comment>
+ <glob pattern="*.ldb"/>
+ <magic priority="50">
+ <match type="string" value="LcfDataBase" offset="0"/>
+ </magic>
+ </mime-type>
+ <mime-type type="application/x-lsd">
+ <comment>LCF Save Data</comment>
+ <comment xml:lang="en">RPG Maker 2k(3) Savegame</comment>
+ <glob pattern="*.lsd"/>
+ <magic priority="50">
+ <match type="string" value="LcfSaveData" offset="0"/>
+ </magic>
+ </mime-type>
+</mime-info>

Add LCF mime types and install them