summaryrefslogtreecommitdiff
path: root/exports/common.mk
blob: 00e1c63b70eb0b5ecb61ee46f0943b6ea20125f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Prevent executing `go env ...` multiple times for the same property
# export is needed for this and also to pass the values on to the Go compiler
ifndef GOOS
export GOOS := $(shell go env GOHOSTOS)
endif
ifndef GOARCH
export GOARCH := $(shell go env GOHOSTARCH)
endif

ifeq (windows,$(GOOS))
LIB_PREFIX ?=
LIB_SUFFIX ?= .dll
else ifeq (darwin,$(GOOS))
LIB_PREFIX ?= lib
LIB_SUFFIX ?= .dylib
else
LIB_PREFIX ?= lib
LIB_SUFFIX ?= .so
endif

# Current version
VERSION = 0.99.0

# Library name without prefixes/suffixes
LIB_NAME ?= eduvpn_common
LIB_NAME_VERSION ?= $(LIB_NAME)-$(VERSION)
# Library file name
LIB_FILE ?= $(LIB_PREFIX)$(LIB_NAME_VERSION)$(LIB_SUFFIX)

# Get relative exports/ directory when included from a wrapper, without trailing slash
override EXPORTS_PATH = $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))

EXPORTS_LIB_PATH ?= $(EXPORTS_PATH)/lib
EXPORTS_LIB_SUBFOLDER_PATH ?= $(EXPORTS_LIB_PATH)/$(GOOS)/$(GOARCH)

# Add library to dynamic linker path for running tests
ifeq (Windows_NT,$(OS))
export PATH := $(abspath $(EXPORTS_LIB_SUBFOLDER_PATH)):$(PATH)
else
export LD_LIBRARY_PATH := $(abspath $(EXPORTS_LIB_SUBFOLDER_PATH)):$(LD_LIBRARY_PATH)
export DYLD_FALLBACK_LIBRARY_PATH := $(abspath $(EXPORTS_LIB_SUBFOLDER_PATH)):$(DYLD_FALLBACK_LIBRARY_PATH)
endif

.try-build-lib:
ifneq ($(wildcard $(EXPORTS_PATH)/Makefile),)
	$(MAKE) -C $(EXPORTS_PATH)
else
$(info Skipping building library as exports/Makefile was not found)
endif