/*
 * This Imakefile does many things:
 * - all
 * - clean
 * - collect
 * - 
 */

#include "../config/crossfire.tmpl"

INCLUDES = -I../include

/* LOCAL_LDFLAGS = -L../common /* SGI doesn't understand this */
LOCAL_LIBRARIES = -L../common -lcross

FILES = \
	archetypes \
	treasures \
	bmaps \
	bmaps.paths \
	$(FONTNAME).cfb \
	$(FONTNAME).bdf \
	collect.pl \
	util.pl \
	xbmtobdf.c \
	motd

LIBFLAGS = -m 0644

DEFINES = -DFONTDIR=\"${FONTDIR}\" -DFONTNAME=\"$(FONTNAME)\" $(TARGET) \
	-DLIBDIR=\"$(C_LIBDIR)\" $(COMPRESS_DEF)

OBJS = xbmtobdf.o

SRCS = xbmtobdf.c

PROGRAMS = xbmtobdf

#ifdef OWIN
FONTTARGET = $(FONTNAME)24.fb
FONTDIRCMD = bldfamily -d
#else
FONTTARGET = $(FONTNAME).$(FONTTYPE)
FONTDIRCMD = mkfontdir
#endif

#

AllTarget($(FILES) $(FONTTARGET))

#define BINDIR C_BINDIR
ComplexProgramTarget(xbmtobdf)
#undef BINDIR

$(FONTNAME).bdf: xbmtobdf bmaps.paths
	$(RM) $(FONTNAME).bdf $(FONTNAME).$(FONTTYPE)
	./xbmtobdf -name $(FONTNAME) -f bmaps.paths -d . > $(FONTNAME).bdf

$(FONTNAME).cfb: xbmtobdf bmaps.paths
	$(RM) -f $(FONTNAME).cfb
	./xbmtobdf -f bmaps.paths -d . -b > $(FONTNAME).cfb

$(FONTNAME)24.fb: $(FONTNAME).bdf
	convertfont $(FONTNAME).bdf

$(FONTNAME).$(FONTTYPE): $(FONTNAME).bdf
	bdfto$(FONTTYPE) < $(FONTNAME).bdf > $(FONTNAME).$(FONTTYPE)

install:: $(FONTTARGET)
	MakeDir($(FONTDIR))
	$(CP) $(FONTTARGET) $(FONTDIR)
/*	$(CP) $(FONTNAME).bdf $(FONTDIR) */
	$(FONTDIRCMD) $(FONTDIR)
	chmod a+r $(FONTDIR)/fonts.dir $(FONTDIR)/$(FONTTARGET)

/***  ***/

.collect-stamp: 
	touch .collect-stamp

collect: 
	perl collect.pl ./arch

archetypes: .collect-stamp
	make collect

bmaps.paths bmaps: .collect-stamp
	make collect

InstallMultipleDestFlags(install,$(FILES),$(C_LIBDIR),$(LIBFLAGS))

install::
	MakeDir($(C_LIBDIR)/players)

install::
	cp -R ./maps $(C_LIBDIR)

clean::
	$(RM) $(FONTNAME).snf $(FONTNAME).pcf $(FONTNAME)24.fb

real-clean::
	$(RM) $(FONTNAME).bdf  $(FONTNAME).cfb
	$(RM) archetypes bmaps .collect-stamp

InsertArchieve(Imakefile README $(FILES),lib)

#ifndef ArchiveNoArch
subarchieve::
	MakeDir($(ATOP)/lib/arch)
	cp -R ./arch $(ATOP)/lib
#endif

subarchieve::
	MakeDir($(ATOP)/lib/maps/editor)
	cp -R ./maps/editor $(ATOP)/lib/maps

/**********************************************************************
 * lib-packet: archetypes, treasures
 **********************************************************************/

libArch:
	tar cvf A`perl puredate.pl`.tar arch treasures
	gzip A`perl puredate.pl`.tar

/*** end of Imakefile ***/
