# ``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$
#

ifndef TYPE
TYPE=opt
endif

include $(ERL_TOP)/erts/etc/common/test_vars.mk

ifndef PURIFY_FLAGS
PURIFY_FLAGS=
endif

ifndef TARGET_DIR
TARGET_DIR=.
endif

CSFX=.test.c
TSFX=.$(TYPE).test

TESTS=	$(TARGET_DIR)/sl_realloc_copy$(TSFX) \
	$(TARGET_DIR)/threads$(TSFX) \
	$(TARGET_DIR)/mmap_leak$(TSFX) \
	$(TARGET_DIR)/mmap_max$(TSFX) \
	$(TARGET_DIR)/halloc_wrap$(TSFX) \

OSRC= 	$(EMSRCDIR)/hash.c $(SYSSRCDIR)/sys_threads.c \
	$(EMSRCDIR)/erl_old_sl_alloc.c

NSRC= 	$(EMSRCDIR)/hash.c $(SYSSRCDIR)/sys_threads.c \
	$(EMSRCDIR)/erl_sl_alloc.c
INCLUDES= 	-I$(CONF_H_DIR) \
		-I$(EMSRCDIR) \
		-I$(ERL_TOP)/erts/emulator/$(TARGET) \
		-I$(ERL_TOP)/erts/emulator/hipe \
		-I$(SYSSRCDIR) \
		-I. 

CFLAGS += -DMULTIPLE_THREADS_USE_SL_ALLOC=1

all: $(TESTS)

$(TARGET_DIR)/old.%$(TSFX): old.%$(CSFX) sl_alloc_test.h $(EMSRCDIR)/erl_old_sl_alloc.c $(SRC)
	$(PURIFY) $(PURIFY_FLAGS) \
	$(CC) $(CFLAGS) -DNO_SL_ALLOC_STAT_ETERM -DINCLUDE_OLD_SL_ALLOC $(LIBS) $(INCLUDES) $(NSRC) $< -o $@

$(TARGET_DIR)/%$(TSFX): %$(CSFX) sl_alloc_test.h $(EMSRCDIR)/erl_sl_alloc.c $(SRC)
	$(PURIFY) $(PURIFY_FLAGS) \
	$(CC) $(CFLAGS) -DNO_SL_ALLOC_STAT_ETERM -DINCLUDE_NEW_SL_ALLOC  $(LIBS) $(INCLUDES) $(OSRC) $< -o $@

clean:
	cd $(TARGET_DIR) && rm -rf *~ \#*\# *.test

