#
# Copyright (c) 1997, 1999 The University of Utah and
# the Computer Systems Laboratory at the University of Utah (CSL).
#
# This file is part of Flick, the Flexible IDL Compiler Kit.
#
# Flick is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Flick is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Flick; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place #330, Boston, MA 02111, USA.
#

## FLICK CONFIGURATION.

# Set this to your Flick source tree.
SRCDIR		= /home/users/barneyrubble/flick-src
# Set this to your Flick object directory.
OBJDIR		= /home/users/barneyrubble/flick-obj

# The Flick stubs need header files from the Flick source and object trees, if
# Flick hasn't already been installed.
CPPFLAGS	= -I$(OBJDIR)/runtime/headers \
		  -I$(SRCDIR)/runtime/headers

# The default C compiler to use for compiling and linking.
CC		= gcc

###############################################################################

## MACROS THAT DESCRIBE WHAT WE ARE BUILDING.

IDL_FILES	= phone.idl

CLIENT		= phonebook
CLIENT_OBJS	= phonebook.o phone-client.o

SERVER		= phoneserver
SERVER_OBJS	= phone-workfuncs.o phone-server.o

# The set of files generated by Flick.  Removed by `make clean'.
FLICK_GEN_FILES	= $(strip \
			$(foreach file,$(IDL_FILES),\
				$(addprefix $(basename $(file)),\
					.aoi .aod \
					-client.prc -client.prd \
					-server.prc -server.prd \
					-client.c -client.h \
					-server.c -server.h)))

###############################################################################

## HOW TO BUILD CORBA C STUBS AND SKELETONS USING FLICK.

# The Flick programs.
FLICK_FE		= $(OBJDIR)/bin/flick-fe-newcorba
FLICK_PG		= $(OBJDIR)/bin/flick-c-pfe-corba
FLICK_BE		= $(OBJDIR)/bin/flick-c-pbe-iiop

# The Flick front end options.
FLICK_FE_FLAGS		=

# The Flick presentation generator options.
FLICK_PG_FLAGS		=
FLICK_PG_CLIENT_FLAGS	= $(FLICK_PG_FLAGS) -c
FLICK_PG_SERVER_FLAGS	= $(FLICK_PG_FLAGS) -s

# The Flick back end options.  We must tell Flick where to find the templates
# for code generation (the SCML files), since we do not assume Flick is
# installed.  We use `--nostdinc -I ...' to direct Flick to the right place.

FLICK_BE_FLAGS		= --nostdinc -I $(SRCDIR)/runtime/headers/flick/pres
FLICK_BE_CLIENT_FLAGS	= $(FLICK_BE_FLAGS)
FLICK_BE_SERVER_FLAGS	= $(FLICK_BE_FLAGS)

# The Flick library directory and appropriate runtime library.
FLICK_LIBS		= -L$(OBJDIR)/lib -lflick-iiop

##

%.aoi: %.idl
	$(FLICK_FE) $(FLICK_FE_FLAGS) -o $@ $<

%-client.prc: %.aoi
	$(FLICK_PG) $(FLICK_PG_CLIENT_FLAGS) -o $@ $<

%-server.prc: %.aoi
	$(FLICK_PG) $(FLICK_PG_SERVER_FLAGS) -o $@ $<

%-client.c %-client.h: %-client.prc
	$(FLICK_BE) $(FLICK_BE_CLIENT_FLAGS) -h $*-client.h -o $*-client.c $<

%-server.c %-server.h: %-server.prc
	$(FLICK_BE) $(FLICK_BE_SERVER_FLAGS) -h $*-server.h -o $*-server.c $<

.PRECIOUS:	%.aoi \
		%-client.prc %-server.prc \
		%-client.c %-client.h %-server.c %-server.h

###############################################################################

## HERE ARE THE GENERIC TOP-LEVEL TARGETS (`all', `clean', ...).

.PHONY: all
all:	$(CLIENT) $(SERVER)

.PHONY: clean
clean:
	$(RM) $(FLICK_GEN_FILES) \
	      $(sort $(CLIENT_OBJS) $(SERVER_OBJS)) \
	      $(CLIENT) $(SERVER)

## HERE ARE THE SPECIFIC TOP-LEVEL TARGETS.

$(SERVER): $(SERVER_OBJS)
	$(CC) $(LDFLAGS) -o $@ $^ $(FLICK_LIBS)

$(CLIENT): $(CLIENT_OBJS)
	$(CC) $(LDFLAGS) -o $@ $^ $(FLICK_LIBS)

###############################################################################

## INDIVIDUAL FILE DEPENDENCIES.

phonebook.o: phone-client.h phone-client.c

phone-workfuncs.o: phone-server.h phone-server.c

###############################################################################

## End of file.

