.SUFFIXES : .cpp .o .c .y

export CPP=g++
export CC=gcc
AR=ar
YACPP=yacc

DEFINES_CPP=

#============================================================================
# Optimized Code - Requires more virtual memory.
#OPTCPPFLAGS=-O3
#----------------------
# Not optimized
OPTCPPFLAGS=
#============================================================================

# gcc < 2.8.x 
#DEFINES_CPP=-D_G_NO_EXTERN_TEMPLATES
#CPPFLAGS=-fhandle-exceptions 


#============================================================================
# gcc 2.8.x (y superiores):
# -------------------------
# Ver warnings:
#CPPFLAGS += -Wall -Wno-deprecated
# Ignorar warnings:
CPPFLAGS += -w

# Include information for GDB:
#CPPFLAGS += -g

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# The next flag must be actived ONLY if we are compiling under Windows 95 !!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#CPPFLAGS += -D__WINDOWS__
#============================================================================



DEFINES_C=


# If we are compiling for Unix
INCLUDES_CPP=-I/usr/include -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux
INCLUDES_CPP=-I./ -I/home/workspace/ericsson -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux
# or if we are compiling for Windows 95
#INCLUDES_CPP=


INCLUDES_C=
CFLAGS= 
DEBUGFLAGS=
LDFLAGS += -L. -g3

SIMOBJS=neighval.o	\
macroexp.o		\
evaldeb.o		\
zone.o			\
except.o		\
strutil.o		\
flatcoup.o		\
flatcoor.o		\
randlib.o		\
ntupla.o		\
cellstate.o		\
gram.o			\
undefd.o		\
atomic.o		\
coupled.o		\
model.o			\
modeladm.o		\
msgadm.o		\
real.o			\
realfunc.o		\
realprec.o		\
impresion.o		\
port.o			\
root.o			\
cdtime.o		\
ini.o			\
mainsimu.o		\
stdaload.o		\
process.o		\
procadm.o		\
simulat.o		\
portlist.o		\
coordin.o		\
atomcell.o		\
tdcell.o		\
idcell.o		\
ltranadm.o		\
coupcell.o		\
coorcell.o		\
synnode.o		\
tbool.o			\
parser.o		\
netload.o		\
bsdchann.o		

# if we are compiling for Windows 95, comment the last two lines



EXAMPLESOBJS = queue.o \
		main.o \
		generat.o \
		cpu.o \
		transduc.o \
		trafico.o \
		distri.o \
		com.o \
		linpack.o \
		debug.o \
		register.o \
		MeNB.o \
		UE.o \
		Msg.o \
		globalQueue.o \
		Point.o \
		movement.o\
		eNB.o \

		

LIBNAME=simu
LIBS=-lsimu 
ALLOBJS=${EXAMPLESOBJS} ${SIMOBJS} 
INIOBJS=initest.o ini.o
ALLSRCS=${ALLOBJS:.o=.cpp} gram.y 

all: libs simu 

libs: libsimu.a

simu: ${ALLOBJS}  libsimu.a
	g++ ${LDFLAGS} -o $@ ${EXAMPLESOBJS} ${LIBS}

initest: ${INIOBJS} 
	${CPP} ${LDFLAGS} -o $@ ${INIOBJS} 

exptest: synnode.o
	g++ ${LDFLAGS} -o $@ synnode.o
	
parser: parser.o gram.o
	g++ ${LDFLAGS} -o $@ parser.o gram.o

libsimu.a: ${SIMOBJS}
	${AR} crs lib${LIBNAME}.a ${SIMOBJS}

clean:
	- rm -f *.o *.a simu core drawlog initest exptest parser makerand toMap

depend:
	makedepend -Y ${ALLSRCS}

backup:
	tar -cvf simu.tar *.cpp *.h *.c *.y makefile* *.ma *.ev *.vpj *.bat *.txt *.val *.inc *.map; gzip simu.tar; mv simu.tar.gz simu.tgz

########################
# Without Optimization
Log.o: Log.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
LogManager.o: LogManager.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
Average.o: Average.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
globalQueue.o: globalQueue.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
MeNB.o: MeNB.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
UE.o: UE.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<
Point.o: Point.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<
movement.o: movement.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
eNB.o: eNB.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
HOElements.o: HOElements.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
BSRegistry.o: BSRegistry.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
NetStats.o: NetStats.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
Msg.o: Msg.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
MetaInfoFile.o: MetaInfoFile.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 
register.o: register.cpp
	${CPP} -c ${LDFLAGS} ${INCLUDES_CPP} ${EXTRA_INCLUDES} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $< 

generat.o: generat.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

queue.o: queue.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

cpu.o: cpu.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

transduc.o: transduc.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

trafico.o: trafico.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

msgadm.o: msgadm.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

root.o: root.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

parser.o: parser.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

main.o: main.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

drawlog.o: drawlog.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

toMap.o: toMap.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

toCDPP.o: toCDPP.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

makerand.o: makerand.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

mainsimu.o: mainsimu.cpp
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<

# Uncomment these lines only for Windows
#macroexp.o: macroexp.cpp
#	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<
#
#flatcoup.o: flatcoup.cpp
#	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} $<
########################

.cpp.o:
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} ${OPTCPPFLAGS} $<

.c.o:
	${CC} -c ${INCLUDES_C} ${DEFINES_C}  ${DEBUGFLAGS} ${CFLAGS} ${OPTCPPFLAGS} $<

.y.o:
	bison -d -v -o gram.c gram.y
	${CPP} -c ${INCLUDES_CPP} ${DEFINES_CPP} ${DEBUGFLAGS} ${CPPFLAGS} ${OPTCPPFLAGS} ${@:.o=.c} 
	rm $*.c
	
# DO NOT DELETE

gram.o: synnode.h parser.h ntupla.h
