aboutsummaryrefslogblamecommitdiffstats
path: root/erts/lib_src/Makefile.in
blob: 49f5b1f0487a56d67595918e115125d04442ce58 (plain) (tree)
1
2
3
4
5
6
7
8
9
10

                  


                                                       




                                                                     
 



                                                                        
 



































































































                                                        
                                 















































































































































































































































































































































































                                                                                                  

      

































































































































                                                                                                 
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 2004-2010. All Rights Reserved.
#
# 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 online 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.
#
# %CopyrightEnd%
#

include $(ERL_TOP)/make/target.mk
include ../include/internal/$(TARGET)/ethread.mk

OMIT_OMIT_FP=no


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@

ERLANG_OSTYPE=@ERLANG_OSTYPE@

OMIT_FP=false
CFLAGS=$(subst O2,O3, @CFLAGS@)

ifeq ($(TYPE),debug)
CFLAGS=@DEBUG_CFLAGS@ -DDEBUG
TYPE_SUFFIX=.debug
ifeq ($(USING_VC),yes)
LD_FLAGS += -g
endif
PRE_LD=

else

ifeq ($(TYPE),purify)
CFLAGS=@DEBUG_CFLAGS@ -DPURIFY
TYPE_SUFFIX=.purify
PRE_LD=purify $(PURIFY_BUILD_OPTIONS)
else
ifeq ($(TYPE),quantify)
CFLAGS += -DQUANTIFY
TYPE_SUFFIX=.quantify
PRE_LD=quantify $(QUANTIFY_BUILD_OPTIONS)
else
ifeq ($(TYPE),purecov)
CFLAGS=@DEBUG_CFLAGS@ -DPURECOV
TYPE_SUFFIX=.purecov
PRE_LD=purecov $(PURECOV_BUILD_OPTIONS)
else
ifeq ($(TYPE),gcov)
CFLAGS=@DEBUG_CFLAGS@ -fprofile-arcs -ftest-coverage -O0
TYPE_SUFFIX=.gcov
PRE_LD=
else
ifeq ($(TYPE),valgrind)
CFLAGS=@DEBUG_CFLAGS@ -DVALGRIND
TYPE_SUFFIX=.valgrind
PRE_LD=
else
ifeq ($(TYPE),gprof)
CFLAGS += -DGPROF -pg
TYPE_SUFFIX=.gprof
PRE_LD=
else
ifeq ($(TYPE),lcnt)
TYPE_SUFFIX = .lcnt
CFLAGS += -DERTS_ENABLE_LOCK_COUNT
OMIT_FP=true
PRE_LD=
else
override TYPE=opt
OMIT_FP=true
TYPE_SUFFIX=
PRE_LD=
endif
endif
endif
endif
endif
endif
endif
endif

OPSYS=@OPSYS@
sol2CFLAGS=
linuxCFLAGS=
darwinCFLAGS=-DDARWIN
noopsysCFLAGS=
OPSYSCFLAGS=$($(OPSYS)CFLAGS)
ARCH=@ARCH@
ultrasparcCFLAGS=-Wa,-xarch=v8plusa
ARCHCFLAGS=$($(ARCH)CFLAGS)

ifeq ($(OMIT_OMIT_FP),yes)
OMIT_FP=false
endif

CREATE_DIRS=

ifeq ($(CC)-$(OMIT_FP), gcc-true)
CFLAGS += -fomit-frame-pointer
endif

CFLAGS += @WFLAGS@ @DEFS@ $(ARCHCFLAGS)

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@

TT_DIR=$(TARGET)/$(TYPE)

ERTS_INCL=../include
ERTS_INCL_INT=../include/internal

INCLUDES=-I$(ERTS_INCL) -I$(ERTS_INCL)/$(TARGET) -I$(ERTS_INCL_INT) -I$(ERTS_INCL_INT)/$(TARGET)
INCLUDES += -I../emulator/beam -I../emulator/sys/$(ERLANG_OSTYPE)

