# ###############################################################
#
#                SWServ Plugin Samples Makefile
#

# ###############################################################
#
# Prefix:
#
#   This should be the location of the SWServ toplevel directory.
#
#   The plugins will be installed in $TOPLEVEL/plugins
#
PREFIX = /home/swserv

# Compiler:
#
CC = cc
CPP = cpp

# Compiler Flags:
#
#   The -shared flag should be specified in order to instruct the
#   compiler to compile as a shared library (a plugin).
#
CFLAGS = -O2 -g -ffast-math -Wall -shared

# Libraries:
#
LIBS =

# Library Directories:
#
LIB_DIR =

# Header File Directories:
#
INC =

# Programs
#
LS      = ls
LSFLAGS = -s -h -c --color=auto
RM      = rm
RMFLAGS = -f


# ###############################################################
#
# Source List:
#
# Each source file is a module for a plugin.
#
SRC_C = borg.c ctf.c hellouniverse.c command.c			\
        defense_station.c destroy_notify.c dom_fighter.c	\
        eco_inflation.c fighter.c freighter.c hail_notify.c	\
        hit_notify.c moveobj.c probe.c rbop.c tholian_spinner.c	\
        timming.c wow.c


# ###############################################################
#
# Build rules:
#

SO_C = $(SRC_C:.c=.o)
.c.o:
	@echo "Compiling plugin $*.so"
	@+$(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $*.c -o $*.so

#	@echo -n "Compiling plugin $*.so"
#	@+$(CC) $(CFLAGS) $(LIB_DIR) $(LIBS) $*.c -o $*.so
#	@echo -n "   "                                           
#	@-$(LS) $(LSFLAGS) $*.so


plugins: $(SO_C)

all: $(SRC_C)


# ###############################################################
#
# Install Rules:
#
INSTALL      = install
INSTBINFLAGS = -m 0755
INSTUIDFLAGS = -m 4755
INSTLIBFLAGS = -m 0755
INSTINCFLAGS = -m 0444
INSTMANFLAGS = -m 0444
INSTDATFLAGS = -m 0444

COPY      = cp
COPYFLAGS = -i -v

MKDIR      = mkdir
MKDIRFLAGS = -p

PLUGINS_DIR = $(PREFIX)/plugins

install:
	$(MKDIR) $(MKDIRFLAGS) $(PLUGINS_DIR)
	$(INSTALL) $(INSTBINFLAGS) hellouniverse $(PLUGINS_DIR)
	$(INSTALL) $(INSTBINFLAGS) command $(PLUGINS_DIR)
	$(INSTALL) $(INSTBINFLAGS) moveobj $(PLUGINS_DIR)
	$(INSTALL) $(INSTBINFLAGS) timming $(PLUGINS_DIR)
	@echo "---------------------------------------------------------------"
	@echo "Plugins have been installed in:"
	@echo " "
	@echo "        $(PLUGINS_DIR)"
	@echo " "


# ###############################################################
#
# Maintainance and Misc Rules:
#
clean:
	@echo "Deleting all intermediate and output files..."
	@$(RM) $(RMFLAGS) a.out core *.o *.so
	@echo "Clean done."


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