forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.linux.makefile
More file actions
76 lines (61 loc) · 2.51 KB
/
Copy pathapplication.linux.makefile
File metadata and controls
76 lines (61 loc) · 2.51 KB
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
###############################################################################
# Linux Application Makefile Template
# Make sure the environment makefile has been included.
ifeq ($(ARCH),)
$(error Environment Makefile not included!)
endif
TYPE_DEFINES=
TYPE_INCLUDES=
TYPE_CCFLAGS=
include $(shell pwd)/$(dir $(lastword $(MAKEFILE_LIST)))/common.linux.makefile
###############################################################################
# Customizations
LIBS=$(CUSTOM_LIBS)
SHARED_LIBS=$(CUSTOM_SHARED_LIBS)
STATIC_LIBS=$(CUSTOM_STATIC_LIBS)
DYNAMIC_LIBS=$(CUSTOM_DYNAMIC_LIBS)
ifneq ($(ARCH),x86_64)
STATIC_LIBS+=stdc++
endif
LDFLAGS_COMMON=$(addprefix -L,$(GLOBAL_LIBS)) $(addprefix -L,$(CUSTOM_INCLUDES)) -export-dynamic
LDFLAGS_LTO:=$(CUSTOM_LDFLAGS_LTO) $(CUSTOM_LDFLAGS) $(LDFLAGS_COMMON) -Xlinker -no-undefined $(addprefix -Xlinker --exclude-libs -Xlinker ,$(addsuffix .a,$(addprefix lib,$(STATIC_LIBS))))
LDFLAGS_FINAL:=$(CUSTOM_LDFLAGS_FINAL) $(CUSTOM_LDFLAGS) $(LDFLAGS_COMMON) -no-undefined $(addprefix --exclude-libs ,$(addsuffix .a,$(addprefix lib,$(STATIC_LIBS))))
TARGET_PATH=$(BUILD_DIR)/$(NAME)
ifeq ($(LD_IS_CC),1)
# If we are using the compiler to link, we need to prefix the linker options
LDFLAGS_FINAL:=$(addprefix -Xlinker ,$(LDFLAGS_FINAL))
LINK_STEP1:=$(CXX) -fvisibility=hidden -o$(TARGET_PATH) $(LDFLAGS_LTO) $(LDFLAGS_FINAL) $(OBJECTS) $(CUSTOM_OBJECTS) \
-Wl,-Bstatic \
-Wl,--start-group \
$(addsuffix .a,$(addprefix $(PRODUCT_DIR)/lib,$(LIBS))) \
$(addprefix -l,$(STATIC_LIBS)) \
-Wl,--end-group \
-Wl,-Bdynamic \
$(addsuffix .so,$(addprefix $(PRODUCT_DIR)/,$(SHARED_LIBS))) \
$(addprefix -l,$(DYNAMIC_LIBS))
LINK_STEP2:=
else
LINK_STEP1:=$(CXX) -Wl,-relocatable -nodefaultlibs -fvisibility=hidden -o$(TARGET_PATH).rel $(LDFLAGS_LTO) $(OBJECTS) $(CUSTOM_OBJECTS) \
-Wl,-Bstatic \
-Wl,--start-group \
$(addsuffix .a,$(addprefix $(PRODUCT_DIR)/lib,$(LIBS))) \
$(addprefix -l,$(STATIC_LIBS)) \
-lgcc -lgcc_eh \
-Wl,--end-group
LINK_STEP2:=$(LD) -o$(TARGET_PATH) $(LDFLAGS_FINAL) $(TARGET_PATH).rel \
-Bdynamic \
$(addsuffix .so,$(addprefix $(PRODUCT_DIR)/,$(SHARED_LIBS))) \
$(addprefix -l,$(DYNAMIC_LIBS)) -lc
endif
$(TARGET_PATH): $(OBJECTS) $(DEPS)
mkdir -p $(dir $(TARGET_PATH))
$(LINK_STEP1)
$(LINK_STEP2)
ifneq ($(MODE),debug)
cd $(BUILD_DIR) && \
$(OBJCOPY) --only-keep-debug "$(NAME)" "$(NAME).dbg" && \
$(STRIP) --strip-debug "$(NAME)" && \
$(OBJCOPY) --add-gnu-debuglink="$(NAME).dbg" "$(NAME)"
endif
.PHONY: $(NAME)
$(NAME): $(TARGET_PATH)