Skip to content

Commit

Permalink
Add STATICLINK config option to prefer static linking of tools
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Dec 27, 2024
1 parent 58593d6 commit fc90be1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ else
$(info WARNING! Doxygen is not available. Will skip 'dox' target)
endif

export

# Build for distribution
.PHONY: distro
distro: shared tools $(DOC_TARGETS)
Expand Down Expand Up @@ -66,9 +64,15 @@ infer: clean
infer run -- make shared

.PHONY: tools
tools: SRC := tools
tools:
make -f tools.mk all

# Link tools against the static or shared libs
ifeq ($(STATICLINK),1)
tools: static
else
tools: shared
make -f tools.mk
endif

# Remove intermediates
.PHONY: clean
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ prior to invoking `make`. The following build variables can be configured:
system (e.g. under `/usr`) set `REDISX` to where the distribution can be found. The build will expect to find
`redisx.h` under `$(REDISX)/include` and `libredisx.so` / `libredisx.a` under `$(REDISX)/lib` or else in the
default `LD_LIBRARY_PATH`.

- `STATICLINK`: To prefer linking tools statically against `libsmax.a`. (It may still link dynamically if
`libsmax.so` is also available.

After configuring, you can simply run `make`, which will build the `shared` (`lib/libsmax.so[.1]`) and `static`
(`lib/libsmax.a`) libraries, local HTML documentation (provided `doxygen` is available), and performs static
Expand Down
8 changes: 5 additions & 3 deletions tools.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
SRC := tools

include config.mk

LDFLAGS += -L$(LIB) -lsmax -lpopt
LDFLAGS := -lm -lpopt -L$(LIB) -lsmax $(LDFLAGS)
LD_LIBRARY_PATH := $(LIB):$(LD_LIBRARY_PATH)

include build.mk

# Top level make targets...
all: $(BIN)/smaxValue $(BIN)/smaxWrite

include build.mk

0 comments on commit fc90be1

Please sign in to comment.