Skip to content

Commit

Permalink
Configure with --enable-shared by default (#881)
Browse files Browse the repository at this point in the history
This is the sane thing to do for a developer's laptop or workstation.

Closes #876
  • Loading branch information
vyzo authored Sep 20, 2023
1 parent 7e51509 commit 92dd79a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
fail-fast: false # if one fails, do not cancel the other
matrix:
gambit-version: ['', '--with-gambit=master']
shared-mode: ['', '--enable-shared']
shared-mode: ['', '--disable-shared']
steps:
- uses: actions/checkout@v3
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Installation from source is straightforward:
```shell
$ git clone [email protected]:mighty-gerbils/gerbil.git
$ cd gerbil
$ ./configure --enable-shared # recommeded to use shared libraries for a local install
$ ./configure
$ make
$ sudo make install
```
Expand Down
15 changes: 12 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ Options understood and processed by Gerbil:
defaults to ${default_gambit_tag}
--enable-march=ARCH specify the machine architecture; it can be empty.
defaults to native
--enable-shared use shared libraries for libgerbil and libgambit
--enable-shared[=no] do (not) use shared libraries for libgerbil and libgambit
--disable-shared default is to enable shared libraries
Gerbil Standard Library features:
--enable-deprecated Enable building of deprecated packages
Expand Down Expand Up @@ -77,8 +78,10 @@ case $(uname) in
;;
esac

gerbil_shared=t
gambit_tag="${default_gambit_tag}"
gambit_config="${default_gambit_config}"
gambit_shared="--enable-shared"

while [ $# -gt 0 ]; do
case "$1" in
Expand All @@ -104,7 +107,13 @@ while [ $# -gt 0 ]; do

--enable-shared)
gerbil_shared=t
gambit_config="${gambit_config} $1"
gambit_shared="--enable-shared"
shift
;;

--disable-shared|--enable-shared=no)
gerbil_shared=f
unset gambit_shared
shift
;;

Expand Down Expand Up @@ -232,7 +241,7 @@ git submodule update --force || die

(cd src/gambit && git fetch origin && git checkout "${gambit_tag}" && touch configure config.status) || die

gambit_config="--prefix=${gerbil_prefix} --enable-march=${gambit_march} ${gambit_config}"
gambit_config="--prefix=${gerbil_prefix} --enable-march=${gambit_march} ${gambit_shared} ${gambit_config}"
(export LDFLAGS="$LDFLAGS"; export CFLAGS="$CFLAGS"; cd src/gambit && ./configure $gambit_config ) || die

rm -f build-env.sh
Expand Down
6 changes: 3 additions & 3 deletions doc/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ $ ./configure && make && sudo make install
This will install Gerbil in `/opt/gerbil`; you will need to add
`/opt/gerbil/bin` to your PATH environment variable.

It is recommended that you enable shared libraries if this is an installation for your development workstation or laptop:
By default, the configuration will enable shared libraries, which is the sane thing to do for a development workstation or laptop. On the other hand, if you want to build statically linked binaries, you can disable shared libraries by configuring like this:
```bash
$ ./configure --enable-shared && make && sudo make install
$ ./configure --disable-shared
```

On the other hand, if you need to override some configuration defaults,
If you need to override some configuration defaults,
you will have to use the following (with your own set of configuration options):
```bash
$ ./configure --prefix=/path/to/which/to/install/gerbil \
Expand Down
8 changes: 4 additions & 4 deletions doc/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $ sudo apt install libssl-dev zlib1g-dev libsqlite3-dev

I usually configure Gerbil for devlopment with the following incantation:
```shell
./configure --prefix=/usr/local/gerbil --enable-shared
./configure --prefix=/usr/local/gerbil
```

This will install Gerbil in `/usr/local/gerbil`; you should add
Expand All @@ -47,7 +47,7 @@ Do not use `--enable-poll` if you are on MacOS, as console polling is broken.
:::

If you intend to build static executables for servers, then you should
remove `--enable-shared` to configure the system to use static
add `--disable-shared` to configure the system to use static
`libgerbil.a` and `libgambit.a` libraries.

Also note, that it is _strongly_ recommended to use `gcc` as your
Expand Down Expand Up @@ -360,8 +360,8 @@ If you want your program to be statically linked to dependent
libraries, so that you can ship it as a _release_, you can specify the
`--release` flag, which may be combined with `--optimized`.
Note that for release builds, your system must be configured without
`--enable-shared` and have all foreign dependencies available as
Note that for release builds, your system must be configured with
`--disable-shared` and have all foreign dependencies available as
static library archives. Of course, you can do that by maintaining a
separate gerbil build in your system for releases, but the recommended
way to build release binaries is by using [docker](docker.md).
Expand Down
6 changes: 3 additions & 3 deletions doc/guide/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ hello, world
The difference between the 3 executable compilation modes can be summarized as follows:
- By default, executable binaries are compiled with separate module compilation and link
to the precompiled gerbil library (`libgerbil`).
If the system was configured with `--enable-shared`, then this
If the system was configured with `--enable-shared` (the default), then this
will be a shared library; otherwise it will be a static library archive.
Note that the executable may have some additionl dynamic library
dependencies from stdlib foreign code, and also links to `libgambit` which will be
Expand All @@ -922,8 +922,8 @@ The difference between the 3 executable compilation modes can be summarized as f
#### Fully Static Binaries

It is also possible to build _fully static_ binaries, provided that
your system supports it and you haven't configured Gerbil with
`--enable-shared`. You can do this simply by passing the `-static`
your system supports it and you have configured Gerbil with
`--enable-shared=no`. You can do this simply by passing the `-static`
option to `gxc` or using the `static-exe:` and `optimized-static-exe:`
specs in your build script.

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ARG configure_args
ENV GERBIL_GCC=g++
RUN cd /opt && git clone https://github.com/vyzo/gerbil gerbil-src
RUN cd /opt/gerbil-src && git fetch -a && git fetch --tags && git checkout ${gerbil_version} \
&& eval ./configure --prefix=/opt/gerbil ${configure_args}
&& eval ./configure --prefix=/opt/gerbil --enable-shared=no ${configure_args}

RUN cd /opt/gerbil-src && make -j ${GERBIL_BUILD_CORES} && make install

Expand Down

0 comments on commit 92dd79a

Please sign in to comment.