USING_MINGW=@MIXED_CYGWIN_MINGW@
USING_VC=@MIXED_CYGWIN_VC@

ifeq ($(USING_VC),yes)
LIB_SUFFIX=.lib
LIB_PREFIX=
else
LIB_SUFFIX=.a
LIB_PREFIX=lib
endif

OBJS_ROOT_DIR=obj
OBJ_DIR=$(OBJS_ROOT_DIR)/$(TT_DIR)

CREATE_DIRS += $(OBJ_DIR)

ERTS_LIBS=

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

#
# erts (public) library
#

ERTS_LIB_SRCS =	common/erl_memory_trace_parser.c

ERTS_LIB_DIR=../lib/$(TARGET)
CREATE_DIRS += $(ERTS_LIB_DIR)

ifeq ($(USING_VC),yes)
# Windows obj dir
MD_OBJ_DIR=$(OBJ_DIR)/MD
MDd_OBJ_DIR=$(OBJ_DIR)/MDd
MT_OBJ_DIR=$(OBJ_DIR)/MT
MTd_OBJ_DIR=$(OBJ_DIR)/MTd

CREATE_DIRS +=	$(MD_OBJ_DIR) \
		$(MDd_OBJ_DIR) \
		$(MT_OBJ_DIR) \
		$(MTd_OBJ_DIR)

ERTS_MD_LIB_OBJS=$(addprefix $(MD_OBJ_DIR)/,$(notdir $(ERTS_LIB_SRCS:.c=.o)))
ERTS_MDd_LIB_OBJS=$(addprefix $(MDd_OBJ_DIR)/,$(notdir $(ERTS_LIB_SRCS:.c=.o)))
ERTS_MT_LIB_OBJS=$(addprefix $(MT_OBJ_DIR)/,$(notdir $(ERTS_LIB_SRCS:.c=.o)))
ERTS_MTd_LIB_OBJS=$(addprefix $(MTd_OBJ_DIR)/,$(notdir $(ERTS_LIB_SRCS:.c=.o)))

else # --- Not windows ---

# Reentrant obj dir
ifneq ($(strip $(ETHR_LIB_NAME)),)
r_OBJ_DIR = $(OBJ_DIR)/r
CREATE_DIRS += $(r_OBJ_DIR)
ERTS_r_LIB_OBJS=$(addprefix $(r_OBJ_DIR)/,$(notdir $(ERTS_LIB_SRCS:.c=.o)))
endif
ERTS_LIB_OBJS=$(addprefix $(OBJ_DIR)/,$(notdir $(ERTS_LIB_SRCS:.c=.o)))

endif

ifeq ($(USING_VC),yes)
ERTS_MD_LIB=$(ERTS_LIB_DIR)/$(LIB_PREFIX)erts_MD$(TYPE_SUFFIX)$(LIB_SUFFIX)
ERTS_MDd_LIB=$(ERTS_LIB_DIR)/$(LIB_PREFIX)erts_MDd$(TYPE_SUFFIX)$(LIB_SUFFIX)
ERTS_MT_LIB=$(ERTS_LIB_DIR)/$(LIB_PREFIX)erts_MT$(TYPE_SUFFIX)$(LIB_SUFFIX)
ERTS_MTd_LIB=$(ERTS_LIB_DIR)/$(LIB_PREFIX)erts_MTd$(TYPE_SUFFIX)$(LIB_SUFFIX)
ERTS_LIBS += \
	$(ERTS_MD_LIB) \
	$(ERTS_MDd_LIB) \
	$(ERTS_MT_LIB) \
	$(ERTS_MTd_LIB)
else

ERTS_LIB = $(ERTS_LIB_DIR)/$(LIB_PREFIX)erts$(TYPE_SUFFIX)$(LIB_SUFFIX)
ERTS_LIBS += $(ERTS_LIB)

ifneq ($(strip $(ETHR_LIB_NAME)),)
ERTS_r_LIB = $(ERTS_LIB_DIR)/$(LIB_PREFIX)erts_r$(TYPE_SUFFIX)$(LIB_SUFFIX)
ERTS_LIBS += $(ERTS_r_LIB)
endif

