-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile-variables
78 lines (70 loc) · 3.33 KB
/
Makefile-variables
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
PREFIX ?= /usr/local
MACOS_VER_NUM ?= $(shell vtool -show-build $(shell pkg-config --variable=libdir getargv)/libgetargv.dylib | awk '/minos/{print $$2}')
MACOS_VER_MAJOR := $(shell echo $(MACOS_VER_NUM) | cut -f1 -d.)
MACOS_VER_MINOR := $(shell echo $(MACOS_VER_NUM) | cut -f2 -d.)
MACOS_LT_10_11 := $(shell [ $(MACOS_VER_MAJOR) -eq 10 -a $(MACOS_VER_MINOR) -lt 11 ] && echo true)
MACOS_LT_10_13 := $(shell [ $(MACOS_VER_MAJOR) -eq 10 -a $(MACOS_VER_MINOR) -lt 13 ] && echo true)
MACOS_LT_11 := $(shell [ $(MACOS_VER_MAJOR) -eq 10 -a $(MACOS_VER_MINOR) -lt 15 ] || [ $(MACOS_VER_MAJOR) -lt 11 ] && echo true)
MACOS_LT_12 := $(shell [ $(MACOS_VER_MAJOR) -eq 10 -a $(MACOS_VER_MINOR) -lt 16 ] || [ $(MACOS_VER_MAJOR) -lt 12 ] && echo true)
export MACOSX_DEPLOYMENT_TARGET := $(MACOS_VER_MAJOR).$(MACOS_VER_MINOR)
# When changing version, also change: getargv++.pc, doxygen.conf, and README.md
VERSION=0.13
#
COMPAT_VERSION := $(shell echo $(VERSION) | cut -f1 -d.).0
ARCH := $(shell uname -m)
CODESIGN_PREFIX := cam.narzt.
KEYCHAIN := ~/Library/Keychains/login.keychain-db
CERT_IDENTITY ?= $(shell security find-identity -v -p codesigning | sed -Ee 's/.*"([^"]+)".*/\1/g' | grep -Fve ' valid identit' -e ' CA')
SRC_DIR := src
INCLUDE_DIR := include
OBJ_DIR := obj
LIB_DIR := lib
PKG_DIR := pkg
FAKE_ROOT := fakeroot
CXX := clang++
CPPFLAGS := -MMD -MP
COMPILER_VERSION := $(shell $(CXX) --version | grep version | grep -o -m 1 "[0-9]\+\.[0-9]\+\.*[0-9]*" | head -n 1)
COMPILER_VERSION_NUMBER := $(shell echo $(COMPILER_VERSION) | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
CLANG_13_OR_MORE := $(shell expr $(COMPILER_VERSION_NUMBER) \>= 130106)
ifneq ($(CLANG_13_OR_MORE),0)
# supported: c++11, c++14, c++17, c++20
# future: c++2b
CXXFLAGS ?= --std=c++20 -O3 -Iinclude $(shell pkg-config --cflags getargv)
else
CXXFLAGS ?= --std=c++17 -O3 -Iinclude $(shell pkg-config --cflags getargv)
endif
EXTRA_CXXFLAGS := -pedantic-errors -Weverything -Wno-c++98-compat -Wno-pre-c++20-compat-pedantic -Wno-poison-system-directories
LDFLAGS := -Llib -fvisibility=default -fPIC
LDLIBS ?= $(shell pkg-config --libs getargv)
LIB_SHORT_NAME := getargv++
LIB_NAME := lib$(LIB_SHORT_NAME)
DYLIB_FILENAME := $(LIB_NAME).$(VERSION).dylib
DYLIB := lib/$(DYLIB_FILENAME)
SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
HEADERS := $(wildcard $(INCLUDE_DIR)/*.hpp)
OBJECTS := $(SOURCES:$(SRC_DIR)/%.cpp=$(OBJ_DIR)/%.o)
DMG_VOLUME_NAME := $(LIB_NAME) Installer
DMG := $(PKG_DIR)/$(LIB_NAME).dmg
PRODUCT_BUNDLE_PACKAGE_TYPE := APPL
LIB_BUNDLE_IDENTIFIER := $(CODESIGN_PREFIX)$(LIB_NAME)
PRODUCT_BUNDLE_IDENTIFIER := $(LIB_BUNDLE_IDENTIFIER)
PRODUCT := $(PKG_DIR)/$(LIB_NAME)-$(VERSION)-macOS-$(MACOSX_DEPLOYMENT_TARGET)-$(ARCH).pkg
LIB_PKG := $(PKG_DIR)/$(LIB_NAME)-$(VERSION)-macOS-$(MACOSX_DEPLOYMENT_TARGET)-$(ARCH)-package.pkg
DISTRIBUTION := $(OBJ_DIR)/dist.xml
ifeq ($(MACOS_LT_10_11),true)
DMG_FORMAT := UDZO
else ifeq ($(MACOS_LT_11),true)
DMG_FORMAT := ULFO
else
DMG_FORMAT := ULMO
endif
ifeq ($(MACOS_LT_10_13),true)
DMG_FS := HFS+
else
DMG_FS := APFS
endif
ifeq ($(MACOS_LT_12),true)
PKG_VERSION_FLAG :=
else
PKG_VERSION_FLAG := --min-os-version $(MACOSX_DEPLOYMENT_TARGET)
endif