1.1 --- a/docs/lplc.1 Fri Feb 10 17:52:47 2017 +0100
1.2 +++ b/docs/lplc.1 Fri Feb 10 19:31:06 2017 +0100
1.3 @@ -12,8 +12,14 @@
1.4 .B lplc
1.5 .I --version
1.6 .SH DESCRIPTION
1.7 -Compile the program whose principal file is given in place of
1.8 -.IR file .
1.9 +.B lplc
1.10 +compiles programs written in the Lichen language, taking the indicated
1.11 +.I file
1.12 +representing the principal source file of a program, compiling the program to an
1.13 +intermediate representation, and then building the result using a C compiler and
1.14 +.B make
1.15 +to produce an executable. Other source files need not be specified: they will be
1.16 +identified by the compiler and loaded as required.
1.17 .SH OPTIONS
1.18 The following options may be specified:
1.19 .PP
1.20 @@ -21,9 +27,15 @@
1.21 .B \-c
1.22 Only partially compile the program; do not attempt to build or link it
1.23 .TP
1.24 +.B \-E
1.25 +Ignore environment variables affecting the module search path
1.26 +.TP
1.27 .B \-g
1.28 Generate debugging information for the built executable
1.29 .TP
1.30 +.B \-P
1.31 +Show the module search path
1.32 +.TP
1.33 .B \-q
1.34 Silence messages produced when building an executable
1.35 .TP
1.36 @@ -62,11 +74,31 @@
1.37 of compiling a program:
1.38 .PP
1.39 .TP
1.40 -.B \-\-help
1.41 +.BR \-h ", " \-? ", " \-\-help
1.42 Show a summary of the command syntax and options
1.43 .TP
1.44 -.B \-\-version
1.45 +.BR \-V ", " \-\-version
1.46 Show version information for this tool
1.47 +.SH ENVIRONMENT VARIABLES
1.48 +.TP
1.49 +ARCH
1.50 +Indicates a prefix to be used with tool names when building an executable. This
1.51 +permits things like cross-compilation where tools have been provided with names
1.52 +featuring architecture- and system-specific prefixes. For example,
1.53 +.I mipsel-linux-gnu
1.54 +may be used to indicate the use of tools for the MIPS architecture running
1.55 +GNU/Linux in little-endian mode.
1.56 +.TP
1.57 +LICHENPATH
1.58 +A collection of directories that are searched before those in the collection
1.59 +comprising the default "module search path". This collection, if already defined
1.60 +in the environment, may be excluded by specifying the
1.61 +.B \-E
1.62 +option.
1.63 +.SH AUTHOR
1.64 +Paul Boddie <paul@boddie.org.uk>
1.65 +.SH RESOURCES
1.66 +The project Web site: http://projects.boddie.org.uk/Lichen
1.67 .SH COPYRIGHT
1.68 Copyright \(co 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
1.69 2014, 2015, 2016, 2017 Paul Boddie <paul@boddie.org.uk>
1.70 @@ -77,5 +109,3 @@
1.71 .SH SEE ALSO
1.72 .BR cc (1),
1.73 .BR make (1).
1.74 -.SH RESOURCES
1.75 -The project Web site: http://projects.boddie.org.uk/Lichen
2.1 --- a/lplc Fri Feb 10 17:52:47 2017 +0100
2.2 +++ b/lplc Fri Feb 10 19:31:06 2017 +0100
2.3 @@ -22,7 +22,7 @@
2.4 VERSION = "0.1"
2.5
2.6 from errors import *
2.7 -from os import rename
2.8 +from os import environ, rename
2.9 from os.path import abspath, exists, isfile, join, split
2.10 from pyparser import error
2.11 from subprocess import Popen, PIPE
2.12 @@ -32,6 +32,7 @@
2.13
2.14 libdirs = [
2.15 join(split(__file__)[0], "lib"),
2.16 + split(__file__)[0],
2.17 "/usr/share/lichen/lib"
2.18 ]
2.19
2.20 @@ -90,7 +91,7 @@
2.21
2.22 # Show help text if requested or if no arguments are given.
2.23
2.24 - if "--help" in args or not args:
2.25 + if "--help" in args or "-h" in args or "-?" in args or not args:
2.26 print >>sys.stderr, """\
2.27 Usage: %s [ <options> ] <filename>
2.28
2.29 @@ -98,7 +99,9 @@
2.30 The following options may be specified:
2.31
2.32 -c Only partially compile the program; do not attempt to build or link it
2.33 +-E Ignore environment variables affecting the module search path
2.34 -g Generate debugging information for the built executable
2.35 +-P Show the module search path
2.36 -q Silence messages produced when building an executable
2.37 -r Reset (discard) cached program information; inspect the whole program again
2.38 -t Silence timing messages
2.39 @@ -122,13 +125,16 @@
2.40 of compiling a program:
2.41
2.42 --help Show a summary of the command syntax and options
2.43 +-h Equivalent to --help
2.44 +-? Equivalent to --help
2.45 --version Show version information for this tool
2.46 +-V Equivalent to --version
2.47 """ % basename
2.48 sys.exit(1)
2.49
2.50 # Show the version information if requested.
2.51
2.52 - elif "--version" in args:
2.53 + elif "--version" in args or "-V" in args:
2.54 print >>sys.stderr, """\
2.55 lplc %s
2.56 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
2.57 @@ -142,6 +148,7 @@
2.58 # Determine the options and arguments.
2.59
2.60 debug = False
2.61 + ignore_env = False
2.62 make = True
2.63 make_verbose = True
2.64 reset = False
2.65 @@ -160,6 +167,7 @@
2.66
2.67 for arg in args:
2.68 if arg == "-c": make = False
2.69 + elif arg == "-E": ignore_env = True
2.70 elif arg == "-g": debug = True
2.71 elif arg == "-q": make_verbose = False
2.72 elif arg == "-r": reset = True
2.73 @@ -176,6 +184,20 @@
2.74 if needed == 0:
2.75 l = filenames
2.76
2.77 + # Add extra components to the module search path from the environment.
2.78 +
2.79 + if not ignore_env:
2.80 + extra = environ.get("LICHENPATH")
2.81 + if extra:
2.82 + libdirs = extra.split(":") + libdirs
2.83 +
2.84 + # Show the module search path if requested.
2.85 +
2.86 + if "-P" in args:
2.87 + for libdir in libdirs:
2.88 + print libdir
2.89 + sys.exit(0)
2.90 +
2.91 # Obtain the program filename.
2.92
2.93 if len(filenames) != 1: