Skip to content

Commit

Permalink
Add LCF mime types and install them
Browse files Browse the repository at this point in the history
  • Loading branch information
carstene1ns committed Jan 2, 2019
1 parent bce2753 commit dca6dcb
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 4 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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})
Expand Down
18 changes: 16 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
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 \
Expand Down Expand Up @@ -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
15 changes: 13 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])])

Expand Down
35 changes: 35 additions & 0 deletions mime/liblcf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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>

0 comments on commit dca6dcb

Please sign in to comment.