endif

#
# erts_internal library
#

ERTS_LIB_INTERNAL_DIR=../lib/internal/$(TARGET)
CREATE_DIRS += $(ERTS_LIB_INTERNAL_DIR)

ERTS_INTERNAL_LIBS=

ERTS_INTERNAL_LIB_SRCS = \
	common/erl_printf_format.c \
	common/erl_printf.c \
	common/erl_misc_utils.c

ERTS_INTERNAL_LIB_NAME=erts_internal$(TYPE_SUFFIX)

ifeq ($(USING_VC),yes)
ifeq ($(TYPE),debug)
ERTS_INTERNAL_LIB_OBJS = \
	$(addprefix $(MTd_OBJ_DIR)/,$(notdir $(ERTS_INTERNAL_LIB_SRCS:.c=.o)))
else
ERTS_INTERNAL_LIB_OBJS = \
	$(addprefix $(MT_OBJ_DIR)/,$(notdir $(ERTS_INTERNAL_LIB_SRCS:.c=.o)))
endif
else
ERTS_INTERNAL_LIB_OBJS = \
	$(addprefix $(OBJ_DIR)/,$(notdir $(ERTS_INTERNAL_LIB_SRCS:.c=.o)))
endif

ERTS_INTERNAL_LIB=$(ERTS_LIB_INTERNAL_DIR)/$(LIB_PREFIX)$(ERTS_INTERNAL_LIB_NAME)$(LIB_SUFFIX)

ERTS_INTERNAL_LIBS += $(ERTS_INTERNAL_LIB)

ifneq ($(strip $(ETHR_LIB_NAME)),)
ERTS_INTERNAL_r_LIB_NAME=erts_internal_r$(TYPE_SUFFIX)

ifeq ($(USING_VC),yes)
ifeq ($(TYPE),debug)
ERTS_INTERNAL_r_LIB_OBJS = \
	$(addprefix $(MDd_OBJ_DIR)/,$(notdir $(ERTS_INTERNAL_LIB_SRCS:.c=.o)))
else
ERTS_INTERNAL_r_LIB_OBJS = \
	$(addprefix $(MD_OBJ_DIR)/,$(notdir $(ERTS_INTERNAL_LIB_SRCS:.c=.o)))
endif
else
ERTS_INTERNAL_r_LIB_OBJS = \
	$(addprefix $(r_OBJ_DIR)/,$(notdir $(ERTS_INTERNAL_LIB_SRCS:.c=.o)))
endif

ERTS_INTERNAL_r_LIB=$(ERTS_LIB_INTERNAL_DIR)/$(LIB_PREFIX)$(ERTS_INTERNAL_r_LIB_NAME)$(LIB_SUFFIX)

ERTS_INTERNAL_LIBS += $(ERTS_INTERNAL_r_LIB)

endif

#
# ethread library
#
ifneq ($(strip $(ETHR_LIB_NAME)),)
ETHREAD_LIB_SRC=common/ethread.c
ETHREAD_LIB_NAME=ethread$(TYPE_SUFFIX)

ifeq ($(USING_VC),yes)
ifeq ($(TYPE),debug)
ETHREAD_LIB_OBJS = \
	$(addprefix $(MDd_OBJ_DIR)/,$(notdir $(ETHREAD_LIB_SRC:.c=.o)))
else
ETHREAD_LIB_OBJS = \
	$(addprefix $(MD_OBJ_DIR)/,$(notdir $(ETHREAD_LIB_SRC:.c=.o)))
endif
else
ETHREAD_LIB_OBJS = \
	$(addprefix $(r_OBJ_DIR)/,$(notdir $(ETHREAD_LIB_SRC:.c=.o)))
endif

ETHREAD_LIB=$(ERTS_LIB_INTERNAL_DIR)/$(LIB_PREFIX)$(ETHREAD_LIB_NAME)$(LIB_SUFFIX)

