XCOMM $XFree86: mit/server/ddx/x386/LinkKit/Imakefile.LK,v 1.20 1993/05/23 10:24:53 dawes Exp $
/*
 * Server Makefile for Link Kit
 */

#include <Server.tmpl>

#define StdLibs $(DIX) $(OS) $(MI) $(EXTENSIONS)
#define NoMFBLibs $(DIX) $(OS) $(FONT) $(MI) $(EXTENSIONS)
#define NoMFBBareLibs $(DIX) $(OS) $(FONT) $(MI)
#define MFBBareLibs $(DIX) $(OS) $(FONT) $(MFB) $(MI)
#define MFBLibs MFBBareLibs $(EXTENSIONS)
#define CFBBareLibs $(DIX) $(OS) $(FONT) $(CFB) $(MFB) $(MI)
#define CFBLibs CFBBareLibs $(EXTENSIONS)

#if BuildPexExt
         PEXLIBS = lib/libdidipex.a \
                   lib/libdiswapex.a \
                   lib/libdiobpex.a \
                   lib/libdidipex.a \
                   lib/libddpex4.a \
                   lib/libddpex3.a \
                   lib/libddpexs.a \
                   lib/libddpex2.a \
                   lib/libddpex1.a \
		   lib/libospex.a 
#endif
#if BuildXInputExt
      OTHEREXTS = lib/libxinput.a
#endif

     NONPEXEXTS = $(OTHEREXTS) lib/libext.a
     EXTENSIONS = $(NONPEXEXTS) $(PEXLIBS)
         XAULIB = lib/libXau.a
       XDMCPLIB = lib/libXdmcp.a
             OS = lib/libos.a $(XAULIB) $(XDMCPLIB)
        BSDEMUL = lib/Berklib.o
           FONT = lib/libfont.a $(RENDERERLIBS)
            DIX = lib/libdix.a
             MI = lib/libmi.a
            MFB = lib/libmfb.a
#if i386Mach
#ifdef i386Mach_BsdTree
   EXTRASYSLIBS = /usr/lib/libmach.a
#else
   EXTRASYSLIBS = /usr/misc/.mach/lib/libmach.a
#endif
#endif
#if HasSdbm
         DBMLIB = -lsdbm
#else
#if !i386Bsd
         DBMLIB = -ldbm
#endif
#endif
#if NeedLibGcc
         GCCLIB = -lgcc
#endif
        SYSLIBS = -lm $(DBMLIB) $(EXTRASYSLIBS) $(GCCLIB)
           CBRT = lib/cbrt.o

       IRULESRC = $(CONFIGDIR)

  IMAKE_DEFINES = -DX386LinkKit=1
      IMAKE_CMD = $(IMAKE) -DUseInstalled -I$(TOP)/$(NEWTOP) -I$(IRULESRC) \
                  $(IMAKE_DEFINES)
   ICONFIGFILES = $(IRULESRC)/Imake.tmpl $(IRULESRC)/Imake.rules \
		  $(IRULESRC)/Project.tmpl $(IRULESRC)/site.def \
			$(IRULESRC)/$(MACROFILE) $(EXTRA_ICONFIGFILES)
EXTRA_ICONFIGFILES = site.def X386Conf.tmpl
       INCLUDES = -Iinclude -Idrivers

XCOMM
XCOMM This turns off the default rule for compiling .c files because
XCOMM this makefile does not really know how to build it.  This is really
XCOMM just a hack because of the Sun version of make and nfs.
XCOMM

#if X386MonoServer
#if X386Server
ALL2 = XF86_Mono
#else
ALL1 = XF86_Mono
#endif
#endif

#if X386Server
ALL1 = XF86_SVGA
#endif

ALL = $(ALL1) $(ALL2)

all: $(ALL)

Configure:
	$(RM) Makefile.x386
	$(IMAKE_CMD) -DMakefileX386 -DInit -s Makefile.x386
	$(MAKE) $(MFLAGS) -f Makefile.x386 X386Conf.tmpl
	$(MAKE) $(MFLAGS) Makefile
	$(RM) Makefile.x386

#ifdef MakefileX386
#if X386MonoServer
#define X386Vga2Args VGA2DRIVER X386Vga2Drivers
#define X386Hga2Args HGA2DRIVER X386Hga2Drivers
#else
#define X386Vga2Args
#define X386Hga2Args
#endif
#if X386Server
#define X386VgaArgs VGADRIVER X386Vga256Drivers
#else
#define X386VgaArgs
#endif
X386Conf.tmpl::
	$(RM) $@
	$(SHELL) x386config.sh \
	  X386VgaArgs X386Vga2Args X386Hga2Args RENDERER FontRenderers
#endif

#ifndef Init
/*****************************************************************************
 *		  Build rule blocks, add one for each server                 *
 *****************************************************************************/

#if X386Server
XCOMM
XCOMM X386 server
XCOMM

#if BuildVga256
       SUBDIRS0 = drivers/vga256
#endif
       X386DIRS = $(SUBDIRS0)
#ifdef i386SVR3Architecture
    X386SYSLIBS = $(CBRT) $(BSDEMUL)
#endif
#ifdef LinuxArchitecture
    X386SYSLIBS = $(CBRT)
#endif
#if SpecialMalloc
  X386MALLOCLIB = /usr/local/lib/libdbmalloc.a
