summaryrefslogtreecommitdiffstats
path: root/Makefile
Commit message (Collapse)AuthorAgeFilesLines
* build: support linker flags/libs separation.Kaz Kylheku2021-01-141-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Our build system lumps all linker options together. The correct way is that linker flags are separated info flags and libs. Also, we respond to the LDFLAGS variable but ignore LDLIBS which is incorrect. Other issues are fixed. All that is fixed here. * Makefile (TXR_CFLAGS): Interpolate $(CFLAGS) last, so that options coming from CFLAGS can override previous options. (TXR_LDFLAGS): Interpolate $(LDFLAGS) last; same reason. (TXR_LDLIBS): New variable. (LINK_PROG): Put $(TXR_LDFLAGS) with the options, before the -o, and put $(TXR_LDLIBS) at the end. * configure (conf_ldlibs, platform_ldlibs): New variables. (usage text): Document platform-ldlibs and adjust documentation of platform-ldflags. (gen_config_make): Generate PLATFORM_LDLIBS and CONF_LDLIBS now needed by Makefile. (mainline): Adjusts various recipes to use conf_ldlibs instead of conf_ldflags, or in some cases both. In the case of libffi where we use pkg-config, we use the special pgk-config options to separately extract the flags and libs. We use EXTRA_LDLIBS instead of EXTRA_LDFLAGS in some conftest invocations, as necessary.
* Copyright year bump 2021.Kaz Kylheku2021-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * METALICENSE: 2020 copyrights bumped to 2021. Added note about SHA-256 routines from Colin Percival. * LICENSE, LICENSE-CYG, Makefile, alloca.h, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lex.yy.c.shipped, lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/copy-file.tl, share/txr/stdlib/debugger.tl, share/txr/stdlib/defset.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/each-prod.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/param.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/quips.tl, share/txr/stdlib/save-exe.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/vm-param.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, time.c, time.h, tree.c, tree.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr, y.tab.c.shipped: Copyright year bumped to 2021.
* build: Android support.Kaz Kylheku2020-12-231-0/+6
| | | | | | | | | | * Makefile (conftest.android): New helper target for testing for Android toolchain, via presence of __ANDROID__ preprocessor symbol, similarly to how we detect Darwin. * configure: New test for Android. This is mutually exclusive agains Darwin. On Android, we add some necessary feature selection macros to the compiler command line.
* configure: replace nm-based trick for sizesKaz Kylheku2020-10-091-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | The trick of declaring static arrays whose size is the value of an integer is not working with newer gcc 10 on Cygwin, because that compiler is rearranging the order of the arrays and adding padding. Basically, the writing on the wall is that this is not a good approach. I'm switching to a different approach. By initializing a suitable C structure (which contains character arrays) in a particular way, we can create a .o file in which a shell script is embedded. We can pull out the shell script and evaluate it to get the sizes of types. * Makefile (conftest.syms): Rule removed. (conftest.clean): Don't remove conftest.syms. * configure (conftest_syms, read_syms): Functions removed. (LANG, LC_ALL): New environment variables. This is needed because we are using tr to process a binary file; we can't have it trying to decode multi-byte characters. (mainline): Use new trick for obtaining variables like SIZEOF_INT.
* time: move time functions out of lib.c into time.c.Kaz Kylheku2020-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Makefile (OBJS): Add new time.o. * eval.c (eval_init): Registration of time functions is removed from here; it is done in time_init now, in time.c. * hash.c: Must #include "time.h" now. * lib.c (time_s, time_local_s, time_utc_s, time_string_s, time_parse_s, year_s, month_s, day_s, hour_s, min_s, sec_s, dst_s, gmtoff_s, zone_s): Variable definitions removed. These are now in time.c. Also declared in time.h. (time_sec, time_sec_usec, gmtime_r, localtime_r, string_time, time_string_local, time_string_utc, broken_time_list, tm_to_time_struct, broken_time_struct, time_fields_local, time_fields_utc, time_struct_local, time_struct_utc, time_fields_to_tm, time_struct_to_tm, make_time_impl, make_time, epoch_tm, strptime_wrap, time_parse, setenv, unsetenv, timegm_hack, make_time_utc, time_meth, time_string_meth, time_parse_meth, time_parse_local, time_parse_utc): Functions removed. These are now in time.c. (time_init): Removed, and now in time.c as an external function. * lib.h (time_sec, time_sec_usec, time_string_local, time_string_utc, time_fields_local, time_fields_utc, time_struct_local, time_struct_utc, make_time, make_time_utc, time_parse, time_parse_local, time_parse_utc): Declarations removed. Now in time.h. * rand.c: Must #include "time.h" now. * time.c: New file. * time.h: New file.
* configure: only detect lex in maintainer mode.Kaz Kylheku2020-09-241-2/+2
| | | | | | | | | * Makefile (lex.yy.c): Move rule into maintainer conditional. * configure: Describe maintainer variable in help text. Move lex check into maintainer conditional. * lex.yy.c.shipped: New file.
* configure: detect yacc only in maintainer mode.Kaz Kylheku2020-09-241-7/+1
| | | | | | | | | | | * Makefile (YACC_FLAGS): Removed. We don't need these because we won't be trying to get newer Bison to behave like older Bison. (y.tab.c): Drop reference to $(YACC_FLAGS). * configure: Entire yacc-detecting section is conditional on the maintainer Boolean variable. If the yacc program is detected as Bison, check for version 2.5 and fail if not found.
* parser: commit Bison-2.5-generated code.Kaz Kylheku2020-09-241-11/+8
| | | | | | | | | | | | | * Makefile (BS_LIC_FROM, BS_LIC_TO): Variables removed. (y.tab.c): Remove all filtering hacks. Don't remove the license from y.tab.c. Don't remove yyparse declaration from y.tab.h. Provide a pattern rule for producing any missing file X from X.shipped. That's how y.tab.c and y.tab.h get produced from y.tab.c.shipped and y.tab.h.shipped, respectively, in user mode. * y.tab.c.shipped, y.tab.h.shipped: New files, generated using Bison 2.5.
* new: maintainer mode.Kaz Kylheku2020-09-241-0/+4
| | | | | | | | | | | | | | | | | | There is now a ./configure --maintainer mode which establishes a variable called maintainer in config.make, with a y value. The initial use for maintainer mode will be that the Yacc parser (the y.tab.c and y.tab.h) files will no longer be regenerated whenever the parser.y file is newer. In the following commit, I will add a generated parser. * Makefile (y.tab.h, y.tab.c): These rules are now only enabled in maintainer mode via an ifeq. * configure (maintainer): New variable. (gen_config_make): Generate maintainer make variable definition in config.make.
* Makefile: stray tabs.Kaz Kylheku2020-09-241-1/+1
| | | | | * Makefile (lex.yy.c): Remove tabs that are being used for alignment instead of spaces.
* New tests for chmod.Kaz Kyheku2020-02-071-0/+2
| | | | | | | | | | | | | | | | The chmod fixes in the previous several commits were caught by this. * Makefile (tst/tests/018/chmod.ok): Set up TXR_ARGS for this test to give it the location of the temporary file to use as the object for testing permissions. (tst/tests/018): Disable TXR_DBG_OPTS for new directory. * tests/018/chmod.tl: New file. * tests/018/chmod.expected: Likewise. * tests/perm.tl: Likewise.
* build: drop config.log in favor of reconfigureKaz Kyheku2020-01-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | The configure command line is now turned into an executable script called reconfigure which can be invoked to repeat the config. * Makefile (distclean): Whether in a configured or state or not, try to remove reconfigure. In the configured state, don't remove config.log. (If distclean is invoked when not configured, the config.* pattern will remove config.log). * configure: rewrite the logic which turns the command line into text. It is now robust against spaces, quotes and meta-charaters. Moreover, the printed representation is chosen according to good heuristics to minimize unnecessary quoting and escaping. The config line is written into an executable script called reconfigure. This is now done twice; it is done immediately, so that we save the command line even if the configure subsequently fails. A comment is added to reconfigure indicating that configure didn't succeed. Then after a successful run through the tests, we save it again, without the cautionary comment. Help texts updated.
* build: deal with the mess of new Bison warnings.Kaz Kylheku2020-01-101-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | Newer versions of Bison produce spurious warnings in Yacc mode about %pure-parser being not POSIX conforming and also deprecated. Plus some strange fluff about "fix-its" that can be applied if option --update is specified. Let's detect at configure time whether the Yacc program being used is actually Bison 3.0 or greater, and if so, give it some flags to shut up these warnings. * Makefile (YACC_FLAGS): New variable, conditionally set based on yacc_is_newer_bison, also new variable, that being generated into config.make. (y.tab.c): Invoke $(TXR_YACC) with $(YACC_FLAGS). (conftest.yacc-version): New phony target for running Yacc with --version, out of the configure script. * configure (yacc_is_newer_bison): New variable. (gen_config_make): Generate yacc_is_newer_bison make variable. New test for whether Yacc is Bison. If so, and the version is >= 3.0, sets the yacc_is_newer_bison variable to y.
* Copyright year bump 2020.Kaz Kylheku2019-12-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, alloca.h, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, chksum.c, chksum.h, chksums/crc32.c, chksums/crc32.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.h, linenoise/linenoise.c, linenoise/linenoise.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/debugger.tl, share/txr/stdlib/defset.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/param.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/save-exe.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/vm-param.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, tree.c, tree.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr: Extended copyright notices to 2020.
* New data type: tnode.Kaz Kylheku2019-09-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Binary search tree nodes are being added as a basic heap data type. The C type tag is TNOD, and the Lisp type is tnode. Binary search tree nodes have three elements: a key, a left child and a right child. The printed notation is #N(key left right). Quasiquoting is supported: ^#N(,foo ,bar) but not splicing. Because tnodes have three elements, they they fit into TXR's four-word heap cell, not requiring any additional memory allocation. These nodes are going to be the basis for a binary search tree container, which will use the scapegoat tree algorithm for maintaining balance. * tree.c, tree.h: New files. * Makefile (OBJS): Adding tree.o. * eval.c (expand_qquote_rec): Recurse through tnode cells, so unquotes work inside #N syntax. * gc.c (finalize): Add TNOD to no-op case in switch; tnodes don't require finalization. (mark_obj): Traverse tnode cell. * hash.c (equal_hash): Add TNOD case. * lib.c (tnode_s): New symbol variable. (seq_kind_tab): New entry for TNOD, mapping to SEQ_NOTSEQ. (code2type, equal): Handle TNOD. (obj_init): Initialize tnode_s variable. (obj_print_impl, populate_obj_hash): Handle TNOD. (init): Call tree_init function in tree.c. * lib.h (enum type, type_t): New enumeration TNOD. (struct tnod): New struct type. (union obj, obj_t): New union member tn of type struct tnod. (tnode_s): Declard. * parserc.c (circ_backpatch): Handle TNOD, so circular notation works through tnode cells. * parser.l (grammar): Recognize #N prefix, mapping to HASH_N token. * parser.y (HASH_N): New grammar terminal symbol. (tnode): New nonterminal symbol. (i_expr, n_expr): Add tnode cases to productions. (yybadtoken): Map HASH_N to "#N" string.
* build: clean target should remove run.shKaz Kylheku2019-09-091-2/+2
| | | | | * Makefile (clean): If it exists, remove the temporary run.sh that is generated by the install-tests target.
* build: bugfix: compiler opts duplicated; remove_flags broken.Kaz Kylheku2019-08-251-1/+1
| | | | | | * Makefile (TXR_CFLAGS): Use := operator rather than += when filtering out REMOVE_FLAGS, or else REMOVE_FLAGS are not really removed, and we duplicate all the flags.
* New: MD5 digest functions.Kaz Kylheku2019-08-231-1/+1
| | | | | | | | | | | | | | | | | * Makefile (OBJS): New object file, chksums/md5.o. * chksum.c (sha256_ensure_buf): Renamed to chksum_ensure_buf and made generic so MD5 code can borrow it. (sha256_stream, sha256): Call chksum_ensure_buf instead of sha256_ensure_buf, passing in new length and hash name parameters. (md5_stream_impl, md5_buf, md5_str): New static functions. (md5_stream, md5): New functions. (chksum_init): Register md5-stream and md5 intrinsics. * chksum.h (md5_stream, md5): Declared. * chksums/md5.c, chksums/md5.h: New files.
* tests: add test related to recent @(collect) change.Kaz Kylheku2019-08-121-0/+2
| | | | | | | | | | | This test will misbehave on TXR without the previous fix; it will not collect columns of data which keep the corresponding rows items together. * tests/002/variant, tests/002/variant.expected, tests/002/variant.txr: New files. * Makefile (TXR_ARGS, TXR_OPTS): Override for new test.
* tests: add @{var1 var2} match test.Kaz Kylheku2019-07-031-0/+1
| | | | | | | | | | | | | | * tests/001/query-5.txr: New file. * tests/001/query-5.expected: New file. * Makefile (tst/tests/001/query-5.ok): Pass -B to txr for this new test. * tests/017/glob-carray.expected: Updated, because the glob test globs over the contents of tests/001 directory. * tests/017/glob-zarray.expected: Likewise.
* New: CRC-32 functions.Kaz Kylheku2019-06-241-1/+1
| | | | | | | | | | | | * Makefile (OBJS): Add chksums/crc32.o. * chksum.c (crc32_stream, crc32): New functions. (chksum_init): Register crc32-stream and crc32 intrinsic functions. * chksums/crc32.c, chksums/crc32.h: New files. * txr.1: Documented.
* * Makefile (OBJS): New objects chksum.o and chksums/sha256.o.Kaz Kylheku2019-06-231-1/+1
| | | | | | | | | | * chksum.c, chksum.h, chksums/sha256.c, chksums/sha256.h: New files. * lib.c (init): Call chksum_init. * txr.1: Documented. * LICENSE: Add SHA-256 copyright notice.
* Makefile: non-configured distclean removes tlo's.Kaz Kylheku2019-06-121-1/+1
| | | | | | * Makefile (distclean): distclean target for not-configured state removes .tlo files by wildcard, including the old .tlo2 files that we used to generate once.
* build: allow $(pwd)/configure to work.Kaz Kylheku2019-04-291-1/+1
| | | | | | | | | | | | | | | | | | | | | When the build is being done in the source directory, allow the configure script to be executed via path names other than just ./configure, such as an absolute path. Some distros use this. * configure (build_in_srcdir): New variable. (inode): New function. Rather than checking whether "$source_dir" is ".", we test whether they are the same inode. If they are the same, we now also set the build_in_srcdir variable in addition to generating the usual warning. (gen_config_make): Propagate the build_in_srcdir into config.make. * Makefile: use the build_in_srcdir variable from config.make to determine whether we are building in the source directory, rather than relying on top_srcdir being blank.
* build: remove nonexistent config option.Kaz Kylheku2019-02-261-2/+2
| | | | | | * Makefile (dbg/%-win.o, opt/%-win.o): Don't pass CONFIG_WIN_MAIN=1 preprocessor symbol; it's not referenced anywhere, and never has been.
* build: get rid of .tlo2 files.Kaz Kylheku2019-02-081-12/+3
| | | | | | | | | | | | | | | After the defvar bugfix in the previous commit, the only differences between .tlo and .tlo2 files are the names of a few gensyms here and there. In other words, they are identical code; therefore, there is no point in compiling them. * Makefile (STDLIB_TLOS2): Variable removed. (%.tlo2): Implicit rule removed. (stage1 stage2): Phony targets removed. (all): Directly depends on $(STDLIB_TLOS) without stage1 intermediary. (clean-tlo): Don't remove $(STDLIB_TLOS2).
* install: broken when using separate build dir.Kaz Kylheku2019-01-251-2/+1
| | | | | | | | * Makefile (install): Drop the $(top_srcdir) prefix from share/txr/stdlib materials. This fails for the .tlo files which are only found in the build directory, not the source directory. The .txr and .tl files are found in both, thanks to symlinks; for those it works either way.
* mpi: remove unused mplogic module.Kaz Kylheku2019-01-181-1/+1
| | | | * Makefile (MPI_OBJ_BASE): remove mplogic.o.
* Copyright year bump 2019.Kaz Kylheku2019-01-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/asm.tl, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/compiler.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/vm-param.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, vm.c, vm.h, vmop.h, win/cleansvg.txr: Extended Copyright line to 2018.
* bugfix: LDFLAGS not pulled in.Kaz Kylheku2018-12-121-1/+1
| | | | | * Makefile (TXR_LDFLAGS): Fix use of wrong assignment operator which clobbers the previous assignment of $(LDFLAGS).
* More reasonable fallback for self path.Kaz Kylheku2018-05-041-2/+4
| | | | | | | | | | | | | | | | * Makefile (opt/txr.o, dbg/txr.o): Set up TXR_REL_PATH preprocessor symbol on command line which specifies the hard installation path derived from the configure prefix. * txr.c (get_self_path): The fallback implementation simply returns TXR_REL_PATH. This will work if in fact the executable is installed at that path. What it means is that the build of TXR which uses this fallback get_self_path will not support relocation: the installation cannot be moved to another directory, yet still find its supporting files. This is better than what we are replacing: not working even in the original installation directory, if not invoked by an absolute path.
* Makefile: use order-only between early and late tlo-s.Kaz Kylheku2018-04-291-1/+1
| | | | | | | | | * Makefile: make STDLIB_EARLY_TLOS order-only prerequisites of STDLIB_LATE_TLOS, rather than conventional prerequisites. This means that the early tlo-s are built or rebuilt before the late ones, but there is no other dependency expressed: an update of early tlo-s doesn't force late tlo-s to be out-of-date and updated also.
* build: fix failure due to .tlo compilation order.Kaz Kylheku2018-04-261-0/+6
| | | | | | | | | | | | | On newer GNU Make versions, $(wildcard ...) doesn't sort its results, and so we compile .tlo files in an arbitrary order. For the most part, this is fine. However, there is a complicated circular dependency involving the error.tl file requiring it to be compiled first. * Makefile (STLIB_EARLY_PATS, STDLIB_EARLY_TLOS, STDLIB_LATE_TLOS): New variables. Use these to express a dependency which causes error.tlo to be built first.
* build: remove dubious license header from y.tab.c.Kaz Kylheku2018-04-161-0/+10
| | | | | | | | | | | | | | | | | | | | | | | The GNU Bison parser has a GPL header in the parser skeleton which gets copied to the generated parser. The GPL asserts that the entire file falls under the GPL (but as a special exception, it may be used in any manner whatsoever in a program, as long as it isn't used as the skeleton of a parser generator). The GPL assertion is false; the file is not entirely derived from the skeleton but contains code directly copied from parser.y, as well as tables generated from parser.y's original grammar. Since we are definitely not using this as a parser skeleton for a parser generator and are thus allowed to do whatever we want such as compiling this into proprietary object files, I'm removing the copyright header as a build step. You never know; someone could package up a built directory of TXR containing a Bison-generated y.tab.c, and then it looks like there is a GPL-ed file in the project. * Makefile (CM): New variable, needed for interpolating literal commas into macro calls. (BS_LIC_FROM, BS_LIC_TO): New variables. (y.tab.c): Filter y.tab.c to remove GPL comment.
* Makefile: bugfix: shell quoting issue in macro.Kaz Kylheku2018-04-161-1/+1
| | | | | | | | | | * Makefile (SH): The $(1) macro argument is substituted into a shell '...' quote. It may contain single quotes itself, so these have to be mapped to the famous '\'' sequence. Currently, only one SH call has '...' syntax in it: one in the y.tab.c rule which calls sed -e '/yyparse/d'. That works anyway, and the quotes could be removed from it; but let's fix the SH macro.
* build: compiling Lisp requires ./txr to exist.Kaz Kylheku2018-04-121-2/+2
| | | | | | | | * Makfile (%.tlo, %.tlo2): We take advantage of Gmake's order-only prerequisites to express this dependency. This means that .tlo and .tlo2 files are not considered outdated when $(PROG) is newer; it only ensures that $(PROG) cannot be missing when a .tlo or .tlo2 must be updated.
* build: prevent make parallelization.Kaz Kylheku2018-04-121-0/+2
| | | | | | * Makefile: add .NOTPARALLEL: special target. This Makfile doesn't support parallel builds; it relies on left-to-right execution of prerequisites in some places.
* build: don't rebuild tlo's all the time.Kaz Kylheku2018-04-071-2/+2
| | | | | | | | * Makefile (%.tlo, %.tlo2): Drop dependency on $(TXR). Of course, the dependency is strictly correct, but most changes to TXR are irrelevant. Moreover, not all relevant dependencies are in place anyway; if we change compile.tl, only the compile.tlo is recompiled.
* stdlib: all code read under sys package.Kaz Kylheku2018-04-061-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Another part of the preparation for an upcoming change. All library code is now read in the sys package, so any symbols that are interned (local variables and whatnot) are in sys and will not be exposed to user code. We have to overcome some annoyances to achieve this: - We have to stay away from the symbols exp or var, because they are now sys:exp and sys:var with their special meaning. - Instances in which a symbol of the same name exists in both sys and usr present a problem; the plain symbol now is the usr one. For instance rplaca will refer to sys:rplaca, so a small amount of code has to explicitly use usr:rplaca. * Makefile (COMPILE_TL): Change to the sys package before compiling library code. * lisplib.c (lisplib_try_load): Bind *package* to the system package. * share/txr/stdlib/asm.tl, share/txr/stdlib/compiler.tl: Remove in-package macro invocation; we don't need this since all files are loaded or compiled in the sys package. * share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/trace.tl share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/ver.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl: Deal with the various usr versus sys symbol issues.
* build: support compiling stdlib.Kaz Kylheku2018-04-051-5/+30
| | | | | | | | | | | | * Makefile (STDLIB_SRCS, STDLIB_TLOS, STDLIB_TLOS2): New variables. (COMPILE_TL): New recipe macro. (%.tlo, %.tlo2): New pattern rules. (all): Depend on new stage1 and stage2 targets. (stage1, stage2): New phony targets. (clean): Add clean-tlo dependency. (clean-tlo): New phony target. (install): Install .tlo files also.
* New: virtual machine with assembler.Kaz Kylheku2018-03-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is the start of compiler work to make TXR Lisp execute faster. In six days of part time work, we now have a register-style virtual machine with 32 instructions, handling exceptions, unwind-protect, lexical closures, and global environment access/mutation. We have a complete assembler and disassembler for this machine. The assembler supports labels with forward referencing with backpatching, and features pseudo-ops: for instance the (mov ...) pseudo-instruction chooses one of three kinds of specific move instruction based on the operands. * Makelfile (OBJS): Add vm.o. * eval.c (lookup_sym_lisp1): Static function becomes external; the virtual machine needs to use this to support that style of lookup. * genvmop.txr: New file. This is the generator for the "vmop.h" header. * lib.c (func_vm): New function. (generic_funcall): Handle the FVM function type via new vm_execute_closure function. In the variadic case, we want to avoid the argument copying which we do for the sake of C functions that get their fixed arguments directly, and then just the trailing arguments. Thus the code is restructured a bit in order to switch twice on the function type. (init): Call vm_init. * lib.h (functype_t): New enum member FVM. (struct func): New member in the .f union: vm_desc. (func_vm): Declared. * lisplib.c (set_dlt_entries_impl): New static function, formed from set_dlt_entries. (set_dlt_entries): Reduced to wrapper for set_dlt_entries_impl, passing in the user package. (set_dlt_entries_sys): New static function: like set_dlt_entries but targetting the sys package. (asm_instantiate, asm_set_entries): New static functions. (lisplib_init): Auto-load the sys:assembler class. * share/txr/stdlib/asm.tl: New file. * vm.c, vm.h, vmop.h: New files.
* Copyright year bump 2018.Kaz Kylheku2018-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * LICENSE, LICENSE-CYG, METALICENSE, Makefile, args.c, args.h, arith.c, arith.h, buf.c, buf.h, cadr.c, cadr.h, combi.c, combi.h, configure, debug.c, debug.h, eval.c, eval.h, ffi.c, ffi.h, filter.c, filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h, itypes.c, itypes.h, jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c, parser.h, parser.l, parser.y, protsym.c, rand.c, rand.h, regex.c, regex.h, share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl, share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl, share/txr/stdlib/doloop.tl, share/txr/stdlib/error.tl, share/txr/stdlib/except.tl, share/txr/stdlib/ffi.tl, share/txr/stdlib/getopts.tl, share/txr/stdlib/getput.tl, share/txr/stdlib/hash.tl, share/txr/stdlib/ifa.tl, share/txr/stdlib/keyparams.tl, share/txr/stdlib/op.tl, share/txr/stdlib/package.tl, share/txr/stdlib/path-test.tl, share/txr/stdlib/place.tl, share/txr/stdlib/pmac.tl, share/txr/stdlib/socket.tl, share/txr/stdlib/stream-wrap.tl, share/txr/stdlib/struct.tl, share/txr/stdlib/tagbody.tl, share/txr/stdlib/termios.tl, share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl, share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl, share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h, stream.c, stream.h, struct.c, struct.h, strudel.c, strudel.h, sysif.c, sysif.h, syslog.c, syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h, win/cleansvg.txr: Extended Copyright line to 2018.
* New feature: structure delegate streams.Kaz Kylheku2017-12-081-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new kind of stream object which redirects its operations to the methods of a structure. * Makefile (OBJS): New object file, strudel.o. * lib.c (init): Call new strudel_init function. * lisplib.c (stream_wrap_set_entries, stream_wrap_instantiate): New static functions. (lisplib_init): Arrange for autloading of new stream-wrap.tl. * share/txr/stdlib/stream-wrap.tl: New file. * stream.c (put_string_s, put_char_s, put_byte_s, get_line_s, get_char_s, get_byte_s, unget_char_s, unget_byte_s, put_buf_s, fill_buf_s, flush_s, seek_s, truncate_s, get_prop_s, set_prop_s, get_error_s, get_error_str_s, clear_error_s, get_fd_s): New symbol variables. (stream_init): New symbol variables initialized. Numerous functions registered via these variables now rather than intern(...) expressions. * stream.h (put_string_s, put_char_s, put_byte_s, get_line_s, get_char_s, get_byte_s, unget_char_s, unget_byte_s, put_buf_s, fill_buf_s, flush_s, seek_s, truncate_s, get_prop_s, set_prop_s, get_error_s, get_error_str_s, clear_error_s, get_fd_s): Declared. * strudel.c, strudel.h: New files.
* Makefile: further improvement of tests.Kaz Kylheku2017-10-251-32/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem is that if a test is interrupted, it will not be re-run because the .ok stamp file depends only on an .out file, and that has been successfully created. We completely remove .out files from the rule tree. Quite simply, the output of a test is the .ok stamp. If that is out of date or doesn't exist, the test is run. Generation of the .out is just a side effect. * Makefile (TESTS_OK): Calculate this variable directly from the wildcard over .txr and .tl files..directly rather than from TESTS_OUT. (TESTS_OUT): Variable removed. (TXR_OPTS, TXR_ARGS): The target-specific assignments of these variables for specific tests is now done against .ok stamp file targets rather than .out targets. (TST_EXPECTED, TST_OUT): New helper variables for condensing repeated instances of some syntax. (tst/%.out): Both of these rules are turned into rules which target tst/%.ok. The .out files are just a side effect; the goal is to update the stamp. If an .out file is removed, the test won't be re-run; only if an .ok file is removed, or any of the real prerequisites change. (%.ok): This rule disappears, and its body containing the conditional stamp file touch is moved into both tst/%.ok rules.
* Makefile: fix silliness in "tests" target.Kaz Kylheku2017-10-251-10/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Last I addressed this, I didn't get it quite right. The problem is that the .out files are being removed when a test fails, which is annoying. The whole redirection of test results to a temp file which is then renamed is silly. Now, the .out files are preserved. Whether or not a test passed depends on whether or not the .ok stamp file is created or updated, so it doesn't matter whether an .out file exists or not. Also, tests are made dependent on the executable, and on the .expected files. If the executable is newer than the test outputs, all the tests will re-run. Also, if any .expected file is touched, the corresponding test will be re-run. * Makefile (clean): Do not remove $(TESTS_TMP). (TESTS_TMP): Variable removed. (tst/%.out): In both rules that run the test and make .out files simply redirect the output directly to the .out file represented as the $@ target. This is how it was before, once upon a time. (%.ok): Do not remove the .out file represdented by $< if the test fails; it is sufficient not to create/touch the .ok stamp file.
* Makefile: improve command abbreviation.Kaz Kylheku2017-10-251-4/+8
| | | | | | | | | | | | For all build steps other than linking, print only the leftmost prerequisite of the target. * Makefile (ABBREV): The macro references $< rather than $^, and hence longer needs the $(DEP_$@) filtering. (ABBREVN): New macro, identical to previous ABBREV, modulo a whitespace fix: removal of a stray tab character. (LINK_PROG): For linking, use ABBREVN so that all the object files are shown.
* Makefile: clean temporary file used in testing.Kaz Kylheku2017-09-281-0/+1
| | | | * Makefile (clean): Remove $(TESTS_TMP) if it exists.
* Makefile: print failing command in condensed mode.Kaz Kylheku2017-09-281-63/+82
| | | | | | | | | | | | | | | | | | When make output is condensed, showing a summary of each build step in the style "CC txr.c -> opt/txr.o", as is the case by default, the failing build command is now shown. Previously, a failed build had to be re-invoked with make VERBOSE=y to show the failing command. * Makefile (SH): New macro. (COMPILE_C, COMPILE_C_WITH_DEPS, LINK_PROG, WINDRES, INSTALL): These macros now invoke commands via SH rather than directly. (lex.yy.c, y.tab.h, y.tab.c, install-tests, %): Recipes for these targets use SH macro for executing shell commands rather than specifying them directly. (tst/%.out, %.ok, %.expected): These test-related pattern rules also use SH.
* configure: deal with non-standard libffi installations.Kaz Kylheku2017-07-041-0/+4
| | | | | | | | | | | | | | | | | This addresses a failure to build with libffi on Arch Linux, reported by Joe Eib. * Makefile (opt/ffi.o, dbg/ffi.o): Pull LIBFFI_CFLAGS into TXR_CFLAGS for just these object files. * configure (have_pkgconfig, libffi_cflags): New variables. (gen_config_make): Create new Makefile variable, LIBFFI_CFLAGS, from libffi_cflags. New configure test to detect pkg-config. Libffi test falls back on using pkg-config to test for existence of the library and to get the cflags and ldflags. Any needed cflags end up in LIBFFI_CFLAGS and are used only when compiling ffi.c.
* ffi: retain some functionality if libffi missing.Kaz Kylheku2017-06-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The FFI module is more than just foreign calls and callbacks; it provides a type system and operations for working with binary data. None of it depends on libffi being present and so shouldn't be disabled if libffi is not available. * Makefile (ffi.o): Unconditionally link this object file, not subject to the have_libffi variable. * configure (have_libffi): Variable removed. (gen_config_make): Do not generate a have_libffi variable into config.make, since nothing needs it. * ffi.c (ffi_type): Fake ffi_type defined if libffi is missing. (FFI_TYPE_STRUCT): Fake macro. (ffi_type ffi_type_void, ffi_type_pointer, ffi_type_sint, ffi_type ffi_type_schar, ffi_type_uchar, ffi_type ffi_type_sshort, ffi_type_ushort, ffi_type ffi_type_sint, ffi_type_uint, ffi_type ffi_type_slong, ffi_type_ulong, ffi_type ffi_type_sint8, ffi_type_uint8, ffi_type ffi_type_sint16, ffi_type_uint16, ffi_type ffi_type_sint32, ffi_type_uint32, ffi_type ffi_type_sint64, ffi_type_uint64, ffi_type ffi_type_float, ffi_type_double): Fake libffi type objects, so that code which references these things will build without modification. (ffi_get_type): Function only defined if we have libffi. (ffi_type_struct_destroy_op, ffi_struct_clone, make_ffi_type_struct, ffi_array_clone, make_ffi_type_array): Don't work with ffi_type's element array if we don't have libffi; our fake ffi_type doesn't have such an array. (struct txr_ffi_closure): Type only defined if we have libffi. (ffi_closure_struct, ffi_closure_struct_checked, ffi_closure_print_op, ffi_closure_destroy_op, ffi_closure_mark_op, ffi_closure_put): Functions only defined if we have libffi. (ffi_closure_ops): Static structure only defined if we have libffi. (ffi_init_types): Don't register a closure type if we don't have libffi. (struct txr_ffi_call_desc): Don't define type if we don't have libffi. (ffi_call_desc, ffi_call_desc_checked, ffi_call_desc_print_op, ffi_call_desc_destroy_op, ffi_call_desc_mark_op, ffi_make_call_desc, ffi_call_wrap, ffi_closure_dispatch, ffi_closure_dispatch_safe, ffi_make_closure, ffi_closure_get_fptr): Functions only defined if we have libffi. (ffi_call_desc_ops): Static structure only defined if we have libffi. (ffi_init): Only register ffi-make-call-desc, ffi-call, and ffi-make-closure if we have libffi. * lib.c: Include "ffi.h" header unconditionally. (generic_funcall, ref, refset, int): Remove #if HAVE_LIBFFI.