else

ETHREAD_LIB_SRC=
ETHREAD_LIB_NAME=
ETHREAD_LIB_OBJS=
ETHREAD_LIB=

endif

#
# Everything to build
#
all: $(CREATE_DIRS) $(ETHREAD_LIB) $(ERTS_LIBS) $(ERTS_INTERNAL_LIBS)
ifeq ($(OMIT_OMIT_FP),yes)
	@echo '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *'
	@echo '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *'
	@echo '* *                                                         * *'
	@echo '* * NOTE: Omit frame pointer optimization has been omitted  * *'
	@echo '* *                                                         * *'
	@echo '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *'
	@echo '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *'
endif
#
# The libs ...
#
ifeq ($(USING_VC),yes)
AR_OUT=-out:
AR_FLAGS=
else
AR_OUT=
AR_FLAGS=rcv
endif

ifndef RANLIB
RANLIB=true
endif

$(ETHREAD_LIB): $(ETHREAD_LIB_OBJS)
	$(AR) $(AR_FLAGS) $(AR_OUT)$@ $(ETHREAD_LIB_OBJS)
	$(RANLIB) $@

$(ERTS_INTERNAL_LIB): $(ERTS_INTERNAL_LIB_OBJS)
	$(AR) $(AR_FLAGS) $(AR_OUT)$@ $(ERTS_INTERNAL_LIB_OBJS)
	$(RANLIB) $@

$(ERTS_INTERNAL_r_LIB): $(ERTS_INTERNAL_r_LIB_OBJS)
	$(AR) $(AR_FLAGS) $(AR_OUT)$@ $(ERTS_INTERNAL_r_LIB_OBJS)
	$(RANLIB) $@

$(ERTS_MD_LIB): $(ERTS_MD_LIB_OBJS)
	$(AR) $(AR_FLAGS) $(AR_OUT)$@ $(ERTS_MD_LIB_OBJS)
	$(RANLIB) $@

$(ERTS_MDd_LIB): $(ERTS_MDd_LIB_OBJS)
	$(AR) $(AR_FLAGS) $(AR_OUT)$@ $(ERTS_MDd_LIB_OBJS)
	$(RANLIB) $@

$(ERTS_MT_LIB): $(ERTS_MT_LIB_OBJS)
	$(AR) $(AR_FLAGS) $(AR_OUT)$@ $(ERTS_MT_LIB_OBJS)
	$(RANLIB) $@

$(ERTS_MTd_LIB): $(ERTS_MTd_LIB_OBJS)
	$(AR) $(AR_FLAGS) $(AR_OUT)$@ $(ERTS_MTd_LIB_OBJS)
	$(RANLIB) $@

$(ERTS_r_LIB): $(ERTS_r_LIB_OBJS)
	$(AR) $(AR_FLAGS) $(AR_OUT)$@ $(ERTS_r_LIB_OBJS)
	$(RANLIB) $@

$(ERTS_LIB): $(ERTS_LIB_OBJS)
	$(AR) $(AR_FLAGS) $(AR_OUT)$@ $(ERTS_LIB_OBJS)
	$(RANLIB) $@

#
# Object files
#

$(r_OBJ_DIR)/%.o: common/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) $(INCLUDES) -c $< -o $@

$(r_OBJ_DIR)/%.o: $(ERLANG_OSTYPE)/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) $(INCLUDES) -c $< -o $@

$(OBJ_DIR)/%.o: common/%.c
	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

$(OBJ_DIR)/%.o: $(ERLANG_OSTYPE)/%.c
	$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@

# Win32 specific

$(MD_OBJ_DIR)/%.o: common/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) -MD $(INCLUDES) -c $< -o $@

$(MD_OBJ_DIR)/%.o: $(ERLANG_OSTYPE)/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) -MD $(INCLUDES) -c $< -o $@

$(MDd_OBJ_DIR)/%.o: common/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) -MDd $(INCLUDES) -c $< -o $@

