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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
|
# ``The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved via the world wide web at http://www.erlang.org/.
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# The Initial Developer of the Original Code is Ericsson Utvecklings AB.
# Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
# AB. All Rights Reserved.''
#
# $Id$
#
include $(ERL_TOP)/make/target.mk
include $(ERL_TOP)/erts/include/internal/$(TARGET)/ethread.mk
USING_MINGW=@MIXED_CYGWIN_MINGW@
USING_VC=@MIXED_VC@
CC=@CC@
LD=@LD@
AR=@AR@
RANLIB=@RANLIB@
RM=@RM@
MKDIR=@MKDIR@
INSTALL=@INSTALL@
INSTALL_DIR=@INSTALL_DIR@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
LDFLAGS=@LDFLAGS@
ifeq ($(TYPE),debug)
CFLAGS = @DEBUG_CFLAGS@ -DDEBUG
TYPEMARKER=.debug
PRE_LD =
ifeq ($(TARGET),win32)
LDFLAGS += -g
endif
else
ifeq ($(TYPE),purify)
CFLAGS = @CFLAGS@ -DPURIFY
TYPEMARKER=.purify
PRE_LD = purify $(PURIFY_BUILD_OPTIONS)
else
ifeq ($(TYPE),quantify)
CFLAGS = @CFLAGS@ -DQUANTIFY
TYPEMARKER=.quantify
PRE_LD = quantify $(QUANTIFY_BUILD_OPTIONS)
else
ifeq ($(TYPE),purecov)
CFLAGS = @DEBUG_CFLAGS@ -DPURECOV
TYPEMARKER=.purecov
PRE_LD = purecov $(PURECOV_BUILD_OPTIONS)
else
override TYPE=opt
CFLAGS = @CFLAGS@
PRE_LD =
TYPEMARKER =
endif
endif
endif
endif
ifeq ($(findstring -D_GNU_SOURCE,$(CFLAGS)),)
THR_DEFS = $(ETHR_DEFS)
else
# Remove duplicate -D_GNU_SOURCE
THR_DEFS = $(filter-out -D_GNU_SOURCE%, $(ETHR_DEFS))
endif
LIBS=@LIBS@
CREATE_DIRS=
TT_DIR=$(TARGET)/$(TYPE)
BIN_DIR=../bin/$(TARGET)
OBJ_DIR=../obj/$(TT_DIR)
CREATE_DIRS += $(BIN_DIR) $(OBJ_DIR)
PROGS=
DRIVERS=
#
# emem sources, objects, includes, libs, etc...
#
ifneq ($(strip $(ETHR_LIB_NAME)),)
# Need ethread package for emem
PROGS += $(BIN_DIR)/emem$(TYPEMARKER)@EXEEXT@
endif
EMEM_OBJ_DIR=$(OBJ_DIR)/emem
CREATE_DIRS += $(EMEM_OBJ_DIR)
EMEM_INCLUDES = -I$(ERL_TOP)/erts/include \
-I$(ERL_TOP)/erts/include/$(TARGET) \
-I$(ERL_TOP)/erts/include/internal \
-I$(ERL_TOP)/erts/include/internal/$(TARGET)
EMEM_HEADERS = erl_memory_trace_block_table.h
EMEM_SRCS = erl_memory.c erl_memory_trace_block_table.c
EMEM_CFLAGS = $(THR_DEFS) $(subst O2,O3, $(CFLAGS)) $(EMEM_INCLUDES)
EMEM_LDFLAGS = $(LDFLAGS)
ifeq ($(USING_VC), yes)
ifeq ($(TYPE),debug)
MT_LIB=MDd
else
MT_LIB=MD
endif
EMEM_CFLAGS += -$(MT_LIB)
EMEM_LDFLAGS += -$(MT_LIB)
EMEM_ERTS_LIB=erts_$(MT_LIB)$(TYPEMARKER)
else
EMEM_ERTS_LIB=erts_r$(TYPEMARKER)
endif
EMEM_ETHR_LIBS=$(subst -l$(ETHR_LIB_NAME),-l$(ETHR_LIB_NAME)$(TYPEMARKER),$(subst -lerts_internal_r,-lerts_internal_r$(TYPEMARKER),$(ETHR_LIBS)))
EMEM_LIBS = $(LIBS) \
-L$(ERL_TOP)/erts/lib/$(TARGET) \
-L$(ERL_TOP)/erts/lib/internal/$(TARGET) \
-l$(EMEM_ERTS_LIB) \
$(EMEM_ETHR_LIBS)
EMEM_OBJS = $(addprefix $(EMEM_OBJ_DIR)/,$(notdir $(EMEM_SRCS:.c=.o)))
#
# Misc targets
#
_create_dirs := $(shell mkdir -p $(CREATE_DIRS))
all: erts_lib $(PROGS) $(DRIVERS)
erts_lib:
cd $(ERL_TOP)/erts/lib_src && $(MAKE) $(TYPE)
docs:
clean:
$(RM) -rf ../obj/*
$(RM) -rf ../bin/*
$(RM) -f ./*~
.PHONY: all erts_lib docs clean
#
# Object targets
#
$(EMEM_OBJ_DIR)/%.o: %.c
$(CC) $(EMEM_CFLAGS) -o $@ -c $<
#
# Driver targets
#
#
# Program targets
#
$(BIN_DIR)/emem$(TYPEMARKER)@EXEEXT@: $(EMEM_OBJS)
$(PRE_LD) $(LD) $(EMEM_LDFLAGS) -o $@ $(EMEM_OBJS) $(EMEM_LIBS)
#
# Release targets
#
include $(ERL_TOP)/make/otp_release_targets.mk
include ../vsn.mk
RELSYSDIR = $(RELEASE_PATH)/lib/tools-$(TOOLS_VSN)
release_spec: all
$(INSTALL_DIR) $(RELSYSDIR)/c_src
$(INSTALL_DATA) $(EMEM_SRCS) $(EMEM_HEADERS) $(RELSYSDIR)/c_src
ifneq ($(PROGS),)
$(INSTALL_DIR) $(RELSYSDIR)/bin
$(INSTALL_PROGRAM) $(PROGS) $(RELSYSDIR)/bin
endif
release_docs_spec:
.PHONY: release_spec release_docs_spec
#
# Make dependencies
#
ifeq ($(USING_VC), yes)
DEP_CC=@EMU_CC@
else
DEP_CC=$(CC)
endif
SED_REPL_EMEM_OBJ_DIR=s|^\([^:]*\)\.o:|$$(EMEM_OBJ_DIR)/\1.o:|g
SED_REPL_OBJ_DIR=s|^\([^:]*\)\.o:|$$(OBJ_DIR)/\1.o:|g
SED_REPL_TT_DIR=s|$(TT_DIR)/|$$(TT_DIR)/|g
SED_REPL_TARGET=s|$(TARGET)/|$$(TARGET)/|g
SED_REPL_ERL_TOP=s|$(ERL_TOP)/|$$(ERL_TOP)/|g
SED_EMEM_DEPEND=sed '$(SED_REPL_EMEM_OBJ_DIR);$(SED_REPL_TT_DIR);$(SED_REPL_TARGET);$(SED_REPL_ERL_TOP)'
SED_DEPEND=sed '$(SED_REPL_OBJ_DIR);$(SED_REPL_TT_DIR);$(SED_REPL_TARGET);$(SED_REPL_ERL_TOP)'
DEPEND_MK=depend.mk
dep depend:
@echo "Generating dependency file $(DEPEND_MK)..."
@echo "# Generated dependency rules." > $(DEPEND_MK);
@echo "# Do *not* edit this file; instead, run 'make depend'." \
>> $(DEPEND_MK);
@echo "# " >> $(DEPEND_MK);
@echo "# emem objects..." >> $(DEPEND_MK);
$(DEP_CC) -MM $(EMEM_CFLAGS) $(EMEM_SRCS) \
| $(SED_EMEM_DEPEND) >> $(DEPEND_MK)
@echo "# EOF" >> $(DEPEND_MK);
.PHONY: dep depend
include $(DEPEND_MK)
# eof
|