You can do this with dub by setting target , but I will show it in a different way.
Using MakefileForD ,
Why?
Because dub sets lib and bin to ~/.dub . And it is impossible to install in a shared directory. As an example, the Linux File System Hierarchy Standard reports that binaries should go to /usr/bin .
You cannot respect this standard using dub.
Generic lib with Makefile,
Create project
myproject └── src └── myproject
Set Makefile_lib to the root directory and rename it to Makefile.
Install command.make in the root directory
You have
myproject ├── command.make ├── Makefile └── src └── myproject └── main.d
Set source directory
In the 5th line from the Makefile
export REPO_SRC_DIR = src
Build
all you have to do is:
make DC=dmd shared-lib
DC accepts dmd ldc and gdc compiler
Install
make install
setting up a custom installation directory
make install PREFIX=/usr LIB_DIR=/usr/lib64
For binaries that are the same, but need to do Makefile_lib instead, you need to do Makefile_exe
source share