diff options
Diffstat (limited to 'source/luametatex/cmake')
-rw-r--r-- | source/luametatex/cmake/debug.cmake | 13 | ||||
-rw-r--r-- | source/luametatex/cmake/lua.cmake | 87 | ||||
-rw-r--r-- | source/luametatex/cmake/luametatex.cmake | 84 | ||||
-rw-r--r-- | source/luametatex/cmake/luaoptional.cmake | 30 | ||||
-rw-r--r-- | source/luametatex/cmake/luarest.cmake | 32 | ||||
-rw-r--r-- | source/luametatex/cmake/luasocket.cmake | 62 | ||||
-rw-r--r-- | source/luametatex/cmake/mimalloc.cmake | 44 | ||||
-rw-r--r-- | source/luametatex/cmake/mingw-32.cmake | 13 | ||||
-rw-r--r-- | source/luametatex/cmake/mingw-64.cmake | 13 | ||||
-rw-r--r-- | source/luametatex/cmake/miniz.cmake | 21 | ||||
-rw-r--r-- | source/luametatex/cmake/mp.cmake | 50 | ||||
-rw-r--r-- | source/luametatex/cmake/pplib.cmake | 43 | ||||
-rw-r--r-- | source/luametatex/cmake/tex.cmake | 99 |
13 files changed, 591 insertions, 0 deletions
diff --git a/source/luametatex/cmake/debug.cmake b/source/luametatex/cmake/debug.cmake new file mode 100644 index 000000000..2aa5dbf4f --- /dev/null +++ b/source/luametatex/cmake/debug.cmake @@ -0,0 +1,13 @@ +# When we run valgrind we need verbose binaries: +# +# valgrind -v --track-origins=yes --leak-check=full context ... + +# add_compile_options(-pg) +# set(CMAKE_EXE_LINKER_FLAGS "-pg") + +# In addition to the microsoft compiler alignment suggestions we can run on linux: +# +# pahole luametatex + +# add_compile_options(-p -gdwarf) +# set(CMAKE_EXE_LINKER_FLAGS "-p -gdwarf") diff --git a/source/luametatex/cmake/lua.cmake b/source/luametatex/cmake/lua.cmake new file mode 100644 index 000000000..8e370a05e --- /dev/null +++ b/source/luametatex/cmake/lua.cmake @@ -0,0 +1,87 @@ +set(lua_sources + + source/luacore/lua54/src/lapi.c + source/luacore/lua54/src/lauxlib.c + source/luacore/lua54/src/lbaselib.c + source/luacore/lua54/src/lcode.c + source/luacore/lua54/src/lcorolib.c + source/luacore/lua54/src/lctype.c + source/luacore/lua54/src/ldblib.c + source/luacore/lua54/src/ldebug.c + source/luacore/lua54/src/ldo.c + source/luacore/lua54/src/ldump.c + source/luacore/lua54/src/lfunc.c + source/luacore/lua54/src/lgc.c + source/luacore/lua54/src/linit.c + source/luacore/lua54/src/liolib.c + source/luacore/lua54/src/llex.c + source/luacore/lua54/src/lmathlib.c + source/luacore/lua54/src/lmem.c + source/luacore/lua54/src/loadlib.c + source/luacore/lua54/src/lobject.c + source/luacore/lua54/src/lopcodes.c + source/luacore/lua54/src/loslib.c + source/luacore/lua54/src/lparser.c + source/luacore/lua54/src/lstate.c + source/luacore/lua54/src/lstring.c + source/luacore/lua54/src/lstrlib.c + source/luacore/lua54/src/ltable.c + source/luacore/lua54/src/ltablib.c + source/luacore/lua54/src/ltm.c + source/luacore/lua54/src/lua.c + source/luacore/lua54/src/lundump.c + source/luacore/lua54/src/lutf8lib.c + source/luacore/lua54/src/lvm.c + source/luacore/lua54/src/lzio.c + + source/luacore/luapeg/lptree.c + source/luacore/luapeg/lpvm.c + source/luacore/luapeg/lpprint.c + source/luacore/luapeg/lpcap.c + source/luacore/luapeg/lpcode.c + +) + +add_library(lua STATIC ${lua_sources}) + +set_property(TARGET lua PROPERTY C_STANDARD 99) + +target_include_directories(lua PRIVATE + source/luacore/lua54/src + source/luacore/luapeg +) + +# luajit: 8000, lua 5.3: 1000000 or 15000 + +target_compile_definitions(lua PUBLIC + # This one should also be set in the lua namespace! + # LUAI_HASHLIMIT=6 # obsolete + LUAI_MAXCSTACK=6000 + LUA_UCID + # LUA_USE_JUMPTABLE=0 + LPEG_DEBUG + # LUA_NOCVTS2N + # LUA_NOBUILTIN # disable likely usage + # LUAI_ASSERT + # LUA_STRFTIMEOPTIONS="aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" +) + +if (UNIX) + target_compile_definitions(lua PUBLIC + LUA_USE_POSIX + LUA_USE_DLOPEN + ) +endif (UNIX) + +if (NOT MSVC) + target_compile_options(lua PRIVATE + -Wno-cast-align + -Wno-cast-qual + ) +endif (NOT MSVC) + +# this seems to be ok for mingw default +# +# todo: what is the right way to increase the stack (mingw) + +# target_compile_options(lua PRIVATE -DLUAI_MAXCSTACK=65536 -Wl,--stack,16777216) diff --git a/source/luametatex/cmake/luametatex.cmake b/source/luametatex/cmake/luametatex.cmake new file mode 100644 index 000000000..396b33d5a --- /dev/null +++ b/source/luametatex/cmake/luametatex.cmake @@ -0,0 +1,84 @@ +add_compile_options(-DLUA_CORE) + +set(luametatex_sources + source/luametatex.c +) + +add_executable(luametatex ${luametatex_sources}) + +target_include_directories(luametatex PRIVATE + . + source/. + source/luacore/lua54/src +) + +target_link_libraries(luametatex + tex + lua + mp + + luarest + luasocket + luaoptional + + pplib + miniz +) + +target_link_libraries(luametatex + ${CMAKE_DL_LIBS} +) + +install(TARGETS luametatex + EXPORT luametatex + RUNTIME + DESTINATION ${CMAKE_INSTALL_BINDIR} + COMPONENT luametatex_runtime +) + +if (luametatex_use_mimalloc) + target_include_directories(luametatex PRIVATE + source/libraries/mimalloc/include + ) + target_link_libraries(luametatex + mimalloc + ) + if (LUAMETATEX_MINGW) + target_link_libraries(luametatex --static) + target_link_libraries(luametatex + pthread + psapi + bcrypt + ) + elseif (NOT MSVC) + target_link_libraries(luametatex + pthread + ) + endif() +endif() + +if (NOT MSVC) + target_link_libraries(luametatex + m +) +endif() + +if (${CMAKE_HOST_SOLARIS}) + target_link_libraries(luametatex + rt + socket + nsl + resolv +) +endif() + +if (DEFINED LMT_OPTIMIZE) + # we strip anyway +elseif (CMAKE_HOST_SOLARIS) + # no strip +elseif (CMAKE_C_COMPILER_ID MATCHES "GNU") + # -g -S -d : remove all debugging symbols & sections + # -x : remove all non-global symbols + # -X : remove any compiler-generated symbols + add_custom_command(TARGET luametatex POST_BUILD COMMAND ${CMAKE_STRIP} -g -S -d -x luametatex${CMAKE_EXECUTABLE_SUFFIX}) +endif() diff --git a/source/luametatex/cmake/luaoptional.cmake b/source/luametatex/cmake/luaoptional.cmake new file mode 100644 index 000000000..adcb790cf --- /dev/null +++ b/source/luametatex/cmake/luaoptional.cmake @@ -0,0 +1,30 @@ +set(luaoptional_sources + + source/luaoptional/lmtsqlite.c + source/luaoptional/lmtmysql.c + source/luaoptional/lmtpostgress.c + source/luaoptional/lmtcurl.c + source/luaoptional/lmtghostscript.c + source/luaoptional/lmtimagemagick.c + source/luaoptional/lmtgraphicsmagick.c + source/luaoptional/lmtzint.c + source/luaoptional/lmtmujs.c + source/luaoptional/lmtlzo.c + source/luaoptional/lmtlz4.c + source/luaoptional/lmtkpse.c + source/luaoptional/lmthb.c + source/luaoptional/lmtzstd.c + source/luaoptional/lmtlzma.c + source/luaoptional/lmtforeign.c + +) + +add_library(luaoptional STATIC ${luaoptional_sources}) + +target_include_directories(luaoptional PRIVATE + . + source/. + source/luacore/lua54/src + source/libraries/mimalloc/include +) + diff --git a/source/luametatex/cmake/luarest.cmake b/source/luametatex/cmake/luarest.cmake new file mode 100644 index 000000000..e374ec156 --- /dev/null +++ b/source/luametatex/cmake/luarest.cmake @@ -0,0 +1,32 @@ +# The cerf library is actually optional but for now we compile it with the +# rest because the complex interfaces are different per platform. There is +# not that much code involved. But, anyway, at some point it might become +# a real optional module in which case the following will change. + +set(luarest_sources + + source/luaoptional/lmtcerflib.c + + source/libraries/libcerf/erfcx.c + source/libraries/libcerf/err_fcts.c + source/libraries/libcerf/im_w_of_x.c + source/libraries/libcerf/w_of_z.c + source/libraries/libcerf/width.c +) + +add_library(luarest STATIC ${luarest_sources}) + +target_include_directories(luarest PRIVATE + source/libraries/libcerf + source/luacore/lua54/src +) + +# only when all ok, to avoid messages + +include(CheckCCompilerFlag) + +CHECK_C_COMPILER_FLAG("-Wno-discarded-qualifiers" limited_support) + +if (limited_support) + target_compile_options(luarest PRIVATE -Wno-discarded-qualifiers) +endif() diff --git a/source/luametatex/cmake/luasocket.cmake b/source/luametatex/cmake/luasocket.cmake new file mode 100644 index 000000000..8489b0a80 --- /dev/null +++ b/source/luametatex/cmake/luasocket.cmake @@ -0,0 +1,62 @@ +set(luasocket_sources + + source/luacore/luasocket/src/auxiliar.c + source/luacore/luasocket/src/buffer.c + source/luacore/luasocket/src/compat.c + source/luacore/luasocket/src/except.c + source/luacore/luasocket/src/inet.c + source/luacore/luasocket/src/io.c + source/luacore/luasocket/src/luasocket.c + source/luacore/luasocket/src/mime.c + source/luacore/luasocket/src/options.c + source/luacore/luasocket/src/select.c + source/luacore/luasocket/src/socket.c + source/luacore/luasocket/src/tcp.c + source/luacore/luasocket/src/timeout.c + source/luacore/luasocket/src/udp.c + + # source/luacore/luasocket/src/serial.c + # source/luacore/luasocket/src/usocket.c + # source/luacore/luasocket/src/wsocket.c + + # source/luacore/luasec/src/config.c + # source/luacore/luasec/src/options.c + # source/luacore/luasec/src/ec.c + # source/luacore/luasec/src/x509.c + # source/luacore/luasec/src/context.c + # source/luacore/luasec/src/ssl.c + +) + +add_library(luasocket STATIC ${luasocket_sources}) + +target_include_directories(luasocket PRIVATE + source/luacore/luasocket + # source/luacore/luasec + # source/luacore/luasec/src + source/luacore/lua54/src +) + +if (NOT MSVC) + target_compile_options(luasocket PRIVATE + -Wno-cast-qual + -Wno-cast-align + ) +endif() + +if (WIN32) + target_link_libraries(luasocket PRIVATE + wsock32 + ws2_32 + ) +endif() + +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + target_compile_definitions(luasocket PRIVATE + LUASOCKET_INET_PTON + ) +endif() + + + + diff --git a/source/luametatex/cmake/mimalloc.cmake b/source/luametatex/cmake/mimalloc.cmake new file mode 100644 index 000000000..78d3944e2 --- /dev/null +++ b/source/luametatex/cmake/mimalloc.cmake @@ -0,0 +1,44 @@ +include("source/libraries/mimalloc/cmake/mimalloc-config-version.cmake") + +set(mimalloc_sources + + source/libraries/mimalloc/src/stats.c + source/libraries/mimalloc/src/random.c + source/libraries/mimalloc/src/os.c + source/libraries/mimalloc/src/bitmap.c + source/libraries/mimalloc/src/arena.c + # source/libraries/mimalloc/src/region.c + source/libraries/mimalloc/src/segment-cache.c + source/libraries/mimalloc/src/segment.c + source/libraries/mimalloc/src/page.c + source/libraries/mimalloc/src/alloc.c + source/libraries/mimalloc/src/alloc-aligned.c + source/libraries/mimalloc/src/alloc-posix.c + source/libraries/mimalloc/src/heap.c + source/libraries/mimalloc/src/options.c + source/libraries/mimalloc/src/init.c +) + +add_library(mimalloc STATIC ${mimalloc_sources}) + +# set(CMAKE_C_STANDARD 11) +# set(CMAKE_CXX_STANDARD 17) + +target_include_directories(mimalloc PRIVATE + source/libraries/mimalloc + source/libraries/mimalloc/src + source/libraries/mimalloc/include +) + +target_compile_definitions(mimalloc PRIVATE + MIMALLOC_LARGE_OS_PAGES=1 + MI_DEBUG=0 + MI_SECURE=0 +) + +if (NOT MSVC) + target_compile_options(mimalloc PRIVATE + -Wno-cast-align + -Wno-cast-qual + ) +endif () diff --git a/source/luametatex/cmake/mingw-32.cmake b/source/luametatex/cmake/mingw-32.cmake new file mode 100644 index 000000000..ef5001226 --- /dev/null +++ b/source/luametatex/cmake/mingw-32.cmake @@ -0,0 +1,13 @@ +if (NOT __MINGW64_TOOLCHAIN_) + add_compile_options(-DLUASOCKET_INET_PTON) +endif() + +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX i686-w64-mingw32) +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) + +add_compile_options(-mtune=nocona) + +set(LUAMETATEX_MINGW 32) + +# set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc") diff --git a/source/luametatex/cmake/mingw-64.cmake b/source/luametatex/cmake/mingw-64.cmake new file mode 100644 index 000000000..c57bed871 --- /dev/null +++ b/source/luametatex/cmake/mingw-64.cmake @@ -0,0 +1,13 @@ +if (NOT __MINGW64_TOOLCHAIN_) + add_compile_options(-DLUASOCKET_INET_PTON) +endif() + +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) + +add_compile_options(-mtune=nocona) + +set(LUAMETATEX_MINGW 64) + +# set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc") diff --git a/source/luametatex/cmake/miniz.cmake b/source/luametatex/cmake/miniz.cmake new file mode 100644 index 000000000..8c1c0e84a --- /dev/null +++ b/source/luametatex/cmake/miniz.cmake @@ -0,0 +1,21 @@ +set(miniz_sources + + source/libraries/miniz/miniz.c + +) + +add_library(miniz STATIC ${miniz_sources}) + +target_compile_definitions(miniz PUBLIC + MINIZ_NO_ARCHIVE_APIS=1 + MINIZ_NO_STDIO=1 + MINIZ_NO_MALLOC=1 +) + +if (NOT MSVC) + target_compile_options(miniz PRIVATE + -Wno-cast-align + -Wno-cast-qual + ) +endif (NOT MSVC) + diff --git a/source/luametatex/cmake/mp.cmake b/source/luametatex/cmake/mp.cmake new file mode 100644 index 000000000..1d064101d --- /dev/null +++ b/source/luametatex/cmake/mp.cmake @@ -0,0 +1,50 @@ +set(mp_sources + + source/mp/mpc/mp.c + source/mp/mpc/mpstrings.c + source/mp/mpc/mpmath.c + source/mp/mpc/mpmathdouble.c + source/mp/mpc/mpmathbinary.c + source/mp/mpc/mpmathdecimal.c + + source/libraries/decnumber/decContext.c + source/libraries/decnumber/decNumber.c + + source/libraries/avl/avl.c + + source/lua/lmtmplib.c + + source/luarest/lmtxdecimallib.c + +) + +add_library(mp STATIC ${mp_sources}) + +target_include_directories(mp PRIVATE + . + source/. + source/mp/mpc + source/luacore/lua54/src + source/libraries/avl + source/libraries/decnumber + source/utilities + source/libraries/mimalloc/include +) + +target_compile_definitions(mp PUBLIC + DECUSE64=1 + # DECCHECK=1 + # DECBUFFER=512 + DECNUMDIGITS=1000 +) + +if (NOT MSVC) + target_compile_options(mp PRIVATE + -Wno-unused-parameter + -Wno-sign-compare + -Wno-cast-qual + -Wno-cast-align + # for decnumber with lto + -fno-strict-aliasing +) +endif() diff --git a/source/luametatex/cmake/pplib.cmake b/source/luametatex/cmake/pplib.cmake new file mode 100644 index 000000000..3ca4c81c5 --- /dev/null +++ b/source/luametatex/cmake/pplib.cmake @@ -0,0 +1,43 @@ +set(pplib_sources + + source/libraries/pplib/pparray.c + source/libraries/pplib/ppcrypt.c + source/libraries/pplib/ppdict.c + source/libraries/pplib/ppheap.c + source/libraries/pplib/ppload.c + source/libraries/pplib/ppstream.c + source/libraries/pplib/ppxref.c + source/libraries/pplib/util/utilbasexx.c + source/libraries/pplib/util/utilcrypt.c + source/libraries/pplib/util/utilflate.c + source/libraries/pplib/util/utilfpred.c + source/libraries/pplib/util/utiliof.c + source/libraries/pplib/util/utillog.c + source/libraries/pplib/util/utillzw.c + source/libraries/pplib/util/utilmd5.c + source/libraries/pplib/util/utilmem.c + source/libraries/pplib/util/utilmemheap.c + source/libraries/pplib/util/utilmemheapiof.c + source/libraries/pplib/util/utilmeminfo.c + source/libraries/pplib/util/utilnumber.c + source/libraries/pplib/util/utilsha.c + +) + +add_library(pplib STATIC ${pplib_sources}) + +if (NOT MSVC) + target_compile_options(pplib PRIVATE + -Wno-missing-declarations + ) +endif (NOT MSVC) + +target_include_directories(pplib PRIVATE + source/libraries/pplib + source/libraries/pplib/util + source/libraries/zlib + + source/libraries/miniz + source/utilities/auxmemory + source/utilities/auxzlib +) diff --git a/source/luametatex/cmake/tex.cmake b/source/luametatex/cmake/tex.cmake new file mode 100644 index 000000000..83820aa1c --- /dev/null +++ b/source/luametatex/cmake/tex.cmake @@ -0,0 +1,99 @@ +set(tex_sources + + source/utilities/auxmemory.c + source/utilities/auxzlib.c + source/utilities/auxsparsearray.c + source/utilities/auxsystem.c + source/utilities/auxunistring.c + source/utilities/auxfile.c + + source/libraries/hnj/hnjhyphen.c + + source/lua/lmtinterface.c + source/lua/lmtlibrary.c + source/lua/lmtcallbacklib.c + source/lua/lmtlanguagelib.c + source/lua/lmtlualib.c + source/lua/lmtluaclib.c + source/lua/lmttexiolib.c + source/lua/lmttexlib.c + source/lua/lmttokenlib.c + source/lua/lmtnodelib.c + source/lua/lmtenginelib.c + source/lua/lmtfontlib.c + source/lua/lmtstatuslib.c + + source/luaoptional/lmtoptional.c + + source/luarest/lmtfilelib.c + source/luarest/lmtpdfelib.c + source/luarest/lmtiolibext.c + source/luarest/lmtoslibext.c + source/luarest/lmtstrlibext.c + source/luarest/lmtdecodelib.c + source/luarest/lmtsha2lib.c + source/luarest/lmtmd5lib.c + source/luarest/lmtaeslib.c + source/luarest/lmtbasexxlib.c + source/luarest/lmtxmathlib.c + source/luarest/lmtxcomplexlib.c + source/luarest/lmtziplib.c + source/luarest/lmtsparselib.c + + source/tex/texalign.c + source/tex/texarithmetic.c + source/tex/texbuildpage.c + source/tex/texcommands.c + source/tex/texconditional.c + source/tex/texdirections.c + source/tex/texdumpdata.c + source/tex/texequivalents.c + source/tex/texerrors.c + source/tex/texexpand.c + source/tex/texmarks.c + source/tex/texinputstack.c + source/tex/texinserts.c + source/tex/texadjust.c + source/tex/texlinebreak.c + source/tex/texlocalboxes.c + source/tex/texmainbody.c + source/tex/texmaincontrol.c + source/tex/texmathcodes.c + source/tex/texmlist.c + source/tex/texnesting.c + source/tex/texpackaging.c + source/tex/texprimitive.c + source/tex/texprinting.c + source/tex/texscanning.c + source/tex/texstringpool.c + source/tex/textypes.c + source/tex/texfont.c + source/tex/texlanguage.c + source/tex/texfileio.c + source/tex/texmath.c + source/tex/texnodes.c + source/tex/textextcodes.c + source/tex/textoken.c + source/tex/texrules.c + +) + +add_library(tex STATIC ${tex_sources}) + +target_compile_definitions(tex PUBLIC + # LUAI_HASHLIMIT=6 # obsolete + ZLIB_CONST=1 + MINIZ_NO_ARCHIVE_APIS=1 + MINIZ_NO_STDIO=1 + MINIZ_NO_MALLOC=1 +) + +target_include_directories(tex PRIVATE + . + source/. + source/libraries/miniz + source/libraries/pplib + source/libraries/pplib/util + source/luacore/lua54/src + source/libraries/mimalloc/include +) |