# $Id: makefile.src,v 1.8 1997/07/31 09:43:27 digulla Exp $
TOP=../../..
CURDIR=workbench/libs/diskfont

USER_INCLUDES = -I..

include $(TOP)/config/make.cfg

# Main function for diskfont.library. Need this apart as an anchor for the link:
INIT_FILE = diskfont_init

FILES = diskfont_functable af_copyfontstobuffer af_scanfontinfo \
	af_fontcache_io af_fontdescr_io memoryfontfunc diskfontfunc \
	dosstreamhook af_helpfuncs diskfont_io

# Guarantee that this will go at the end of the file:
END_FILE = diskfont_endtag

FUNCTIONS = \
	opendiskfont	    \
	availfonts	    \
	newfontcontents     \
	disposefontcontents \
	newscaleddiskfont

OBJDIR=$(GENDIR)/workbench/libs/diskfont

OBJS = $(foreach f,$(FILES) $(FUNCTIONS),$(OBJDIR)/$(f).o)

# The init and endskip object filenames
INITFUNC = $(OBJDIR)/$(INIT_FILE).o
ENDFUNC = $(OBJDIR)/$(END_FILE).o

all: setup $(SLIBDIR)/diskfont.library

# ***** Native ***************
ifeq ($(FLAVOUR),native)

# Generate a map file
MAPGEN = -Xlinker -M

# Strip resulting binary
STRIP = strip

# ***** Not Native ***************
else

MAPGEN =
STRIP = true

# ***** END ***************
endif

%define_libs prelibs=-ldiskfont

# The filename of the linklib
LIB=$(LIBDIR)/libdiskfont.a

$(SLIBDIR)/diskfont.library: $(LIB) $(DEPLIBS) $(OBJS) $(INITFUNC) $(ENDFUNC)
	@echo "Building $(notdir $@) ..."
	@$(CC) $(ILDFLAGS) $(MAPGEN) $(INITFUNC) $(LIBS) $(ENDFUNC) -o $@ 2>&1|tee diskfontlib.map
	%checkuds
	@if test ! -s diskfontlib.map; then rm diskfontlib.map ; else true ; fi
	@$(STRIP) $@

# Collect all functions in a linklib for fast linking:
$(LIB): $(OBJS)
	@echo "Adding functions to $(notdir $@) ..."
	@$(AR) $@ $?
	@$(RANLIB) $@

setup :
	@echo "CFLAGS=$(CFLAGS)"
	%mkdirs_q $(OBJDIR) $(SLIBDIR)

clean::
	$(RM) $(OBJDIR) *.err

$(OBJDIR)/%.o: %.c
	%compile_q

diskfont_functable.c : $(foreach f,$(FUNCTIONS),$(f).c) \
	    $(TOP)/scripts/makefunctable.awk
	%mkfunctable_q Diskfont

diskfont_endtag.c: $(TOP)/scripts/makeendtag.awk
	%mkendtag_q Diskfont

$(OBJDIR)/diskfont_init.o: libdefs.h

%libdefs_rule

$(OBJDIR)/%.d: %.c
	%mkdepend_q

%common
%include_deps $(foreach f,$(INIT_FILE) $(END_FILE) $(FILES) $(FUNCTIONS),$(OBJDIR)/$(f).d)
