#
# BASL scheduler: $Id: Makefile.in,v 2.0 1998/10/14 23:12:41 hender Exp $
#
@MAKE_POSIX_TARGET@

srcdir = @srcdir@
top_srcdir = @top_srcdir@
MK_VPATH = @srcdir@
INSTALL = @INSTALL@

@mk_head@
@mk_dirs@

BUILD_INCS = -I. -I$(srcdir) -I@top_builddir@/src/include
INCS = $(BUILD_INCS) -I$(PBS_SRCINC)
CFLAGS = @CFLAGS@ $(INCS) @DEFS@

# The scheduler code source directory.
SCHD_SRC = @SCHD_SRC@

OBJS_COMMON = af.o

OBJS_COMP =  Basl2c.o CodeGen.o List.o Node.o Semantic.o SymTab.o \
             Lexer.o Parser.o

OBJS_SCHED = af_cnode.o af_cnodemap.o af_config.o af_job.o \
             af_que.o af_resmom.o af_server.o af_system.o pbs_sched.o

OBJS = $(OBJS_COMMON) $(OBJS_COMP) $(OBJS_SCHED)

#
# do not try to find the source for these objs, they are created
# by the Makefile
#
MKDEP_IGNORE = pbs_sched.o

TARGETS = basl2c pbs_sched

PBSLIBS = ../lib/Liblog/liblog.a ../lib/Libnet/libnet.a ../lib/Libpbs/libpbs.a

LIBRARIES = $(LDFLAGS) $(PBSLIBS) $(TCL_LIBS) $(LIBS) $(LEXLIB) -lm



all: autodepend
	@MAKE_POSIX_PLUS@@$(MAKE) build

build: $(TARGETS)

install: build
	$(INSTALL) -d -m 755 $(bindir) &&    \
	$(INSTALL) -m 755 basl2c $(bindir) ; \
	$(INSTALL) -d -m 755 $(sbindir) &&   \
	$(INSTALL) -m 700 pbs_sched $(sbindir)

basl2c: $(OBJS_COMMON) $(OBJS_COMP)
	$(CC) $(CFLAGS) -o $@ $(OBJS_COMMON) $(OBJS_COMP) $(LIBRARIES)

pbs_sched: $(OBJS_COMMON) $(OBJS_SCHED)
	$(CC) $(CFLAGS) -o $@ $(OBJS_COMMON) $(OBJS_SCHED) $(LIBRARIES)

pbs_sched.o: $(SCHD_SRC) $(srcdir)/af_system.h $(srcdir)/af_server.h basl2c
	@if expr $(SCHD_SRC) : '.*\.basl$$' > /dev/null 2>&1; then \
	    echo Compiling BASL: $(SCHD_SRC) ;\
            echo         into C: pbs_sched.c ; \
	    echo ./basl2c $(SCHD_SRC) ; \
	    ./basl2c $(SCHD_SRC) ; \
	    $(CC) $(CFLAGS) -c pbs_sched.c ; \
	else \
	    $(CC) $(CFLAGS) -c $(SCHD_SRC) ; \
	fi


Lexer.o: y.tab.h
y.tab.h: Parser.o

# some of these files can be left behind if make is interrupted
clean::
	-(rm y.tab.* lex.yy.* pbs_sched.c; exit 0)

@mk_cleanup@
@mk_tail@

