PREFIX = /usr

CFLAGS = -Wall -O2 -g `glib-config --cflags`

INC_DIRS =

LIBS = -lm `glib-config --libs`
LIB_DIRS =

CC = cc
CPP = c++

CPPFLAGS = -D__cplusplus -Dc_plusplus

OBJ_C   = $(SRC_C:.c=.o)
OBJ_CPP = $(SRC_CPP:.cpp=.o)

MKDIR      = mkdir
MKDIRFLAGS = -p -m 0755

INSTALL      = install
INSTBINFLAGS = -m 0755 -s

EDV_BIN_DIR = $(PREFIX)/lib/endeavour2/bin


# Compile time information export:
#
EXPORT_COMPILETIMEINFO_H = echo -n -e "\
\#ifndef COMPILETIMEINFO_H\n\
\#define COMPILETIMEINFO_H\n\
\#define COMPILE_COMPILER\t\"`$(CPP) --version`\"\n\
\#define COMPILE_USER\t\t\"$(USER)\"\n\
\#define COMPILE_LOCATION\t\"`uname -n`\"\n\
\#define COMPILE_DATE\t\t`date +\"%s\"`\n\
\#endif\t/* COMPILETIMEINFO_H */\n"


# Rules:
#

all: config recycle sendcmd

config:
	$(EXPORT_COMPILETIMEINFO_H) > compiletimeinfo.h

recycle:
	$(CC) `glib-config --cflags --libs` \
	-Wall -O2 -g \
	recycle.c ../edvrecbin.c ../edvrecbinfio.c \
	../string.cpp ../strexp.cpp ../disk.cpp ../fio.cpp \
	-o recycle

sendcmd:
	$(CC) `glib-config --cflags --libs` \
	-Wall -O2 -g \
	sendcmd.c ../edvinterps.c ../edvcfg.c ../edvcfgfio.c \
	../prochandle.cpp ../string.cpp ../strexp.cpp ../disk.cpp \
	../fio.cpp \
        -o sendcmd

install:
	$(MKDIR) $(MKDIRFLAGS) $(EDV_BIN_DIR)
	$(INSTALL) $(INSTBINFLAGS) recycle $(EDV_BIN_DIR)
	$(INSTALL) $(INSTBINFLAGS) sendcmd $(EDV_BIN_DIR)


# Maintainance and Misc Rules:
clean:
	rm -f a.out core *.o compiletimeinfo.h \
	recycle sendcmd