$(MDd_OBJ_DIR)/%.o: $(ERLANG_OSTYPE)/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) -MDd $(INCLUDES) -c $< -o $@

$(MT_OBJ_DIR)/%.o: common/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) -MT $(INCLUDES) -c $< -o $@

$(MT_OBJ_DIR)/%.o: $(ERLANG_OSTYPE)/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) -MT $(INCLUDES) -c $< -o $@

$(MTd_OBJ_DIR)/%.o: common/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) -MTd $(INCLUDES) -c $< -o $@

$(MTd_OBJ_DIR)/%.o: $(ERLANG_OSTYPE)/%.c
	$(CC) $(THR_DEFS) $(CFLAGS) -MTd $(INCLUDES) -c $< -o $@

#
# Create directories
#

$(CREATE_DIRS):
	$(MKDIR) -p $@

#
# Install
#

include $(ERL_TOP)/make/otp_release_targets.mk
include ../vsn.mk
RELSYSDIR = $(RELEASE_PATH)/erts-$(VSN)

RELEASE_INCLUDES= \
	$(ERTS_INCL)/erl_memory_trace_parser.h \
	$(ERTS_INCL)/$(TARGET)/erl_int_sizes_config.h \
	$(ERTS_INCL)/erl_fixed_size_int_types.h
RELEASE_LIBS=$(ERTS_LIBS)

INTERNAL_RELEASE_INCLUDES= \
	$(ERTS_INCL_INT)/README \
	$(ERTS_INCL_INT)/ethread.h \
	$(ERTS_INCL_INT)/$(TARGET)/ethread.mk \
	$(ERTS_INCL_INT)/$(TARGET)/erts_internal.mk \
	$(ERTS_INCL_INT)/$(TARGET)/ethread_header_config.h \
	$(ERTS_INCL_INT)/erl_printf.h \
	$(ERTS_INCL_INT)/erl_printf_format.h \
	$(ERTS_INCL_INT)/erl_memory_trace_protocol.h \
	$(ERTS_INCL_INT)/erl_misc_utils.h \
	$(ERTS_INCL_INT)/erl_errno.h

INTERNAL_X_RELEASE_INCLUDE_DIRS= i386 x86_64 ppc32 sparc32 sparc64 tile

INTERNAL_RELEASE_LIBS= \
	../lib/internal/README \
	$(ETHREAD_LIB) \
	$(ERTS_INTERNAL_LIBS)

release_spec: all
ifneq ($(strip $(RELEASE_INCLUDES)),)
	$(INSTALL_DIR) $(RELSYSDIR)/include
	$(INSTALL_DIR) $(RELEASE_PATH)/usr/include
	$(INSTALL_DATA) $(RELEASE_INCLUDES) $(RELSYSDIR)/include
	$(INSTALL_DATA) $(RELEASE_INCLUDES) $(RELEASE_PATH)/usr/include
endif
ifneq ($(strip $(INTERNAL_RELEASE_INCLUDES)),)
	$(INSTALL_DIR) $(RELSYSDIR)/include/internal
	$(INSTALL_DATA) $(INTERNAL_RELEASE_INCLUDES) $(RELSYSDIR)/include/internal
