/*
 * Imakefile for Mesa-library - src tree
 *
 * Author :  Michael Pichler
 *
 * created:  20 Mar 1995
 *
 * changed:  11 Feb 1997
 *
 */


#ifdef InObjectCodeDir

/* use SHM extension of X11 if possible */
/* requires ...include/X11/extensions/XShm.h */
/* programs using Mesa must then link Xext */
#ifndef AIX  /* missing functions in libXext.a */
#define UseX11SharedMemoryExtension
#endif

#ifdef UseX11SharedMemoryExtension
APP_CCDEFINES = -DSHM
#endif

/* switch to C mode */
UseGcc()

/* shared lib version */
REVISION = 2.1
APP_CCINCLUDES = -I$(SRC)/../include -I$(XINCDIR) /* also for make depend! */

/* take this line from delivered Makefile ... */
CORE_SOURCES = accum.c alpha.c alphabuf.c api.c attrib.c bitmap.c \
	blend.c bresenhm.c clip.c context.c copypix.c depth.c \
	dlist.c draw.c drawpix.c enable.c eval.c feedback.c fog.c \
	get.c interp.c image.c light.c lines.c logic.c \
	masking.c matrix.c misc.c pb.c pixel.c points.c pointers.c \
	polygon.c readpix.c scissor.c span.c stencil.c teximage.c \
	texobj.c texture.c triangle.c varray.c vb.c vertex.c winpos.c \
	xform.c

DRIVER_SOURCES = glx.c osmesa.c svgamesa.c \
	xfonts.c xmesa1.c xmesa2.c xmesa3.c

SOURCES = $(CORE_SOURCES) $(DRIVER_SOURCES)

OBJS = $(SOURCES:.c=.o)
SH_OBJS = $(OBJS)
/* no need to keep separate shared and non-shared object files */

OPTIMIZE_CCFLAGS=-O2
#ifndef HaveShared
SHARED_CCFLAGS=
#endif
APP_CCFLAGS=$(OPTIMIZE_CCFLAGS) $(SHARED_CCFLAGS)

/* patched version of the rule in hg-special.def (without shared subdir) */
#define NormalSharedLibraryTarget(libname,rev,depobjs,ldobjs)		@@\
AOUT_SH = Concat3(shared/,lib,libname.so.rev)				@@\
SHARED_CCLDLIBFLAGS = SharedCCLdLibFlags				@@\
S_OBJS = $(patsubst %.o,shared/%.o,ldobjs)				@@\
S_DEP_OBJS = $(patsubst %.o,shared/%.o,depobjs)				@@\
									@@\
AllTarget(Concat3(shared/,lib,libname.so.rev))				@@\
									@@\
Concat3(shared/,lib,libname.so.rev): $(S_DEP_OBJS)			@@\
	@echo "building $@"						@@\
	-@if [ -f $@ ] ; then \						@@\
	  	$(MV)  $@ $@~ ; \                              		@@\
	fi ;								@@\
	$(CCCMD) $(SHARED_CCLDLIBFLAGS) -o Concat(lib,libname.so.rev)  $(S_OBJS)	@@\
									@@\
clean::									@@\
	$(RM) Concat3(shared/,lib,libname.so.rev) 			@@\
	$(RM) $(S_OBJS)

/* static and shared lib version */
MakeHgLibrary(MesaGL,$(REVISION))
MakeSharedHgLibrary(MesaGL,$(REVISION))

/* Core */
MakeObjectFromSrc(accum)
MakeObjectFromSrc(alpha)
MakeObjectFromSrc(alphabuf)
MakeObjectFromSrc(api)
MakeObjectFromSrc(attrib)
MakeObjectFromSrc(bitmap)
MakeObjectFromSrc(blend)
MakeObjectFromSrc(bresenhm)
MakeObjectFromSrc(clip)
MakeObjectFromSrc(context)
MakeObjectFromSrc(copypix)
MakeObjectFromSrc(depth)
MakeObjectFromSrc(dlist)
MakeObjectFromSrc(draw)
MakeObjectFromSrc(drawpix)
MakeObjectFromSrc(enable)
MakeObjectFromSrc(eval)
MakeObjectFromSrc(feedback)
MakeObjectFromSrc(fog)
MakeObjectFromSrc(get)
/*MakeObjectFromSrc(hgcolors)*/
MakeObjectFromSrc(interp)
MakeObjectFromSrc(image)
MakeObjectFromSrc(light)
MakeObjectFromSrc(lines)
MakeObjectFromSrc(logic)
MakeObjectFromSrc(masking)
MakeObjectFromSrc(matrix)
MakeObjectFromSrc(misc)
MakeObjectFromSrc(pb)
MakeObjectFromSrc(pixel)
MakeObjectFromSrc(points)
MakeObjectFromSrc(pointers)
MakeObjectFromSrc(polygon)
MakeObjectFromSrc(readpix)
MakeObjectFromSrc(scissor)
MakeObjectFromSrc(span)
MakeObjectFromSrc(stencil)
MakeObjectFromSrc(teximage)
MakeObjectFromSrc(texobj)
MakeObjectFromSrc(texture)
MakeObjectFromSrc(triangle)
MakeObjectFromSrc(varray)
MakeObjectFromSrc(vb)
MakeObjectFromSrc(vertex)
MakeObjectFromSrc(winpos)
MakeObjectFromSrc(xform)

/* X11 device driver */
MakeObjectFromSrc(glx)
MakeObjectFromSrc(osmesa)
MakeObjectFromSrc(svgamesa)
MakeObjectFromSrc(xfonts)
MakeObjectFromSrc(xmesa1)
MakeObjectFromSrc(xmesa2)
MakeObjectFromSrc(xmesa3)


#else

MakeInObjectCodeDir()

Makefiles::
	-(cd $(ARCH); rmdir shared; rm -f shared; ln -s . shared)

#endif /* if compiling in subdirectory */