#endif
#if GnuMalloc
X386MALLOCLIB = -lgmalloc
#endif

      X386OBJS1 = lib/x386Init.o x386Conf.o $(X386CONFOBJS) rendererConf.o
      X386OBJS2 = lib/dixfonts.o lib/mibitblt.o
     X386VGALIB = $(VGAOBJS) drivers/libvga256.a
       X386LIBS = lib/libx386.a $(X386VGALIB) lib/libx386.a MFBLibs \
                  $(X386SYSLIBS) $(X386MALLOCLIB)
       X386OBJS = $(X386OBJS1) $(X386OBJS2)
   INSTPGMFLAGS = $(INSTUIDFLAGS)     /* server must be suid root  */
     VGADRIVERS = X386Vga256Drivers

reloadXF86_SVGA: $(CONFIGSRC)/X386Conf.tmpl
	@$(MAKE) $(MFLAGS) Makefile
	@$(MAKE) $(MFLAGS) DoReload

DoReload: x386Conf.o $(X386CONFOBJS) $(VGAOBJS) $(RENDERERLIBS) loadXF86_SVGA

SpecialObjectRule(x386Conf.o,$(ICONFIGFILES),$(X386SCREENFLAGS))

vga256Conf.c: $(ICONFIGFILES) confvga256.sh
	$(RM) $@
	$(SHELL) confvga256.sh $(VGADRIVERS)

clean::
	$(RM) vga256Conf.c

ServerTarget(XF86_SVGA,$(X386DIRS),$(X386OBJS),$(X386LIBS),$(SYSLIBS))

loadX386:
	@echo run \"make loadXF86_SVGA\"

#endif /* X386Server */


#if X386MonoServer
XCOMM
XCOMM X386mono server
XCOMM

#if BuildVga2
       SUBDIRS1 = drivers/vga2
#endif
#if BuildHga2
       SUBDIRS2 = drivers/hga2
#endif
      X386MDIRS = $(SUBDIRS1) $(SUBDIRS2)
#ifdef i386SVR3Architecture
    X386SYSLIBS = $(CBRT) $(BSDEMUL)
#endif
#ifdef LinuxArchitecture
    X386SYSLIBS = $(CBRT)
#endif
#if SpecialMalloc
  X386MALLOCLIB = /usr/local/lib/libdbmalloc.a
#endif
#if GnuMalloc
X386MALLOCLIB = -lgmalloc
#endif

     X386MOBJS1 = lib/x386Init_m.o x386Conf_m.o $(X386MCONFOBJS) \
                  rendererConf.o
     X386MOBJS2 = lib/dixfonts_m.o lib/mibitblt_m.o
#if BuildVga2
    X386MVGALIB = $(VGA2OBJS) drivers/libvga2.a
#endif
#if BuildHga2
    X386MHGALIB = $(HGA2OBJS) drivers/libhga2.a
#endif
      X386MLIBS = lib/libx386.a $(X386MVGALIB) $(X386MHGALIB) lib/libx386.a \
                  NoMFBBareLibs $(NONPEXEXTS) $(X386SYSLIBS) $(X386MALLOCLIB)
      X386MOBJS = $(X386MOBJS1) $(X386MOBJS2)
    VGA2DRIVERS = X386Vga2Drivers
    HGA2DRIVERS = X386Hga2Drivers
   INSTPGMFLAGS = $(INSTUIDFLAGS)     /* server must be suid root  */

vga2Conf.c: $(ICONFIGFILES) configvga2.sh
	$(RM) $@
	$(SHELL) configvga2.sh $(VGA2DRIVERS)

clean::
	$(RM) vga2Conf.c

hga2Conf.c: $(ICONFIGFILES) confhga2.sh
	$(RM) $@
	$(SHELL) confhga2.sh $(HGA2DRIVERS)

clean::
	$(RM) hga2Conf.c

SpecialObjectRule(x386Conf_m.o,x386Conf_m.c $(ICONFIGFILES),MonoDefines $(X386SCREENFLAGS))

x386Conf_m.c: x386Conf.c
	$(RM) $@
	$(LN) $? $@

depend:: x386Conf_m.c

clean::
	$(RM) x386Conf_m.c

reloadXF86_Mono: $(CONFIGSRC)/X386Conf.tmpl
	@$(MAKE) $(MFLAGS) Makefile
	@$(MAKE) $(MFLAGS) DoReloadMono

DoReloadMono: x386Conf.o $(X386CONFOBJS) $(VGA2OBJS) $(HGA2OBJS) \
              $(RENDERERLIBS) loadXF86_Mono

ServerTarget(XF86_Mono,$(X386MDIRS),$(X386MOBJS),$(X386MLIBS),$(SYSLIBS))

loadX386mono:
	@echo run \"make loadXF86_Mono\"

#endif /* X386MonoServer */

/* Common rules */
#if X386Server || X386MonoServer
$(CONFIGSRC)/X386Conf.tmpl: $(ICONFIGFILES)
	@echo Checking in $(CONFIGSRC)...
	@cd $(CONFIGSRC); set -x; $(MAKE) $(MFLAGS) Makefiles

    RENDERERS = FontRenderers

rendererConf.c: $(ICONFIGFILES) configrend.sh
	$(RM) $@
	$(SHELL) configrend.sh $(RENDERERS)

clean::
	$(RM) rendererConf.c

#endif

SUBDIRS = $(SUBDIRS0) $(SUBDIRS1) $(SUBDIRS2) $(SUBDIRS3)

InstallMultipleFlags($(ALL),$(BINDIR),$(INSTPGMFLAGS))

install::
	-(cd $(DESTDIR)$(BINDIR); $(RM) X; $(LN) $(ALL1) X)

#define IHaveSubdirs

DependSubdirs($(SUBDIRS))
MakeLintLibSubdirs($(SUBDIRS))
LintSubdirs($(SUBDIRS))

ForceSubdirs($(DEPDIRS) $(SUBDIRS))

clean::
	$(RM) $(ALL)

#endif /* Init */
