#************************************************************************
#       -= SEER - C-Scripting engine v 0.93a =-
#State      : under implementation
#Author     : Przemyslaw Podsiadly
#             email: ppodsiad@elka.pw.edu.pl
#             WWW:   http://home.elka.pw.edu.pl/~ppodsiad
#File:makefile.in
#Desc:does the dirty work - what makefile tells him
#************************************************************************
.PHONY:delobj error
#defines:
#****Compilation options:
#Optimize=1
#PGCC=1
#Compiler=1
# Comment out the following for 'production' builds - _m
DEB=-ggdb
Debug=1
Profile=1
Rebuild=1
#SeeRC=1   make seerc.exe
#Test=1    make test.exe

DoBefore=

Machine=-m486

#****output filename:

#****library objs
#OBJ_PATH=objs
OBJECTS=vars.o compiler.o expr.o declare.o initial.o parser.o preproc.o dict.o consts.o vcpucode.o vcpudeco.o instance.o callasm.o pmem.o script.o protect.o headers.o
OBJs = $(addprefix $(OBJ_PATH)/, $(OBJECTS))

#****program objs
#ifdef Compiler
#OBJp=seerc.o
EXE=bin/seerc

LIBc=lib/libseer.a
#ifdef Compiler
#LIBc=lib/libseerc.a

LIBs=-lm
#-lalleg
HDRs=seer.h src/internal.h src/code.h
COMPILE_C_HEADERS=

#****Compilation parameters
PRO=
Optim=-O6
#FLAGS=-Wall -s $(DEB) $(Machine) $(Optim) -ffast-math -fomit-frame-pointer
FLAGS=-Wall -s $(DEB) $(Machine) -ffast-math
SAFEFLAGS=-Wall -s $(DEB) $(Machine) -ffast-math
LINK=-Wall -s

#ifdef Compiler
MACROS=-DDEBUG
#MACROS=

#****compiler and linker:
AR=ar rs
CC=gcc

#ifdef SeeRC
#all:$(LIBc) $(EXE)
all:$(LIBc)

#****************************************************************
#****link program:
$(EXE):$(LIBc) msg2 $(OBJ_PATH)/$(OBJp) $(HDRs);$(CC) $(PRO) $(LINK) -o $(EXE) $(OBJ_PATH)/$(OBJp) $(LIBc) $(LIBs)

#****link library:
$(LIBc):$(DoBefore) $(OBJs) $(HDRs);$(AR) $(LIBc) $(OBJs)


#msg :;@echo Building SeeR scripting library
msg2 :$(DoBefore);@echo Building SeeR $(EXE)

#****compile
#objs/.o:compiler.c $(HDRs) $(COMPILE_C_HEADERS);$(CC) $(FLAGS) $(PRO) $(MACROS) -c -o $@ compiler.c

$(OBJ_PATH)/callasm.o:src/callasm.c $(HDRs);$(CC) $(SAFEFLAGS) -c $(MACROS) $(PRO) -I. -o $@ $<

$(OBJ_PATH)/%.o:src/%.c $(HDRs);$(CC) $(FLAGS) $(MACROS) $(PRO) -I. -c -o $@ $<

$(OBJ_PATH)/seerc.o:seerc/seerc.c $(HDRs);$(CC) $(FLAGS) $(PRO)  -I. -c -o $@ $<
$(OBJ_PATH)/test.o:test.c $(HDRs);$(CC) -s -Wall $(Machine) $(PRO)  -I. -c -o $@ $<

delobj:;@if [ "`ls $(OBJ_PATH)/*.o 2>/dev/nul`" != "" ]; then rm $(OBJ_PATH)/*.o; fi

#;echo -n "Re"
