diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-05-30 02:38:43 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-05-30 03:12:56 +0200 |
commit | 432ad24e382681f1c13b07e8486e91063dd96e2e (patch) | |
tree | 51838adac822767bd5884b9383cd4c72f29d3840 /configure.ac | |
parent | 524bc3960e6a6e5645ce904e20f72479e24e0a23 (diff) | |
download | sciteco-432ad24e382681f1c13b07e8486e91063dd96e2e.tar.gz |
THE GREAT CEEIFICATION EVENT
This is a total conversion of SciTECO to plain C (GNU C11).
The chance was taken to improve a lot of internal datastructures,
fix fundamental bugs and lay the foundations of future features.
The GTK user interface is now in an useable state!
All changes have been squashed together.
The language itself has almost not changed at all, except for:
* Detection of string terminators (usually Escape) now takes
the string building characters into account.
A string is only terminated outside of string building characters.
In other words, you can now for instance write
I^EQ[Hello$world]$
This removes one of the last bits of shellisms which is out of
place in SciTECO where no tokenization/lexing is performed.
Consequently, the current termination character can also be
escaped using ^Q/^R.
This is used by auto completions to make sure that strings
are inserted verbatim and without unwanted sideeffects.
* All strings can now safely contain null-characters
(see also: 8-bit cleanliness).
The null-character itself (^@) is not (yet) a valid SciTECO
command, though.
An incomplete list of changes:
* We got rid of the BSD headers for RB trees and lists/queues.
The problem with them was that they used a form of metaprogramming
only to gain a bit of type safety. It also resulted in less
readble code. This was a C++ desease.
The new code avoids metaprogramming only to gain type safety.
The BSD tree.h has been replaced by rb3ptr by Jens Stimpfle
(https://github.com/jstimpfle/rb3ptr).
This implementation is also more memory efficient than BSD's.
The BSD list.h and queue.h has been replaced with a custom
src/list.h.
* Fixed crashes, performance issues and compatibility issues with
the Gtk 3 User Interface.
It is now more or less ready for general use.
The GDK lock is no longer used to avoid using deprecated functions.
On the downside, the new implementation (driving the Gtk event loop
stepwise) is even slower than the old one.
A few glitches remain (see TODO), but it is hoped that they will
be resolved by the Scintilla update which will be performed soon.
* A lot of program units have been split up, so they are shorter
and easier to maintain: core-commands.c, qreg-commands.c,
goto-commands.c, file-utils.h.
* Parser states are simply structs of callbacks now.
They still use a kind of polymorphy using a preprocessor trick.
TECO_DEFINE_STATE() takes an initializer list that will be
merged with the default list of field initializers.
To "subclass" states, you can simply define new macros that add
initializers to existing macros.
* Parsers no longer have a "transitions" table but the input_cb()
may use switch-case statements.
There are also teco_machine_main_transition_t now which can
be used to implement simple transitions. Additionally, you
can specify functions to execute during transitions.
This largely avoids long switch-case-statements.
* Parsers are embeddable/reusable now, at least in parse-only mode.
This does not currently bring any advantages but may later
be used to write a Scintilla lexer for TECO syntax highlighting.
Once parsers are fully embeddable, it will also be possible
to run TECO macros in a kind of coroutine which would allow
them to process string arguments in real time.
* undo.[ch] still uses metaprogramming extensively but via
the C preprocessor of course. On the downside, most undo
token generators must be initiated explicitly (theoretically
we could have used embedded functions / trampolines to
instantiate automatically but this has turned out to be
dangereous).
There is a TECO_DEFINE_UNDO_CALL() to generate closures for
arbitrary functions now (ie. to call an arbitrary function
at undo-time). This simplified a lot of code and is much
shorter than manually pushing undo tokens in many cases.
* Instead of the ridiculous C++ Curiously Recurring Template
Pattern to achieve static polymorphy for user interface
implementations, we now simply declare all functions to
implement in interface.h and link in the implementations.
This is possible since we no longer hace to define
interface subclasses (all state is static variables in
the interface's *.c files).
* Headers are now significantly shorter than in C++ since
we can often hide more of our "class" implementations.
* Memory counting is based on dlmalloc for most platforms now.
Unfortunately, there is no malloc implementation that
provides an efficient constant-time memory counter that
is guaranteed to decrease when freeing memory.
But since we use a defined malloc implementation now,
malloc_usable_size() can be used safely for tracking memory use.
malloc() replacement is very tricky on Windows, so we
use a poll thread on Windows. This can also be enabled
on other supported platforms using --disable-malloc-replacement.
All in all, I'm still not pleased with the state of memory
limiting. It is a mess.
* Error handling uses GError now. This has the advantage that
the GError codes can be reused once we support error catching
in the SciTECO language.
* Added a few more test suite cases.
* Haiku is no longer supported as builds are instable and
I did not manage to debug them - quite possibly Haiku bugs
were responsible.
* Glib v2.44 or later are now required.
The GTK UI requires Gtk+ v3.12 or later now.
The GtkFlowBox fallback and sciteco-wrapper workaround are
no longer required.
* We now extensively use the GCC/Clang-specific g_auto
feature (automatic deallocations when leaving the current
code block).
* Updated copyright to 2021.
SciTECO has been in continuous development, even though there
have been no commits since 2018.
* Since these changes are so significant, the target release has
been set to v2.0.
It is planned that beginning with v3.0, the language will be
kept stable.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 136 |
1 files changed, 80 insertions, 56 deletions
diff --git a/configure.ac b/configure.ac index dd4854d..38d33bf 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ([2.65]) -AC_INIT([SciTECO], [0.6.4], +AC_INIT([SciTECO], [2.0.0], [robin.haberkorn@googlemail.com], [sciteco], [http://sciteco.sf.net/]) @@ -15,7 +15,7 @@ AC_CONFIG_AUX_DIR(config) AM_INIT_AUTOMAKE AC_CONFIG_TESTDIR([tests]) -AC_CONFIG_SRCDIR([src/main.cpp]) +AC_CONFIG_SRCDIR([src/main.c]) AC_CONFIG_HEADERS([config.h]) AC_CANONICAL_BUILD @@ -52,9 +52,8 @@ canonicalize() { # Checks for programs. LT_INIT -AC_PROG_CXX -AX_CXX_COMPILE_STDCXX(11, noext, mandatory) AC_PROG_CC +# FIXME: We want -std=gnu11 AC_PROG_CC_C99 AC_PROG_SED AC_PROG_INSTALL @@ -72,8 +71,9 @@ if [[ x$ax_cv_gnu_make_command = x ]]; then fi # Additionally required by the Scintilla build process: +AC_PROG_CXX +AX_CXX_COMPILE_STDCXX(11, noext, mandatory) AC_CHECK_TOOL(AR, ar) -AC_PROG_RANLIB # Check for Windows resource compiler and define # WIN32 conditional @@ -87,13 +87,6 @@ case $host in ;; esac -# Detect Clang (including Emscripten). -# A particular warning does not cooperate well with our use -# of the BSD data structures. -AC_CHECK_DECL(__clang__, [ - CXXFLAGS="$CXXFLAGS -Wno-mismatched-tags" -]) - # Changing the EXEEXT on emscripten ensures that we don't # need a special Makefile rule to generate Javascript files. AC_CHECK_DECL(EMSCRIPTEN, [ @@ -120,7 +113,8 @@ if [[ x$GROFF = x ]]; then AC_MSG_ERROR([GNU roff required!]) fi -# not necessarily required (depends on --enable-developer-doc) +# Doxygen is not necessarily required as long as +# you do not run `make devdoc`. AC_CHECK_PROG(DOXYGEN, doxygen, doxygen) AC_CHECK_PROG(DOT, dot, dot) DOXYGEN_HAVE_DOT=YES @@ -131,7 +125,7 @@ AC_SUBST(DOXYGEN_HAVE_DOT) AC_CHECK_PROG(SCITECO, sciteco, sciteco) # Checks for libraries. -PKG_CHECK_MODULES(LIBGLIB, [glib-2.0 >= 2.28], [ +PKG_CHECK_MODULES(LIBGLIB, [glib-2.0 >= 2.44], [ CFLAGS="$CFLAGS $LIBGLIB_CFLAGS" CXXFLAGS="$CXXFLAGS $LIBGLIB_CFLAGS" LIBS="$LIBS $LIBGLIB_LIBS" @@ -140,21 +134,11 @@ PKG_CHECK_MODULES(LIBGLIB, [glib-2.0 >= 2.28], [ # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([bsd/sys/queue.h], [], [ - AM_CPPFLAGS="$AM_CPPFLAGS -I\$(top_srcdir)/compat" -]) - case $host in *-mingw*) - AC_CHECK_HEADERS([windows.h psapi.h], , [ + AC_CHECK_HEADERS([windows.h], , [ AC_MSG_ERROR([Missing Windows headers!]) - ], [ - #include <windows.h> ]) - - # Make sure we get GetProcessMemoryInfo(): - AM_CPPFLAGS="$AM_CPPFLAGS -DPSAPI_VERSION=1" - LIBS="$LIBS -lpsapi" ;; esac @@ -165,35 +149,30 @@ AC_TYPE_SIZE_T # Checks for library functions. # They must exist on every target system. -AC_CHECK_FUNCS([memset setlocale strchr strrchr fstat], , [ +AC_CHECK_FUNCS([memset setlocale strchr strrchr fstat sscanf], , [ AC_MSG_ERROR([Missing libc function]) ]) # Library functions that we assume exist on UNIX/Linux # and UNIXoid systems, so that G_OS_UNIX is sufficient # to test for them. +# +# NOTE: mmap() is currently only used by dlmalloc(). +# # FIXME: Perhaps it would be more elegant to check whether -# glib defines G_OS_UNIX || G_OS_HAIKU instead... +# glib defines G_OS_UNIX instead... case $host in *-*-linux* | *-*-*bsd* | *-*-darwin* | *-*-cygwin* | *-*-haiku*) - AC_CHECK_FUNCS([realpath fchown dup dup2], , [ + AC_CHECK_FUNCS([realpath fchown dup dup2 getpid open read mmap], , [ AC_MSG_ERROR([Missing libc function]) ]) ;; esac -# Check for optional libc features. -# Some of this will only be found on glibc, -# others on FreeBSD/jemalloc. -AC_CHECK_HEADERS([malloc.h malloc_np.h]) -AC_CHECK_FUNCS([malloc_trim malloc_usable_size], [ - # Sometimes the declaration is missing. - AC_CHECK_DECLS([malloc_trim]) -]) - # # Config options # + AC_ARG_WITH(scintilla, AS_HELP_STRING([--with-scintilla=PATH], [Specify Scintilla's path [default=./scintilla]]), @@ -310,20 +289,13 @@ case $INTERFACE in ;; gtk) - # NOTE: Ubuntu 14.04 only has Gtk+ 3.10, so we have to support it. - # This version lacks GtkFlowBox. # gmodule is required by Scintilla. - PKG_CHECK_MODULES(LIBGTK, [gtk+-3.0 >= 3.10 gmodule-2.0], [ + PKG_CHECK_MODULES(LIBGTK, [gtk+-3.0 >= 3.12 gmodule-2.0], [ CFLAGS="$CFLAGS $LIBGTK_CFLAGS" CXXFLAGS="$CXXFLAGS $LIBGTK_CFLAGS" LIBS="$LIBS $LIBGTK_LIBS" ]) - # Should be available since v3.12 - AC_CHECK_FUNCS(gtk_flow_box_new, [], [ - GTK_FLOW_BOX_FALLBACK=true - ]) - GOB2_CHECK(2.0.20) AC_DEFINE(INTERFACE_GTK, 1, [Build with GTK+ 3.0 support]) @@ -353,17 +325,6 @@ AC_ARG_ENABLE(html-manual, [html_man=$enableval], [html_man=no]) AM_CONDITIONAL(BUILD_HTMLMAN, [test $html_man = yes]) -AC_ARG_ENABLE(developer-doc, - AS_HELP_STRING([--enable-developer-doc], - [Generate developer documentation using Doxygen [default=no]]), - [dev_doc=$enableval], [dev_doc=no]) -if [[ $dev_doc = yes -a x$DOXYGEN = x ]]; then - AC_MSG_ERROR([Enabled generating developer documentation, - but Doxygen cannot be found! - Try --disable-developer-doc.]) -fi -AM_CONDITIONAL(BUILD_DEVDOC, [test $dev_doc = yes]) - AC_ARG_ENABLE(bootstrap, AS_HELP_STRING([--disable-bootstrap], [Bootstrap using sciteco-minimal, @@ -375,6 +336,67 @@ if [[ $bootstrap = no -a x$SCITECO = x ]]; then fi AM_CONDITIONAL(BOOTSTRAP, [test x$bootstrap = xyes]) +AC_ARG_ENABLE(malloc-replacement, + AS_HELP_STRING([--enable-malloc-replacement], + [Replace the libc malloc() [default=check]]), + [malloc_replacement=$enableval], [malloc_replacement=check]) +if [[ $malloc_replacement = check ]]; then + # We currently do not support dlmalloc on Windows. + case $host in + *-mingw*) malloc_replacement=no;; + *) malloc_replacement=yes;; + esac +fi +AM_CONDITIONAL(REPLACE_MALLOC, [test $malloc_replacement = yes]) +if [[ $malloc_replacement = yes ]]; then + AM_CPPFLAGS="$AM_CPPFLAGS -I\$(top_srcdir)/contrib/dlmalloc" + AC_DEFINE(REPLACE_MALLOC, 1, [Define to 1 if the system malloc() is replaced.]) + AC_DEFINE(HAVE_MALLOC_H, 1, [Define to 1 if you have the <malloc.h> header file.]) + AC_DEFINE(HAVE_MALLOC_TRIM, 1, [Define to 1 if you have the `malloc_trim' function.]) +else + # NOTE: We don't check for malloc_footprint() since even if existing, + # it cannot be guaranteed to work (eg. as in dlmalloc with HAVE_MORECORE=1). + AC_CHECK_HEADERS([malloc.h malloc_np.h]) + AC_CHECK_FUNCS([malloc_trim], [ + AC_CHECK_DECLS([malloc_trim], , , [ + #include <malloc.h> + ]) + ]) + + case $host in + *-mingw*) + AC_CHECK_HEADERS([psapi.h], , [ + AC_MSG_ERROR([Missing Windows headers!]) + ], [ + #include <windows.h> + ]) + + # Make sure we get GetProcessMemoryInfo(): + AM_CPPFLAGS="$AM_CPPFLAGS -DPSAPI_VERSION=1" + LIBS="$LIBS -lpsapi" + ;; + *-*-linux*) + AC_CHECK_HEADERS([sys/time.h sys/resource.h]) + AC_CHECK_FUNCS([sysconf]) + + # FIXME: procfs might be available on other UNIXoid platforms. + # Perhaps add a --with-procfs? + # However, we currently also depend on sysconf(). + # Also, it should generally not be necessary to + # --disable-malloc-replacement on UNIX. + AC_DEFINE(HAVE_PROCFS, 1, [Whether procfs (/proc) is supported]) + ;; + *-*-*bsd*) + AC_CHECK_HEADERS([sys/types.h sys/sysctl.h]) + AC_CHECK_FUNCS([sysctl]) + ;; + *-*-darwin*) + AC_CHECK_HEADERS([mach/mach.h mach/message.h mach/kern_return.h mach/task_info.h]) + AC_CHECK_FUNCS([task_info mach_task_self]) + ;; + esac +fi + # This cannot be done with --enable-static as it only controls # which kind of libraries libtool builds. # Also, it cannot be controlled reliably by setting LDFLAGS for @@ -392,6 +414,8 @@ AM_CONDITIONAL(STATIC_EXECUTABLES, [test x$static_executables = xyes]) AC_CONFIG_FILES([GNUmakefile:Makefile.in src/GNUmakefile:src/Makefile.in] [src/interface-gtk/GNUmakefile:src/interface-gtk/Makefile.in] [src/interface-curses/GNUmakefile:src/interface-curses/Makefile.in] + [contrib/dlmalloc/GNUmakefile:contrib/dlmalloc/Makefile.in] + [contrib/rb3ptr/GNUmakefile:contrib/rb3ptr/Makefile.in] [lib/GNUmakefile:lib/Makefile.in] [doc/GNUmakefile:doc/Makefile.in doc/Doxyfile] [tests/GNUmakefile:tests/Makefile.in tests/atlocal]) |