endif
ifneq ($(strip $(INTERNAL_X_RELEASE_INCLUDE_DIRS)),)
	for xdir in $(INTERNAL_X_RELEASE_INCLUDE_DIRS); do \
		$(INSTALL_DIR) $(RELSYSDIR)/include/internal/$$xdir; \
		$(INSTALL_DATA) $(ERTS_INCL_INT)/$$xdir/*.h \
			$(RELSYSDIR)/include/internal/$$xdir; \
	done
endif
ifneq ($(strip $(RELEASE_LIBS)),)
	$(INSTALL_DIR) $(RELSYSDIR)/lib
	$(INSTALL_DIR) $(RELEASE_PATH)/usr/lib
	$(INSTALL_DATA) $(RELEASE_LIBS) $(RELSYSDIR)/lib
	$(INSTALL_DATA) $(RELEASE_LIBS) $(RELEASE_PATH)/usr/lib
endif
ifneq ($(strip $(INTERNAL_RELEASE_LIBS)),)
	$(INSTALL_DIR) $(RELSYSDIR)/lib/internal
	$(INSTALL_DATA) $(INTERNAL_RELEASE_LIBS) $(RELSYSDIR)/lib/internal
endif

docs: 

release_docs_spec:


#
# Cleanup
#
clean:
	$(RM) -rf ../lib/internal/$(TARGET)/*
	$(RM) -rf ../lib/$(TARGET)/*
	$(RM) -rf obj/$(TARGET)/*
	$(RM) -f $(TARGET)/depend.mk

#
# Make dependencies
#

ifeq ($(USING_VC),yes)
# VC++ used for compiling. We undef __GNUC__ since if __GNUC__ is defined
# we will include other headers than when compiling which will result in
# faulty dependencies.
#DEP_CC=@EMU_CC@ -U__GNUC__
DEP_CC=$(CC)
else
DEP_CC=$(CC)
endif

#SED_REPL_WIN_DRIVE=s|\([ 	]\)\([A-Za-z]\):|\1/cygdrive/\2|g;s|^\([A-Za-z]\):|/cygdrive/\1|g
SED_REPL_O=s|^\([^:]*\)\.o:|$$(OBJ_DIR)/\1.o:|g
SED_REPL_r_O=s|^\([^:]*\)\.o:|$$(r_OBJ_DIR)/\1.o:|g
SED_REPL_MD_O=s|^\([^:]*\)\.o:|$$(MD_OBJ_DIR)/\1.o:|g
SED_REPL_MDd_O=s|^\([^:]*\)\.o:|$$(MDd_OBJ_DIR)/\1.o:|g
SED_REPL_MT_O=s|^\([^:]*\)\.o:|$$(MT_OBJ_DIR)/\1.o:|g
SED_REPL_MTd_O=s|^\([^:]*\)\.o:|$$(MTd_OBJ_DIR)/\1.o:|g
SED_REPL_TT_DIR=s|$(TT_DIR)/|$$(TT_DIR)/|g
SED_REPL_TARGET=s|$(TARGET)/|$$(TARGET)/|g

ifeq ($(TARGET),win32)
#SED_PREFIX=$(SED_REPL_WIN_DRIVE);
SED_PREFIX=
DEP_FLAGS=$(subst -O3,,$(subst -O2,,$(CFLAGS))) $(INCLUDES)
else
SED_PREFIX=
DEP_FLAGS=$(CFLAGS) $(INCLUDES)
endif

SED_DEPEND=sed '$(SED_PREFIX)$(SED_REPL_O);$(SED_REPL_TT_DIR);$(SED_REPL_TARGET)'
SED_r_DEPEND=sed '$(SED_PREFIX)$(SED_REPL_r_O);$(SED_REPL_TT_DIR);$(SED_REPL_TARGET)'
SED_MD_DEPEND=sed '$(SED_PREFIX)$(SED_REPL_MD_O);$(SED_REPL_TT_DIR);$(SED_REPL_TARGET)'
SED_MDd_DEPEND=sed '$(SED_PREFIX)$(SED_REPL_MDd_O);$(SED_REPL_TT_DIR);$(SED_REPL_TARGET)'
SED_MT_DEPEND=sed '$(SED_PREFIX)$(SED_REPL_MT_O);$(SED_REPL_TT_DIR);$(SED_REPL_TARGET)'
SED_MTd_DEPEND=sed '$(SED_PREFIX)$(SED_REPL_MTd_O);$(SED_REPL_TT_DIR);$(SED_REPL_TARGET)'

DEPEND_MK=$(TARGET)/depend.mk

depend:
	@echo "Generating dependency file $(DEPEND_MK)..."
	@echo "# Generated dependency rules" > $(DEPEND_MK);
	@echo "# " >> $(DEPEND_MK);
ifneq ($(strip $(ETHREAD_LIB_SRC)),)
	@echo "# ethread lib objects..." >> $(DEPEND_MK);
ifeq ($(USING_VC),yes)
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ETHREAD_LIB_SRC) \
		| $(SED_MD_DEPEND) >> $(DEPEND_MK)
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ETHREAD_LIB_SRC) \
		| $(SED_MDd_DEPEND) >> $(DEPEND_MK)
else
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ETHREAD_LIB_SRC) \
		| $(SED_r_DEPEND) >> $(DEPEND_MK)
endif
endif
ifneq ($(strip $(ERTS_INTERNAL_LIB_SRCS)),)
ifneq ($(strip $(ETHREAD_LIB_SRC)),)
	@echo "# erts_internal_r lib objects..." >> $(DEPEND_MK);
ifeq ($(USING_VC),yes)
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_INTERNAL_LIB_SRCS) \
		| $(SED_MD_DEPEND) >> $(DEPEND_MK)
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_INTERNAL_LIB_SRCS) \
		| $(SED_MDd_DEPEND) >> $(DEPEND_MK)
else
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_INTERNAL_LIB_SRCS) \
		| $(SED_r_DEPEND) >> $(DEPEND_MK)
endif
endif
	@echo "# erts_internal lib objects..." >> $(DEPEND_MK);
ifeq ($(USING_VC),yes)
	$(DEP_CC) -MM $(DEP_FLAGS) $(ERTS_INTERNAL_LIB_SRCS) \
		| $(SED_MD_DEPEND) >> $(DEPEND_MK)
	$(DEP_CC) -MM $(DEP_FLAGS) $(ERTS_INTERNAL_LIB_SRCS) \
		| $(SED_MDd_DEPEND) >> $(DEPEND_MK)
else
	$(DEP_CC) -MM $(DEP_FLAGS) $(ERTS_INTERNAL_LIB_SRCS) \
		| $(SED_DEPEND) >> $(DEPEND_MK)
endif
endif
ifneq ($(strip $(ERTS_LIB_SRCS)),)
ifeq ($(USING_VC),yes)
	@echo "# erts_MD lib objects..." >> $(DEPEND_MK);
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_LIB_SRCS) \
		| $(SED_MD_DEPEND) >> $(DEPEND_MK)
	@echo "# erts_MDd lib objects..." >> $(DEPEND_MK);
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_LIB_SRCS) \
		| $(SED_MDd_DEPEND) >> $(DEPEND_MK)
	@echo "# erts_MT lib objects..." >> $(DEPEND_MK);
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_LIB_SRCS) \
		| $(SED_MT_DEPEND) >> $(DEPEND_MK)
	@echo "# erts_MTd lib objects..." >> $(DEPEND_MK);
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_LIB_SRCS) \
		| $(SED_MTd_DEPEND) >> $(DEPEND_MK)
	@echo "# erts_internal_r lib objects..." >> $(DEPEND_MK);
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_INTERNAL_LIB_SRCS) \
		| $(SED_MD_DEPEND) >> $(DEPEND_MK)
	@echo "# erts_internal_r.debug lib objects..." >> $(DEPEND_MK);
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_INTERNAL_LIB_SRCS) \
		| $(SED_MDd_DEPEND) >> $(DEPEND_MK)
else
ifneq ($(strip $(ETHREAD_LIB_SRC)),)
	@echo "# erts_r lib objects..." >> $(DEPEND_MK);
	$(DEP_CC) -MM $(THR_DEFS) $(DEP_FLAGS) $(ERTS_LIB_SRCS) \
		| $(SED_r_DEPEND) >> $(DEPEND_MK)
endif
	@echo "# erts lib objects..." >> $(DEPEND_MK);
	$(DEP_CC) -MM $(DEP_FLAGS) $(ERTS_LIB_SRCS) \
		| $(SED_DEPEND) >> $(DEPEND_MK)
endif
endif
	@echo "# EOF" >> $(DEPEND_MK);

-include $(DEPEND_MK)

# eof