standardizing installation paths and default build.

This commit is contained in:
Norayr Chilingarian 2026-09-17 01:47:47 +04:00
parent c985dcb3e4
commit c0fb40fb69
11 changed files with 253 additions and 115 deletions

View file

@ -27,14 +27,14 @@ default libraries complying with the Oakwood Guidelines for Oberon-2 compilers.
## Installation ## Installation
It is easy to install the Oberon compiler and libraries It is easy to build the Oberon compiler and libraries
with the following simple steps: with the following simple steps:
1. Install pre-requisites such as git, gcc, static C libraries, diff utils. 1. Install pre-requisites such as git, gcc, static C libraries, diff utils.
2. Clone the repository: `git clone https://github.com/vishaps/voc`. 2. Clone the repository: `git clone https://github.com/vishaps/voc`.
3. Optionally `export CC=clang` or `export CC=tcc`. 3. Optionally choose a C compiler, for example with `export CC=clang`.
4. run `make full`. 4. Run `make`.
5. Optionally install to a system directory such as /opt or /usr/local/share with `make install` (might be with sudo). 5. Optionally install to a system directory with `make install` (might be with sudo).
6. Set your PATH variable to include the compiler binary. 6. Set your PATH variable to include the compiler binary.
These are detailed below: These are detailed below:
@ -58,28 +58,38 @@ More details, including for MingW and MS C, in [**Installation**](/doc/Installat
1. `git clone https://github.com/vishaps/voc` 1. `git clone https://github.com/vishaps/voc`
2. `cd voc` 2. `cd voc`
3. `make full` 3. `make`
`make full` will create an installation directory under your local repository at voc/install. `make` is an unprivileged build. It creates an installation image under
`voc/install`, runs the confidence tests, and does not copy files to the host.
`mmake full` runs `ldconfig` to configure the linker to find libraries in voc/install, but you Choose a different C compiler with, for example, `CC=clang make`.
need to update your program search PATH yourself (see step 4 below).
#### 3. Optionally install to a system directory #### 3. Optionally install to a system directory
Run `make install` as root to copy the voc/install directory to the appropriate directory Run `make install` as root to copy the `voc/install` image to the configured directories.
for your OS as follows: The default Unix locations are `/usr/local/bin`, `/usr/local/share/voc`, and
`/usr/local/lib`. Override `PREFIX`, `BINDIR`, `INSTALLDIR`, and `LIBDIR` as needed.
For a package build, use `DESTDIR` so the staged path is not compiled into the
compiler configuration:
make install PREFIX=/usr DESTDIR=/path/to/package-root
To retain the historical self-contained layout, use an explicit installation
directory instead:
make install INSTALLDIR=/opt/voc
| System | Where `make install` puts the installation | | System | Where `make install` puts the installation |
| ------- | -------------------------------------- | | ------- | -------------------------------------- |
| Linux | `/opt/voc` | | Unix | `/usr/local/bin`, `/usr/local/share/voc`, `/usr/local/lib` |
| BSD | `/usr/local/share/voc` |
| Windows | See [**Windows installation**](/doc/Winstallation.md) | | Windows | See [**Windows installation**](/doc/Winstallation.md) |
| Termux | `/data/data/com.termux/files/opt/voc` | | Termux | `/data/data/com.termux/files/opt/voc` |
`make install` updates `ldconfg` with the new library locations. For a manual installation with libraries outside the standard linker paths,
use `make install-system`; unlike `make install`, it also runs `ldconfig`.
#### 4. Set your PATH environment variable #### 4. Set your PATH environment variable
@ -87,16 +97,17 @@ for your OS as follows:
Since there are so many ways that different systems and users manage their PATHs, we leave Since there are so many ways that different systems and users manage their PATHs, we leave
it to you to update your path to include the compiler binary. it to you to update your path to include the compiler binary.
Both `make full` and `make install` display instructions on setting the path specific to your Both `make` and `make install` display instructions on setting the path specific to your
system. system. A staged installation is run from its final installation paths after
the package is installed, not from its `DESTDIR` path.
For reference this will be: For reference this will be:
| Installation choice | Set path | | Installation choice | Set path |
| --------- | -------------------------------------- | | --------- | -------------------------------------- |
| Just `make full` | `export PATH="your-repository-clone/install/bin:$PATH"` | | Just `make` | `export PATH="your-repository-clone/install/bin:$PATH"` |
| `make install` on Linux | `export PATH="/opt/voc/bin:$PATH"` | | `make install` on Unix | `export PATH="/usr/local/bin:$PATH"` |
| `make install` on BSD | `export PATH="/usr/local/share/voc/bin:$PATH"` | | `make install` on BSD | `export PATH="/usr/local/bin:$PATH"` |
| `make install` on Windows | See [**Windows installation**](/doc/Winstallation.md) | | `make install` on Windows | See [**Windows installation**](/doc/Winstallation.md) |
| `make install` on Termux | `export PATH="/data/data/com.termux/files/opt/voc/bin:$PATH"` | | `make install` on Termux | `export PATH="/data/data/com.termux/files/opt/voc/bin:$PATH"` |

View file

@ -82,7 +82,7 @@ This will create a subdirectory 'voc' which includes the following files and dir
``` ```
cd voc cd voc
make full make
``` ```
The makefile will: The makefile will:
@ -94,48 +94,71 @@ The makefile will:
link the final Oberon compiler. This compiler is then used for the remaining steps. link the final Oberon compiler. This compiler is then used for the remaining steps.
- Build the .sym file browser command `showdef`. - Build the .sym file browser command `showdef`.
- Build all the libraries in -O2 mode, and a subset in -OC mode. - Build all the libraries in -O2 mode, and a subset in -OC mode.
- Create an installation directory structure local to your copy of the repository. - Create an installation directory image local to your copy of the repository at `install/`.
- Run a set of confidence tests. - Run a set of confidence tests.
The makefile will use either gcc or clang, whichever is installed. If you have both installed you can specify which to use by running either `export CC=gcc` or `export CC=clang` before the `make full` command. The makefile will use either gcc or clang, whichever is installed. If you have both installed you can specify which to use with, for example, `CC=clang make`.
The build does not require root access and does not install anything outside
the repository. To select a compiler for one build, use for example:
```
CC=clang make
```
#### Installation directories: #### Installation directories:
If the makefile succeeds it will end with instructions on how to set your path variable so that the If the makefile succeeds it will end with instructions on how to set your path variable so that the
compiler (voc) is found. compiler (voc) in the local `install/bin` directory is found.
#### Installing to system directories #### Installing to system directories
You may optionally install to system directories such as /opt or /usr/local/share. You may optionally copy the local installation image to system directories such as /opt or /usr/local.
First be sure to have completed `make full` successfully. First be sure to have completed `make` successfully.
Then from a root prompt, or using sudo, run `make install` Then from a root prompt, or using sudo, run `make install`.
The installation will be made to: By default, the installation will be made to:
| System | Install dir | | Content | Install dir |
| ----------------------- | -------------------------------------- | | --------------------------- | --------------------------- |
| All types of Linux | /opt/voc | | Compiler and showdef | /usr/local/bin |
| BSD (including Darwin) | /usr/local/share/voc | | Oberon resources | /usr/local/share/voc |
| Runtime libraries | /usr/local/lib |
| Termux (android) | /data/data/com.termux/files/opt/voc | | Termux (android) | /data/data/com.termux/files/opt/voc |
As with `make full`, `make install` will exit with instructions on how to set Set `PREFIX`, `BINDIR`, `INSTALLDIR`, and `LIBDIR` to change these locations.
your PATH. `make install` only copies files. Use `make install-system` for a manual
installation that also updates the dynamic linker cache.
For package builds, set the final paths and use `DESTDIR` for staging:
```
make install PREFIX=/usr DESTDIR=/path/to/package-root
```
`DESTDIR` is only a staging prefix and is not included in the compiler's
runtime search paths. To install the historical self-contained layout instead,
use an explicit installation directory, for example:
```
make install INSTALLDIR=/opt/voc
```
#### Installation directory contentains: #### Installation directory contents:
| Directory | Content | | Directory | Content |
| --- | --- | | --- | --- |
| bin/ | Compiler and symbol file browser command binaries. | | `BINDIR` | Compiler and symbol file browser command binaries. |
| lib/ | Static and dynamic link libraries for all (-O2 and -OC) type models. | | `LIBDIR` | Static and dynamic link libraries for all type models. |
| 2/include/ | C compiler header files for -O2 modules | | `INSTALLDIR/2/include` | C headers for -O2 modules. |
| 2/sym/ | .sym files for -O2 modules | | `INSTALLDIR/2/sym` | Symbol files for -O2 modules. |
| C/include/ | C compiler header files for -OC modules | | `INSTALLDIR/C/include` | C headers for -OC modules. |
| C/sym/ | .sym files for -OC modules | | `INSTALLDIR/C/sym` | Symbol files for -OC modules. |

View file

@ -1,7 +1,7 @@
### Porting to a new platform ### Porting to a new platform
Porting to a new 32 or 64 bit platform is usually automatically handled Porting to a new 32 or 64 bit platform is usually automatically handled
by `make full`: by `make`:
- The makefile compiles `src/tools/make/configure.c` with the - The makefile compiles `src/tools/make/configure.c` with the
platform's default C compiler. platform's default C compiler.
@ -14,10 +14,10 @@ by `make full`:
which of 5 sets of pre-prepared C source files to build to create which of 5 sets of pre-prepared C source files to build to create
the bootstrap compiler. the bootstrap compiler.
On most systems this will be sufficient for `make full` to build On most systems this will be sufficient for `make` to build the compiler
and install the compiler and libraries. and libraries.
`make full` will terminate with a message such as: `make` will terminate with a message such as:
`--- Branch v2docs freebsd gcc LP64 confidence tests passed ---` `--- Branch v2docs freebsd gcc LP64 confidence tests passed ---`
@ -55,4 +55,3 @@ Unix-like systems including Linux, BSD, Android and cygwin
If you are porting to a system that does not provide a Unix style API, it will If you are porting to a system that does not provide a Unix style API, it will
be necessary to implement a new variant of Platform.Mod providing the same be necessary to implement a new variant of Platform.Mod providing the same
interface as Platformunix.Mod and Platform Windows.Mod. interface as Platformunix.Mod and Platform Windows.Mod.

View file

@ -52,12 +52,12 @@ This will create a subdirectory 'voc' including the following files and director
| makefile | Makefile for all BSD- and Linux- like environments. Includes tests. | | makefile | Makefile for all BSD- and Linux- like environments. Includes tests. |
| make.cmd | Makefile specifically for native Microsoft C builds. No tests. | | make.cmd | Makefile specifically for native Microsoft C builds. No tests. |
#### 3. Build and install the Oberon compiler and library #### 3. Build the Oberon compiler and library
``` ```
cd voc cd voc
[sudo] make full make
``` ```
The makefile will: The makefile will:
@ -69,9 +69,15 @@ The makefile will:
link the final Oberon compiler. This compiler is then used for the remaining steps. link the final Oberon compiler. This compiler is then used for the remaining steps.
- Build the .sym file browser command `showdef`. - Build the .sym file browser command `showdef`.
- Build all the libraries in -O2 mode, and a subset in -OC mode. - Build all the libraries in -O2 mode, and a subset in -OC mode.
- Install the compiler and libraries by copying them to an appropriate location for your OS. - Create an installation image in the local `install/` directory.
- Run a set of confidence tests. - Run a set of confidence tests.
The build does not require administrator access. To install the resulting
image, run `make install` separately. On Cygwin, the default Unix locations
are `/usr/local/bin`, `/usr/local/share/voc`, and `/usr/local/lib`; use
`PREFIX`, `BINDIR`, `INSTALLDIR`, and `LIBDIR` to change them. For a package
build, use `DESTDIR` as the staging prefix.
### Build using mingw under cygwin ### Build using mingw under cygwin
@ -84,13 +90,13 @@ The makefile will:
If it succeeds the makefile will end with instructions on how to set your path variable so that the If it succeeds the makefile will end with instructions on how to set your path variable so that the
compiler (voc) is found. compiler (voc) is found.
The installation will be found at: The local build image will be found at:
| Built with | Install dir | | Built with | Install dir |
| --------------- | -------------------------------------- | | --------------- | -------------------------------------- |
| cygwin | /opt/voc | | cygwin | `voc/install/` |
| cygwin + mingw | %PROGRAMFILES%/voc | | cygwin + mingw | `voc/install/` |
| MSC | %PROGRAMFILES%/voc | | MSC | `%PROGRAMFILES%/voc` after installation |
The installation directory contains: The installation directory contains:
@ -167,12 +173,12 @@ To use mingw, install the correct sized package and export CC= the compiler name
- For 32 bit cygwin - For 32 bit cygwin
- use setup-x86.exe to add the package mingw64-i686-gcc-core. - use setup-x86.exe to add the package mingw64-i686-gcc-core.
- run 'export CC=i686-w64-mingw32-gcc' then 'make full' - run 'export CC=i686-w64-mingw32-gcc' then 'make'
- For 64 bit cygwin - For 64 bit cygwin
- use setup-x86\_64.exe to add the package mingw64-x86\_64-gcc-core. - use setup-x86\_64.exe to add the package mingw64-x86\_64-gcc-core.
- run 'export CC=x86_64-w64-mingw32-gcc' then 'make full' - run 'export CC=x86_64-w64-mingw32-gcc' then 'make'
(*Note*: Don't be put off by the name 'mingw64' in the 32 bit package.) (*Note*: Don't be put off by the name 'mingw64' in the 32 bit package.)

View file

@ -40,7 +40,7 @@ for /F %%d in ('cd');do set ROOTDIR=%%d
:: Process target parameter :: Process target parameter
if "%1" equ "" ( if "%1" equ "" (
call :usage call :all
) else ( ) else (
call :%1 call :%1
) )
@ -54,7 +54,7 @@ goto :eof
@echo. @echo.
@echo Usage: @echo Usage:
@echo. @echo.
@echo. make full - Make compiler to 'install' subdirectory @echo. make - Make compiler to 'install' subdirectory
@echo. make install - Install 'install' subdir to OS. Requires administrator privileges @echo. make install - Install 'install' subdir to OS. Requires administrator privileges
@echo. @echo.
@echo. make clean - Remove made files @echo. make clean - Remove made files
@ -66,7 +66,7 @@ goto :eof
:full :all
call :clean || exit /b call :clean || exit /b
echo. echo.
echo.--- Compiler build started --- echo.--- Compiler build started ---

View file

@ -3,13 +3,25 @@
# Makes sure configuration parameters are up to date and then hands off # Makes sure configuration parameters are up to date and then hands off
# to src/tools/make/oberon.mk. # to src/tools/make/oberon.mk.
# Installation paths. The default is a conventional local Unix installation.
# Set INSTALLDIR explicitly to retain the historical self-contained layout,
# for example: INSTALLDIR=/opt/voc make.
PREFIX ?=
DESTDIR ?=
INSTALLDIR ?=
BINDIR ?=
LIBDIR ?=
# The configurator applies defaults and resolves PREFIX versus explicit paths.
CONFIG_PATHS = PREFIX='$(PREFIX)' INSTALLDIR='$(INSTALLDIR)' BINDIR='$(BINDIR)' LIBDIR='$(LIBDIR)'
# To build and install the Oberon compiler and library on a Unix based # To build and install the Oberon compiler and library on a Unix based
# OS (Linux/Mac/BSD etc.) or on cygwin, run: # OS (Linux/Mac/BSD etc.) or on cygwin, run:
# #
# make full # make
# #
# To override your OSs default C compiler, first run # To override your OSs default C compiler, first run
# #
@ -67,12 +79,15 @@
# Default make target - explain usage # Default target: complete build and confidence tests.
all:
# Display build and installation targets
usage: usage:
@echo "" @echo ""
@echo Usage: @echo Usage:
@echo "" @echo ""
@echo " make full" @echo " make"
@echo "" @echo ""
@echo " Does a full, clean build, and runs confidence tests." @echo " Does a full, clean build, and runs confidence tests."
@echo " An installation directory image is left in the local repository install directory." @echo " An installation directory image is left in the local repository install directory."
@ -84,7 +99,8 @@ usage:
@echo " make library - Build all library files and make library" @echo " make library - Build all library files and make library"
@echo " make O2library - Build all library files with Oberon-2 type sizes" @echo " make O2library - Build all library files with Oberon-2 type sizes"
@echo " make OClibrary - Build all library files with Component Pascal type sizes" @echo " make OClibrary - Build all library files with Component Pascal type sizes"
@echo " make install - Install built compiler and library in /opt or C:\\PROGRAM FILES*" @echo " make install - Install built compiler and library"
@echo " make install-system - Install and update the dynamic linker cache"
@echo " (Needs root access)" @echo " (Needs root access)"
@echo "" @echo ""
@echo "Targets for (re)creating and reverting bootstrap C sources:" @echo "Targets for (re)creating and reverting bootstrap C sources:"
@ -102,18 +118,16 @@ FORCE:
configuration: FORCE configuration: FORCE
@$(CC) -I src/runtime -o a.o src/tools/make/configure.c @$(CC) -I src/runtime -o a.o src/tools/make/configure.c
@./a.o @$(CONFIG_PATHS) ./a.o
@rm a.o @rm a.o
@echo BRANCH=$$(git rev-parse --abbrev-ref HEAD)>>Configuration.Make @branch=$$(git -c safe.directory="$$(pwd)" rev-parse --abbrev-ref HEAD 2>/dev/null || printf unknown); echo BRANCH=$$branch>>Configuration.Make; echo Branch: $$branch.
@echo Branch: $$(git rev-parse --abbrev-ref HEAD).
bootstrapconfiguration: FORCE bootstrapconfiguration: FORCE
@$(CC) -I src/runtime -o a.o src/tools/make/configure.c @$(CC) -I src/runtime -o a.o src/tools/make/configure.c
@./a.o bootstrap @$(CONFIG_PATHS) ./a.o bootstrap
@rm a.o @rm a.o
@echo BRANCH=$$(git rev-parse --abbrev-ref HEAD)>>Configuration.Make @branch=$$(git -c safe.directory="$$(pwd)" rev-parse --abbrev-ref HEAD 2>/dev/null || printf unknown); echo BRANCH=$$branch>>Configuration.Make; echo Branch: $$branch.
@echo Branch: $$(git rev-parse --abbrev-ref HEAD).
@ -138,8 +152,9 @@ clean: configuration
# full: Full build of compiler and libarary. # all: Complete clean build of compiler and library.
full: configuration .PHONY: all
all: configuration
@make -f src/tools/make/oberon.mk -s clean @make -f src/tools/make/oberon.mk -s clean
# Make bootstrap compiler from source suitable for current data model # Make bootstrap compiler from source suitable for current data model
@printf "\n\n--- Compiler build started ---\n\n" @printf "\n\n--- Compiler build started ---\n\n"
@ -234,9 +249,15 @@ makeinstalldir:
install: configuration install: configuration
@make -f src/tools/make/oberon.mk -s install @make -f src/tools/make/oberon.mk -s install
install-system: configuration
@make -f src/tools/make/oberon.mk -s install-system
uninstall: configuration uninstall: configuration
@make -f src/tools/make/oberon.mk -s uninstall @make -f src/tools/make/oberon.mk -s uninstall
uninstall-system: configuration
@make -f src/tools/make/oberon.mk -s uninstall-system
@ -315,7 +336,7 @@ auto: configuration
# autoonce: What auto does each time a build is triggered. # autoonce: What auto does each time a build is triggered.
autoonce: configuration autoonce: configuration
git pull git pull
@if make -s full; then echo \*\* Succeeded \*\*; else echo \*\* Failed \*\*;fi @if make -s; then echo \*\* Succeeded \*\*; else echo \*\* Failed \*\*;fi

View file

@ -122,6 +122,7 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
S: INTEGER; S: INTEGER;
InstallDir*: ARRAY 1024 OF CHAR; InstallDir*: ARRAY 1024 OF CHAR;
LibraryDir*: ARRAY 1024 OF CHAR;
ResourceDir*: ARRAY 1024 OF CHAR; ResourceDir*: ARRAY 1024 OF CHAR;
@ -832,17 +833,17 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
PROCEDURE IsProbablyInstallDir(s: ARRAY OF CHAR): BOOLEAN; PROCEDURE IsProbablyInstallDir(s: ARRAY OF CHAR): BOOLEAN;
VAR testpath: ARRAY 4096 OF CHAR; identity: Platform.FileIdentity; VAR testpath: ARRAY 4096 OF CHAR; identity: Platform.FileIdentity;
BEGIN BEGIN
COPY(InstallDir, testpath); COPY(s, testpath);
Strings.Append("/lib/lib", testpath); Strings.Append("/lib/lib", testpath);
Strings.Append(Configuration.name, testpath); Strings.Append(Configuration.name, testpath);
Strings.Append("-O2.a", testpath); Strings.Append("-O2.a", testpath);
IF Platform.IdentifyByName(testpath, identity) # 0 THEN RETURN FALSE END; IF Platform.IdentifyByName(testpath, identity) # 0 THEN RETURN FALSE END;
COPY(InstallDir, testpath); COPY(s, testpath);
Strings.Append("/2/include/Oberon.h", testpath); Strings.Append("/2/include/Oberon.h", testpath);
IF Platform.IdentifyByName(testpath, identity) # 0 THEN RETURN FALSE END; IF Platform.IdentifyByName(testpath, identity) # 0 THEN RETURN FALSE END;
COPY(InstallDir, testpath); COPY(s, testpath);
Strings.Append("/2/sym/Files.sym", testpath); Strings.Append("/2/sym/Files.sym", testpath);
IF Platform.IdentifyByName(testpath, identity) # 0 THEN RETURN FALSE END; IF Platform.IdentifyByName(testpath, identity) # 0 THEN RETURN FALSE END;
@ -850,14 +851,28 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
END IsProbablyInstallDir; END IsProbablyInstallDir;
PROCEDURE FindInstallDir; PROCEDURE FindInstallDir;
VAR i: INTEGER; VAR i: INTEGER; env: ARRAY 1024 OF CHAR;
BEGIN BEGIN
(* Explicit overrides are useful for testing a staged installation. *)
Platform.GetEnv("VOCROOT", env);
IF env[0] # 0X THEN
COPY(env, InstallDir);
Platform.GetEnv("VOCLIBDIR", env);
IF env[0] # 0X THEN COPY(env, LibraryDir)
ELSE COPY(Configuration.libdir, LibraryDir)
END;
RETURN
END;
(* First try location of binary (with <name>.d appended) *) (* First try location of binary (with <name>.d appended) *)
COPY(Modules.BinaryDir, InstallDir); COPY(Modules.BinaryDir, InstallDir);
Strings.Append("/", InstallDir); Strings.Append("/", InstallDir);
Strings.Append(Configuration.name, InstallDir); Strings.Append(Configuration.name, InstallDir);
Strings.Append(".d", InstallDir); Strings.Append(".d", InstallDir);
IF IsProbablyInstallDir(InstallDir) THEN RETURN END; IF IsProbablyInstallDir(InstallDir) THEN
COPY(InstallDir, LibraryDir); Strings.Append("/lib", LibraryDir);
RETURN
END;
(* Now test whether binary is in bin directory under install dir. *) (* Now test whether binary is in bin directory under install dir. *)
COPY(Modules.BinaryDir, InstallDir); COPY(Modules.BinaryDir, InstallDir);
@ -865,11 +880,17 @@ MODULE OPM; (* RC 6.3.89 / 28.6.89, J.Templ 10.7.89 / 22.7.96 *)
WHILE (i > 0) & (InstallDir[i-1] # '/') DO DEC(i) END; WHILE (i > 0) & (InstallDir[i-1] # '/') DO DEC(i) END;
IF (i > 0) & (InstallDir[i-1] = '/') THEN IF (i > 0) & (InstallDir[i-1] = '/') THEN
InstallDir[i-1] := 0X; InstallDir[i-1] := 0X;
IF IsProbablyInstallDir(InstallDir) THEN RETURN END IF IsProbablyInstallDir(InstallDir) THEN
COPY(InstallDir, LibraryDir); Strings.Append("/lib", LibraryDir);
RETURN
END
END; END;
(* Give up! Use install directory from configuration. *) (* Give up! Use install directory from configuration. *)
COPY(Configuration.installdir, InstallDir) COPY(Configuration.installdir, InstallDir);
COPY(Configuration.libdir, LibraryDir);
Platform.GetEnv("VOCLIBDIR", env);
IF env[0] # 0X THEN COPY(env, LibraryDir) END
END FindInstallDir; END FindInstallDir;

View file

@ -79,8 +79,8 @@ PROCEDURE LinkMain*(VAR moduleName: ARRAY OF CHAR; statically: BOOLEAN; addition
Strings.Append(".c ", cmd); Strings.Append(".c ", cmd);
IF statically THEN IF statically THEN
IF Configuration.os = "darwin" THEN IF Configuration.os = "darwin" THEN
Strings.Append(OPM.InstallDir, cmd); Strings.Append(OPM.LibraryDir, cmd);
Strings.Append('/lib/lib', cmd); Strings.Append('/lib', cmd);
Strings.Append(Configuration.name, cmd); Strings.Append(Configuration.name, cmd);
Strings.Append('-O', cmd); Strings.Append('-O', cmd);
Strings.Append(OPM.Model, cmd); Strings.Append(OPM.Model, cmd);
@ -93,8 +93,8 @@ PROCEDURE LinkMain*(VAR moduleName: ARRAY OF CHAR; statically: BOOLEAN; addition
Strings.Append(moduleName, cmd); Strings.Append(moduleName, cmd);
IF (~statically) OR ~(Configuration.os = "darwin") THEN IF (~statically) OR ~(Configuration.os = "darwin") THEN
Strings.Append(Configuration.linkflags, cmd); Strings.Append(Configuration.linkflags, cmd);
Strings.Append(OPM.InstallDir, cmd); Strings.Append(OPM.LibraryDir, cmd);
Strings.Append('/lib"', cmd); Strings.Append('"', cmd);
Strings.Append(Configuration.libspec, cmd); Strings.Append(Configuration.libspec, cmd);
Strings.Append('-O', cmd); Strings.Append('-O', cmd);
Strings.Append(OPM.Model, cmd); Strings.Append(OPM.Model, cmd);
@ -109,8 +109,8 @@ PROCEDURE LinkMain*(VAR moduleName: ARRAY OF CHAR; statically: BOOLEAN; addition
Strings.Append('-O', cmd); Strings.Append('-O', cmd);
Strings.Append(OPM.Model, cmd); Strings.Append(OPM.Model, cmd);
Strings.Append('.dylib "', cmd); Strings.Append('.dylib "', cmd);
Strings.Append(OPM.InstallDir, cmd); Strings.Append(OPM.LibraryDir, cmd);
Strings.Append('/lib/lib', cmd); Strings.Append('/lib', cmd);
Strings.Append(Configuration.name, cmd); Strings.Append(Configuration.name, cmd);
Strings.Append('-O', cmd); Strings.Append('-O', cmd);
Strings.Append(OPM.Model, cmd); Strings.Append(OPM.Model, cmd);

View file

@ -310,7 +310,7 @@ PROCEDURE SetDefaultPath;
VAR path: ARRAY 256 OF CHAR; VAR path: ARRAY 256 OF CHAR;
BEGIN BEGIN
path := ".;"; path := ".;";
Strings.Append(Configuration.installdir, path); Strings.Append(OPM.InstallDir, path);
Strings.Append("/2/sym", path); Strings.Append("/2/sym", path);
Files.SetSearchPath(path) Files.SetSearchPath(path)
END SetDefaultPath; END SetDefaultPath;

View file

@ -40,6 +40,8 @@ void assert(int truth, char *complaint) {if (!truth) fail(complaint);}
char builddate[256]; char builddate[256];
char installdir[256]; char installdir[256];
char bindir[256];
char libdir[256];
char versionstring[256]; char versionstring[256];
char osrelease[1024]; char osrelease[1024];
char cwd[1024]; char cwd[1024];
@ -173,8 +175,11 @@ void determineInstallDirectory() {
installdir[0] = 0; installdir[0] = 0;
} else { } else {
char *env = getenv("INSTALLDIR"); char *env = getenv("INSTALLDIR");
if (env) { char *prefix = getenv("PREFIX");
if (env && env[0]) {
strncpy(installdir, env, sizeof(installdir)); strncpy(installdir, env, sizeof(installdir));
} else if (prefix && prefix[0]) {
snprintf(installdir, sizeof(installdir), "%s/share/%s", prefix, oname);
} else { } else {
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__)
if (sizeof (void*) == 8) { if (sizeof (void*) == 8) {
@ -191,7 +196,7 @@ void determineInstallDirectory() {
} else if (termux) { } else if (termux) {
snprintf(installdir, sizeof(installdir), "/data/data/com.termux/files/opt/%s", oname); snprintf(installdir, sizeof(installdir), "/data/data/com.termux/files/opt/%s", oname);
} else { } else {
snprintf(installdir, sizeof(installdir), "/opt/%s", oname); snprintf(installdir, sizeof(installdir), "/usr/local/share/%s", oname);
} }
#endif #endif
} }
@ -200,6 +205,39 @@ void determineInstallDirectory() {
void determineInstallationPaths() {
char *env;
char *install;
char *prefix = getenv("PREFIX");
int explicitInstallDir;
install = getenv("INSTALLDIR");
explicitInstallDir = install && install[0];
env = getenv("BINDIR");
if (env && env[0]) {
snprintf(bindir, sizeof(bindir), "%s", env);
} else if (prefix && prefix[0] && !explicitInstallDir) {
snprintf(bindir, sizeof(bindir), "%s/bin", prefix);
} else if (explicitInstallDir || termux) {
snprintf(bindir, sizeof(bindir), "%s/bin", installdir);
} else {
snprintf(bindir, sizeof(bindir), "/usr/local/bin");
}
env = getenv("LIBDIR");
if (env && env[0]) {
snprintf(libdir, sizeof(libdir), "%s", env);
} else if (prefix && prefix[0] && !explicitInstallDir) {
snprintf(libdir, sizeof(libdir), "%s/lib", prefix);
} else if (explicitInstallDir || termux) {
snprintf(libdir, sizeof(libdir), "%s/lib", installdir);
} else {
snprintf(libdir, sizeof(libdir), "/usr/local/lib");
}
}
void determineBuildDate() { void determineBuildDate() {
time_t t = time(0); time_t t = time(0);
@ -380,6 +418,8 @@ void writeMakeParameters() {
fprintf(fd, "ADRSIZE=%d\n", addressSize); fprintf(fd, "ADRSIZE=%d\n", addressSize);
fprintf(fd, "ALIGNMENT=%d\n", alignment); fprintf(fd, "ALIGNMENT=%d\n", alignment);
fprintf(fd, "INSTALLDIR=%s\n", installdir); fprintf(fd, "INSTALLDIR=%s\n", installdir);
fprintf(fd, "BINDIR=%s\n", bindir);
fprintf(fd, "LIBDIR=%s\n", libdir);
fprintf(fd, "PLATFORM=%s\n", platform); fprintf(fd, "PLATFORM=%s\n", platform);
fprintf(fd, "BINEXT=%s\n", binext); fprintf(fd, "BINEXT=%s\n", binext);
fprintf(fd, "DYNEXT=%s\n", dynext); fprintf(fd, "DYNEXT=%s\n", dynext);
@ -407,6 +447,7 @@ void writeConfigurationMod() {
fprintf(fd, " compiler* = '%s';\n", compiler); fprintf(fd, " compiler* = '%s';\n", compiler);
fprintf(fd, " compile* = '%s';\n", cc); fprintf(fd, " compile* = '%s';\n", cc);
fprintf(fd, " installdir* = '%s';\n", installdir); fprintf(fd, " installdir* = '%s';\n", installdir);
fprintf(fd, " libdir* = '%s';\n", libdir);
fprintf(fd, " staticLink* = '%s';\n", staticlink); fprintf(fd, " staticLink* = '%s';\n", staticlink);
fprintf(fd, "VAR\n"); fprintf(fd, "VAR\n");
fprintf(fd, " versionLong-: ARRAY %d OF CHAR;\n", (int)strnlen(versionstring, 100)+1); fprintf(fd, " versionLong-: ARRAY %d OF CHAR;\n", (int)strnlen(versionstring, 100)+1);
@ -447,6 +488,7 @@ int main(int argc, char *argv[])
determineCDataModel(); determineCDataModel();
determineBuildDate(); determineBuildDate();
determineInstallDirectory(); determineInstallDirectory();
determineInstallationPaths();
testSystemDotH(); testSystemDotH();

View file

@ -16,6 +16,12 @@ ROOTDIR = $(CURDIR)$(.CURDIR)
# *every* build by the makefile in the enlistment root. # *every* build by the makefile in the enlistment root.
include ./Configuration.Make include ./Configuration.Make
# Defaults for configuration files generated by older versions.
BINDIR ?= $(INSTALLDIR)/bin
LIBDIR ?= $(INSTALLDIR)/lib
.PHONY: install uninstall install-system uninstall-system
FLAVOUR = $(OS).$(DATAMODEL).$(COMPILER) FLAVOUR = $(OS).$(DATAMODEL).$(COMPILER)
BUILDDIR = build/$(FLAVOUR) BUILDDIR = build/$(FLAVOUR)
OBECOMP = $(ONAME)$(BINEXT) OBECOMP = $(ONAME)$(BINEXT)
@ -180,30 +186,39 @@ instructions: FORCE
FORCE: FORCE:
# installable: Check for access to the installation directory # uninstall: Remove files installed by this makefile without changing the
installable: # host dynamic linker configuration.
@rm -rf "S(INSTALLDIR)/test-access-qqq" uninstall:
@if ! mkdir -p "$(INSTALLDIR)/test-access-qqq";then printf '\n\n Cannot write to install directory.\n Please use sudo or run as root/administrator.\n\n'; exit 1;fi @rm -f "$(DESTDIR)$(BINDIR)/$(OBECOMP)" "$(DESTDIR)$(BINDIR)/showdef$(BINEXT)"
@rm -rf "S(INSTALLDIR)/test-access-qqq" @rm -rf "$(DESTDIR)$(INSTALLDIR)/2" "$(DESTDIR)$(INSTALLDIR)/C"
@rm -f "$(DESTDIR)$(LIBDIR)/lib$(ONAME)-O2.a" "$(DESTDIR)$(LIBDIR)/lib$(ONAME)-O2$(DYNEXT)"
@rm -f "$(DESTDIR)$(LIBDIR)/lib$(ONAME)-OC.a" "$(DESTDIR)$(LIBDIR)/lib$(ONAME)-OC$(DYNEXT)"
uninstall: installable # install: Use only after a successful full build. DESTDIR is a staging
@printf '\nUninstalling from \"$(INSTALLDIR)\"\n' # prefix and is deliberately not included in the generated compiler paths.
@[ -d "$(INSTALLDIR)/lib" ] && sh src/tools/make/addlibrary.sh uninstall "$(INSTALLDIR)/lib" $(ONAME) || echo nolibdir, skipping install:
rm -rf "$(INSTALLDIR)" @printf '\nInstalling compiler to "$(DESTDIR)$(BINDIR)"\n'
@mkdir -p "$(DESTDIR)$(BINDIR)"
@cp "$(ROOTDIR)/install/bin/$(OBECOMP)" "$(DESTDIR)$(BINDIR)/$(OBECOMP)"
@-cp "$(ROOTDIR)/install/bin/showdef$(BINEXT)" "$(DESTDIR)$(BINDIR)"
@mkdir -p "$(DESTDIR)$(INSTALLDIR)/2" "$(DESTDIR)$(INSTALLDIR)/C"
@cp -rf "$(ROOTDIR)/install/2/." "$(DESTDIR)$(INSTALLDIR)/2/"
@cp -rf "$(ROOTDIR)/install/C/." "$(DESTDIR)$(INSTALLDIR)/C/"
@mkdir -p "$(DESTDIR)$(LIBDIR)"
@cp "$(ROOTDIR)/install/lib/"* "$(DESTDIR)$(LIBDIR)/"
@printf '\nOberon compiler installed.\n'
# install: Use only after a successful full build. Installs the compiler # install-system: Install and update the dynamic linker cache for a manual
# and libraries in /opt/$(ONAME). # installation. Package managers should use install with DESTDIR instead.
# May require root access. install-system: install
install: uninstall @sh src/tools/make/addlibrary.sh install "$(LIBDIR)" $(ONAME)
@printf '\nInstalling into \"$(INSTALLDIR)\"\n'
@rm -rf "$(INSTALLDIR)" uninstall-system: uninstall
@cp -rf "$(ROOTDIR)/install/" "$(INSTALLDIR)" @sh src/tools/make/addlibrary.sh uninstall "$(LIBDIR)" $(ONAME)
@sh src/tools/make/addlibrary.sh install "$(INSTALLDIR)/lib" $(ONAME)
@printf '\nOberon compiler installed to $(INSTALLDIR)\n'
@printf '\nNow add $(INSTALLDIR)/bin to your path, for example with the command:\n'
@printf 'export PATH=\"$(INSTALLDIR)/bin:$$PATH\"\n'
@printf '\n' @printf '\n'