This repository has been archived by the owner on Dec 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
module.mak
86 lines (72 loc) · 2.36 KB
/
module.mak
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
79
80
81
82
83
84
85
86
# This file is included by:
# - ldr/loader.mak
# - module/module.mak
# - plugins/plugin.mak
ifdef __LINT__
# Info 785 Too few initializers for aggregate
CFLAGS += -e785
endif
#----------------------------------------------------------------------
# include allmake.mak and prepare default goal if needed
ifndef NO_DEFAULT_TARGETS
include $(RD)../../allmake.mak
# prepare targets
GOALS += modules
GOALS += $(addprefix $(RI),$(IDCS))
GOALS += configs
all: $(GOALS)
# create default target and add it to the list of targets
ifdef BUILD_STATIC_LIBRARY
DEFAULT_TARGET = $(L)$(PROC)$(A)
STATIC_LIBS += $(DEFAULT_TARGET)
else
DEFAULT_TARGET = $(call module_dll,$(PROC))
MODULES += $(DEFAULT_TARGET)
endif
# create lists of object files for default target (shared or static)
OBJS += $(BASE_OBJS)
OBJS += $(call objs,$(foreach n,1 2 3 4 5 6 7 8 9 10,$(O$(n))))
$(DEFAULT_TARGET): MODULE_OBJS += $(OBJS)
# object file dependencies must be explicitly added to each module
$(DEFAULT_TARGET): $(OBJS)
endif
#----------------------------------------------------------------------
# prepare ldflags for all modules
MODULE_LDFLAGS += $(OUTMAP)$(F)$(@F).map
ifdef __LINUX__
DEFFILE ?= $(SRC_PATH)exports.def
MODULE_LDFLAGS += -Wl,--version-script=$(DEFFILE)
else ifdef __MAC__
INSTALL_NAME ?= $(@F)
MODULE_LDFLAGS += -Wl,-install_name,$(INSTALL_NAME)
endif
#----------------------------------------------------------------------
# main rule for modules
.PHONY: modules
modules: $(MODULES) $(STATIC_LIBS)
# shared libraries
$(MODULES): LDFLAGS += $(MODULE_LDFLAGS)
$(MODULES): $(LIBS) $(IDALIB) $(MAKEFILE_DEP) $(DEFFILE)
$(call link_dll, $(MODULE_OBJS), $(LIBS) $(LINKIDA))
ifdef __NT__
ifndef DONT_ERASE_LIB
$(Q)$(RM) $(@:$(DLLEXT)=.exp) $(@:$(DLLEXT)=.lib)
endif
endif
$(CHECKSYMS_CMD)
$(POSTACTION)
# static libraries
$(STATIC_LIBS): $(call lib, $(MODULE_OBJS))
#----------------------------------------------------------------------
# auxiliary rules
CFG_CONFIGS = $(addprefix $(C),$(CONFIGS))
configs: $(CFG_CONFIGS)
$(RI)%.idc: %.idc
$(CP) $? $@
#----------------------------------------------------------------------
# removes installed binaries from the $(BIN_PATH)/ directory
.PHONY: uninstall
uninstall::
rm -rf $(MODULES) $(STATIC_LIBS)
#----------------------------------------------------------------------
include $(IDA)objdir.mak