/* Makefile for GNU Emacs.
   Copyright (C) 1985, 1987, 1988, 1990 Free Software Foundation, Inc.

This file is part of GNU Emacs.

GNU Emacs is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.

GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Emacs; see the file COPYING.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* 87.7.15  modified by K.Handa */
/* 87.6.9   modified by K.Handa */
/* 88.1.15  modified for Nemacs Ver.2.0 by K.Handa */
/* 89.11.20 modified for Nemacs Ver.3.2 by K.Handa */
/* 89.12.12 modified for Nemacs Ver.3.2.1 by K.Handa
	'make-docfile' concerns kanji.o and wnnfns.o. */
/* 90.2.27  modified for Nemacs Ver.3.3.1 by K.Handa
	add dependency on puresize.h and nconfig.h to alloc.c and data.c
	change definition of WNNLIB and WNNINC */
/* 90.9.21  modified for Nemacs Ver.3.3.3 by K.Handa
	To make Emacs works directly on Sun's console screen. */
/* 91.11.1  modified for Nemacs Ver.4.0.0 by K.Handa <handa@etl.go.jp> */
/* 92.3.6   modified for Mule Ver.0.9.0 by K.Handa <handa@etl.go.jp> */
/* 92.3.23  modified for Mule Ver.0.9.1 by T.Sakakibara <tomo@axis.co.jp>
	wnnfns.c and alloc.c depends on mule-config.h, data.c not. */
/* 92.3.25  modified for Mule Ver.0.9.2 by K.Handa <handa@etl.go.jp>
	Place of defining WNNLIB... is moved after '#undef X11'.
	Define MULE_OBJ in case EGG is not defined.
	emacs.c also depends on mule-config.h. */
/* 92.3.31  modified for Mule Ver.0.9.2 by K.Handa <handa@etl.go.jp>
	Sun console feature added. */
/* 92.4.1   modified for Mule Ver.0.9.2 by K.Handa <handa@etl.go.jp>
	Now search.o depends on mule.h. */
/* 92.4.7   modified for Mule Ver.0.9.3 by K.Handa <handa@etl.go.jp>
	All .el files created newly or patched are byte-compiled. */
/* 92.4.16  modified for Mule Ver.0.9.3 by K.Handa <handa@etl.go.jp>
	Only necessary .el files are byte-compiled. */
/* 92.5.18  modified for Mule Ver.0.9.4 by T.Shingu <shingu@cpr.canon.co.jp>
	Now WNN4 is supported. */
/* 92.7.8   modified for Mule Ver.0.9.5 by K.Handa <handa@etl.go.jp>
	Support for WNN3 and WNN4V3 stopped. */
/* 92.7.8   modified for Mule Ver.0.9.5 by Y.Kawabe <kawabe@sramhc.sra.co.jp>
	Support for SJ3 started. */
/* 92.7.30  modified for Mule Ver.0.9.5 by K.Handa <handa@etl.go.jp>
	Support for CANNA started. */
/* 92.7.30  modified for Mule Ver.0.9.5
		by H.Ogata <mj1015@capricorn.cse.kyutech.ac.jp>
	MULE_ELC_PATCHED is augmented. */
/* 92.7.31  modified for Mule Ver.0.9.5 by K.Handa <handa@etl.go.jp>
	Convention of Mule-oriented definitions changed. */
/* 92.8.5   modified for Mule Ver.0.9.5.1 by M.Minda <minmin@astec.co.jp>
	More support for CANNA. */
/* 92.8.10  modified for Mule Ver.0.9.5 by K.Handa <handa@etl.go.jp>
	keyboard.elc is appended to MULE_ELC_BASE */
/* 92.8.11  modified for Mule Ver.0.9.6 by Y.Niibe <gniibe@mri.co.jp>
	There should be no dependency in target .el.elc:. */
/* 92.8.11  modified for Mule Ver.0.9.6 by T.Shingu <shingu@cpr.canon.co.jp>
	EGG supports cserver. */
/* 92.10.14 modified for Mule Ver.0.9.6 by K.Handa <handa@etl.go.jp>
	sunterm.c uses bdfstaff. */
/* 92.10.16 modified for Mule Ver.0.9.6 with DOS suppert 
		by M.Higashida <manabu@sigmath.osaka-u.ac.jp> */
/* 92.10.26 modified for Mule Ver.0.9.6 by T.Saneto <sanewo@pdp.crl.sony.co.jp>
	Macro MULE_LIB_EXT is used for LIBWNN. */
/* 92.11.22 modified for Mule Ver.0.9.7 by K.Handa <handa@etl.go.jp>
	Change of the way to byte-compile ${MULE_ELC_PATCHED}.
	Change of the way to create ${etcdir}charsets.
	Change of the way to compile ${etcdir}bdf.c. */
/* 92.11.30 modified for Mule Ver.0.9.7 by K.Handa <handa@etl.go.jp>
	Name change mule-config.h -> mconfig.h-dist */
/* 93.1.3   modified for Mule Ver.0.9.7.1 by K.Handa <handa@etl.go.jp>
	Always try to byte-compile ${MULE_ELC_PATCHED}. */
/* 93.2.10  modified for Mule Ver.0.9.7.1 by K.Handa <handa@etl.go.jp>
	sendmail.elc is in MULE_ELC_PATCHED.
	Targe .el.elc is added.  Defining SUFFIX_BUG suppresses using it. */
/* 93.5.12  modified for Mule Ver.0.9.8 by T.Enami <enami@sys.ptg.sony.co.jp>
	Support MCPATH. */
/* 93.5.14  modified for Mule Ver.0.9.8 by K.Handa <handa@etl.go.jp>
	CCL support. */
/* 93.6.17  modified for Mule Ver.0.9.8 by T.Atsushiba<toshiki@jit.dec-j.co.jp>
	dabbrev.elc is in MULE_ELC_PATCHED. */
/* 93.6.25  modified for Mule Ver.0.9.8 by K.Handa <handa@etl.go.jp>
	Name change: charsets -> charset */
/* 93.7.27  modified for Mule Ver.0.9.8 by K.Handa <handa@etl.go.jp>
	$(MULE_LIB) should be at the first of $(LIBES). */

dot = .
/* on Xenix, replace double-dot below with $(dot)$(dot) */
lispdir = $(dot)$(dot)/lisp/
etcdir = $(dot)$(dot)/etc/
shortnamesdir = $(dot)$(dot)/shortnames/
cppdir = $(dot)$(dot)/cpp/
oldXMenudir = $(dot)$(dot)/oldXMenu/

/* Just to avoid uncertainty.  */
SHELL = /bin/sh

#define NO_SHORTNAMES
#include "config.h"

/* 92.10.21 by M.Higashida */
#ifdef MSDOS
# ifdef GO32
supportdosdir = $(dot)$(dot)/dos/go32/
# else /* not GO32 */
#  ifdef EMX
supportdosdir = $(dot)$(dot)/dos/emx/
#  endif /* EMX */
# endif /* not GO32 */
gcclibdir = GCC_LIBDIR  /* defined in `s-' file. */

.SUFFIXES: .c.o.s

.c.o:
	$(CC) $(CFLAGS) -c $<


/* Should to change directory with `/' separater. */
#if unix
CD=cd
#else
CD=chd
#endif
#else /* not MSDOS */
CD=cd
#endif /* not MSDOS */
/* end of patch */

/* Use HAVE_X11 as an alias for X11 in this file
   to avoid problems with X11 as a subdirectory name
   in -I and other such options which pass through this file. */

#ifdef X11
#define HAVE_X11
#undef X11
#endif

/* 90.2.27, 92.2.6, 92.3.25, 92.7.31  patch by K.Handa */
#include "mconfig.h"
/* end of patch */

/* On some machines #define register is done in config;
   don't let it interfere with this file.  */
#undef register

/* On some systems we may not to use the system make command. */
#ifdef MAKE_COMMAND
MAKE = MAKE_COMMAND
#else
MAKE=make
#endif

#ifdef C_COMPILER
CC = C_COMPILER
#endif

/* Some machines don't find the standard C libraries in the usual place.  */
#ifndef ORDINARY_LINK
#ifndef LIB_STANDARD
#define LIB_STANDARD -lc
#endif
#else
#ifndef LIB_STANDARD
#define LIB_STANDARD
#endif
#endif

/* Unless inhibited or changed, use -lg to link for debugging.  */
#ifndef LIBS_DEBUG
#define LIBS_DEBUG -lg
#endif

/* Some s- files define this to request special libraries.  */
#ifndef LIBS_SYSTEM
#define LIBS_SYSTEM
#endif

/* Some m- files define this to request special libraries.  */
#ifndef LIBS_MACHINE
#define LIBS_MACHINE
#endif

/* Some s- files define this to request special switches in ld.  */
#ifndef LD_SWITCH_SYSTEM
#if defined (BSD) && !defined (COFF) && !defined (__GNUC__)
#define LD_SWITCH_SYSTEM -X
#else
#define LD_SWITCH_SYSTEM
#endif /* COFF, or not BSD */
#endif

/* Some m- files define this to request special switches in ld.  */
#ifndef LD_SWITCH_MACHINE
#define LD_SWITCH_MACHINE
#endif

/* Some m- files define this to request special switches in cc.  */
#ifndef C_SWITCH_MACHINE
#define C_SWITCH_MACHINE
#endif

#ifndef C_SWITCH_SYSTEM
#define C_SWITCH_SYSTEM
#endif

#ifndef C_SWITCH_X_MACHINE
#define C_SWITCH_X_MACHINE
#endif

#ifndef C_SWITCH_X_SYSTEM
#define C_SWITCH_X_SYSTEM
#endif

#ifndef ORDINARY_LINK
#ifndef START_FILES
#ifdef NO_REMAP
#define START_FILES pre-crt0.o /lib/crt0.o
#else
#define START_FILES crt0.o
#endif
#endif /* have START_FILES */
STARTFILES = START_FILES
#else  /* ORDINARY_LINK */
STARTFILES = pre-crt0.o
#endif /* ORDINARY_LINK */

/* This macro says how to compile for debugging.
   If you want to optimize, DON'T change this macro.
   Instead, replace C_DEBUG_SWITCH with C_OPTIMIZE_SWITCH
   where CFLAGS is set.  */
#ifndef C_DEBUG_SWITCH
#define C_DEBUG_SWITCH -g
#endif

/* If user wants to optimize, this is how.  */
#ifndef C_OPTIMIZE_SWITCH
#define C_OPTIMIZE_SWITCH -O
#endif

/* cc switches needed to make `asm' keyword work.
   Nothing special needed on most machines.  */
#ifndef C_SWITCH_ASM
#define C_SWITCH_ASM
#endif

/* Specify address for ld to start loading at,
   if requested by configuration.  */

#ifdef LD_TEXT_START_ADDR
STARTFLAGS = -T LD_TEXT_START_ADDR -e __start
#endif

#ifndef LINKER
#ifdef ORDINARY_LINK
LD = $(CC)
#else /* not ORDINARY_LINK */
#if __GNUC__ > 1
/* Search the proper places so that we can find -lgcc.  */
#define LINKER gcc -nostdlib
#else
#define LINKER ld
#endif 
#endif /* not ORDINARY_LINK */
#endif /* no LINKER */

#ifdef LINKER
LD = LINKER
#endif
LDFLAGS = LD_SWITCH_SYSTEM LD_SWITCH_MACHINE

/* Figure out whether the system cpp can handle long names.
   Do it by testing it right now.
   If it loses, arrange to use the GNU cpp.  */

#define LONGNAMEBBBFOOX
#ifdef LONGNAMEBBBARFOOX
/* Installed cpp fails to distinguish those names!  */
/* Arrange to compile the GNU cpp later on */
#define NEED_CPP
/* Cause cc to invoke the cpp that comes with Emacs,
   which will be in a file named localcpp.  */
MYCPPFLAG= -Blocal
/* LOCALCPP is the local one or nothing.
   CPP is the local one or the standardone.  */
LOCALCPP= localcpp
#endif /* NEED_CPP */

#ifdef SHORTNAMES
SHORT= shortnames
#endif /* SHORTNAMES */

CFLAGS= C_DEBUG_SWITCH -Demacs $(MYCPPFLAG) C_SWITCH_MACHINE C_SWITCH_SYSTEM \
 C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM $(MCPATH_FLAGS)
/* DO NOT use -R.  There is a special hack described in lastfile.c
   which is used instead.  Some initialized data areas are modified
   at initial startup, then labeled as part of the text area when
   Emacs is dumped for the first time, and never changed again. */

/* You may replace C_DEBUG_SWITCH with C_OPTIMIZE_SWITCH
   if you don't believe in debugging. */

/* -Demacs is needed to make some files produce the
   correct version for use in Emacs.  */

#ifndef LIBX10_MACHINE
#define LIBX10_MACHINE
#endif

#ifndef LIBX11_MACHINE
#define LIBX11_MACHINE
#endif

#ifndef LIBX10_SYSTEM
#define LIBX10_SYSTEM
#endif

#ifndef LIBX11_SYSTEM
#define LIBX11_SYSTEM
#endif

#ifndef LIB_X11_LIB
#define LIB_X11_LIB -lX11
#endif

#ifdef HAVE_X_WINDOWS
#ifdef HAVE_X11
#ifdef HAVE_X_MENU
OLDXMENU = libXMenu11.a
XOBJ = x11term.o x11fns.o xmenu.o
LIBX = $(OLDXMENU) LIB_X11_LIB LIBX11_MACHINE LIBX11_SYSTEM
#else
XOBJ = x11term.o x11fns.o
LIBX = LIB_X11_LIB LIBX11_MACHINE LIBX11_SYSTEM
#endif
#else /* not HAVE_X11 */
#ifdef HAVE_X_MENU
XOBJ= xterm.o xfns.o xmenu.o
LIBX= -lXMenu -lX LIBX10_MACHINE LIBX10_SYSTEM
#else
XOBJ= xterm.o xfns.o
LIBX= -lX LIBX10_MACHINE LIBX10_SYSTEM
#endif /* not HAVE_X_MENU */
#endif /* not HAVE_X11 */
#endif /* HAVE_X_WINDOWS */

/* 92.3.31 by K.Handa */
#ifdef HAVE_SUN_CONSOLE
SUNOBJ = sunterm.o ${etcdir}bdf.o
LIBSUN = -lpixrect
#endif
/* end of patch */

/* 92.10.21 by M.Higashida */
#ifdef MSDOS
SUPPORTDOS= $(supportdosdir)libdos.a
# ifdef HAVE_VGA_ADAPTER
DOSOBJ= dosfns.o vgaterm.o ${etcdir}bdf.o
LIBDOS= $(SUPPORTDOS) -lgrx
# else /* not HAVE_VGA_ADAPTER */
DOSOBJ= dosfns.o
LIBDOS = $(SUPPORTDOS)
# endif /* not HAVE_VGA_ADAPTER */
#endif /* MSDOS */
/* end of patch */

/* Fix linking if compiled with GCC.  */
#ifdef __GNUC__
#if __GNUC__ > 1
#ifndef LIB_GCC
#define LIB_GCC -lgcc
#endif
GNULIB_VAR = LIB_GCC
#else /* __GNUC__ <= 1 */
#ifndef LIB_GCC
#define LIB_GCC /usr/local/lib/gcc-gnulib
#endif
GNULIB_VAR = `if [ -f LIB_GCC ] ; then echo LIB_GCC; else echo; fi`
#endif /* __GNUC__ <= 1 */
#else
GNULIB_VAR = 
#endif

#ifdef MAINTAIN_ENVIRONMENT
environobj = environ.o
#endif /* MAINTAIN_ENVIRONMENT */

/* Allow config.h to specify a replacement file for unexec.c.  */
#ifndef UNEXEC
#define UNEXEC unexec.o
#endif

/* 92.7.31 by K.Handa */
/* Mule specific definitions. */
/* 89.3.23, 90.2.28, 92.2.6 by K.Handa, 92.5.18 by T.Shingu */
MULE_H = mule.h
CC_H = codeconv.h
/* 93.5.14 by K.Handa */
MULE_OBJ_BASE = mule.o codeconv.o category.o ccl.o
MULE_ELC_BASE = \
	${lispdir}mule.elc ${lispdir}mule-util.elc ${lispdir}attribute.elc \
	${lispdir}kinsoku.elc ${lispdir}quail.elc ${lispdir}trex.elc \
	${lispdir}keyboard.elc ${lispdir}ccl.elc ${lispdir}worddef.elc
MULE_LIB_BASE =

/* 92.7.8 by K.Handa and Y.Kawabe */
#ifdef WNN4
MULE_OBJ_EXT = wnn4fns.o	/* 92.5.18 by T.Shingu */
MULE_ELC_EXT = ${lispdir}egg.elc ${lispdir}wnn4-egg.elc
MULE_LIB_EXT = LIBWNN		/* 92.10.26 by T.Saneto */
WNNINC = INCWNN
#else  /* not WNN4 */
#ifdef SJ3
MULE_ELC_EXT = ${lispdir}egg.elc ${lispdir}sj3-client.elc ${lispdir}sj3-egg.elc
#else  /* not WNN4, not SJ3 */
#ifdef CANNA			/* 92.7.30 K.Handa */
MULE_OBJ_EXT = canna.o
MULE_ELC_EXT = ${lispdir}canna.elc
#ifdef CANNA2			/* 92.8.5 by M.Minda */
MULE_LIB_EXT  = LIBCANNA2
CANNAINC = INCCANNA2
#else
MULE_LIB_EXT  = LIBCANNA
CANNAINC = INCCANNA
#endif /* not CANNA2 */
#endif /* CANNA */
#endif /* not SJ3 */
#endif /* not WNN4 */

#ifndef MCPATH
MCPATH_FLAGS =
MCPATH_H =
#else /* MCPATH */
MCPATH_OBJ = mcpath.o
MCPATH_FLAGS = -DMCPATH -I./mcpath/include
MCPATH_H = mcpath.h
#endif /* MCPATH */

#ifdef MSDOS
MULE_ELC_EXT = ${lispdir}demacs.elc ${lispdir}dos-fns.elc ${lispdir}fepctrl.elc
#endif

MULE_OBJ = $(MULE_OBJ_BASE) $(MULE_OBJ_EXT)
MULE_ELC = $(MULE_ELC_BASE) $(MULE_ELC_EXT)
MULE_LIB = $(MULE_LIB_BASE) $(MULE_LIB_EXT)
/* 92.4.6 by K.Handa, 92.7.30 by H.Ogata */
/* List of lisp files to be 'bytecompile'd again. */
MULE_ELC_PATCHED = $(MULE_ELC) \
	${lispdir}bytecomp.elc ${lispdir}debug.elc ${lispdir}files.elc \
	${lispdir}fill.elc ${lispdir}info.elc ${lispdir}isearch.elc \
	${lispdir}picture.elc ${lispdir}startup.elc ${lispdir}replace.elc \
	${lispdir}rmail.elc ${lispdir}simple.elc ${lispdir}texinfmt.elc \
	${lispdir}dired.elc ${lispdir}macros.elc ${lispdir}man.elc \
	${lispdir}sendmail.elc ${lispdir}dabbrev.elc\
	${lispdir}prolog.elc ${lispdir}x-mouse.elc ${lispdir}compile.elc
/* end of patch */

/* lastfile must follow all files
   whose initialized data areas should be dumped as pure by dump-emacs. */
/* 91.11.1, 92.3.31 by K.Handa, 92.10.21 by M.Higashida */
obj=    dispnew.o scroll.o xdisp.o window.o \
	term.o cm.o $(XOBJ) $(SUNOBJ) $(DOSOBJ) \
	emacs.o keyboard.o macros.o keymap.o sysdep.o \
	buffer.o filelock.o insdel.o marker.o \
	minibuf.o fileio.o dired.o filemode.o \
	cmds.o casefiddle.o indent.o search.o regex.o undo.o \
	alloc.o data.o doc.o editfns.o callint.o \
	eval.o fns.o print.o lread.o \
	abbrev.o syntax.o UNEXEC mocklisp.o bytecode.o \
	process.o callproc.o $(environobj) \
	doprnt.o \
	$(MULE_OBJ) $(MCPATH_OBJ)

#ifdef TERMINFO
/* Used to be -ltermcap here.  If your machine needs that,
   define LIBS_TERMCAP in the m- file.  */
#ifndef LIBS_TERMCAP
#define LIBS_TERMCAP -lcurses
#endif
termcapobj = terminfo.o
#else
#ifndef LIBS_TERMCAP
#define LIBS_TERMCAP
termcapobj = termcap.o tparam.o
#else
termcapobj = tparam.o
#endif
#endif

#ifndef SYSTEM_MALLOC
#ifdef HAVE_ALLOCA
mallocobj = malloc.o
#else
mallocobj = alloca.o malloc.o
#endif
#else /* SYSTEM_MALLOC */
#ifndef HAVE_ALLOCA
mallocobj = alloca.o
#endif
#endif

/* define otherobj as list of object files that make-docfile
   should not be told about.  */
otherobj= $(termcapobj) lastfile.o $(mallocobj)

/* List of Lisp files loaded into the dumped Emacs. */
/* 91.11.1, 92.2.6, 92.10.11  by K.Handa */
lisp=	${lispdir}simple.elc ${lispdir}help.elc \
	${lispdir}files.elc ${lispdir}window.elc \
	${lispdir}indent.elc ${lispdir}loaddefs.el ${lispdir}paths.el \
	${lispdir}startup.elc ${lispdir}lisp.elc \
	${lispdir}page.elc ${lispdir}register.elc \
	${lispdir}paragraphs.elc ${lispdir}lisp-mode.elc \
	${lispdir}text-mode.elc ${lispdir}fill.elc \
	${lispdir}c-mode.elc ${lispdir}isearch.elc \
	${lispdir}replace.elc ${lispdir}abbrev.elc \
	${lispdir}buff-menu.elc ${lispdir}subr.elc \
	${lispdir}mule-conf.el ${lispdir}mule-init.el \
	$(MULE_ELC)

/* just to be sure the sh is used */
SHELL=/bin/sh

/* Construct full set of libraries to be linked.  */
/* 92.3.31, 92.7.31 by K.Handa, 92.8.5 by M.Minda, 92.10.21 by M.Higashida */
/* 93.7.27 by K.Handa */
LIBES = $(MULE_LIB) LIBS_TERMCAP $(LIBX) $(LIBSUN) $(LIBDOS) LIBS_SYSTEM LIBS_MACHINE LIBS_DEBUG $(GNULIB_VAR) LIB_STANDARD

/* Enable recompilation of certain other files depending on system type.  */

#ifndef OTHER_FILES
#define OTHER_FILES
#endif

/* Enable inclusion of object files in temacs depending on system type.  */
#ifndef OBJECTS_SYSTEM
#define OBJECTS_SYSTEM
#endif

#ifndef OBJECTS_MACHINE
#define OBJECTS_MACHINE
#endif

all: xemacs OTHER_FILES ${etcdir}CHARSETS

/* 92.10.21 by M.Higashida, 92.11.22 by K.Handa */
#ifdef MSDOS
# ifdef GO32
execprefix="go32 $(dot)/"
# else /* not GO32 */
execprefix=
# endif /* not GO32 */
#else /* not MSDOS */
execprefix=$(dot)/
#endif /* not MSDOS */
/* end of patch */

/* 93.2.10 by K.Handa */
#ifdef SUFFIX_BUG
elc-patched:
#else	
.SUFFIXES: .elc .el
.el.elc:
#endif /* not SUFFIX_BUG */
#ifdef HAVE_SHM
	$(execprefix)temacs -nl -batch -l ${lispdir}mule-inst.el ${lispdir} ${MULE_ELC_PATCHED}
#else
	$(execprefix)temacs -batch -l ${lispdir}mule-inst.el ${lispdir} ${MULE_ELC_PATCHED}
#endif
/* end of patch */

#ifdef SUFFIX_BUG
xemacs: temacs elc-patched ${etcdir}DOC ${lisp}
#else
xemacs: temacs ${etcdir}DOC ${lisp}
#endif /* not SUFFIX_BUG */
#ifdef HAVE_SHM
	$(execprefix)temacs -nl -batch -l inc-vers
	$(execprefix)temacs -nl -batch -l loadup dump
	ln temacs xemacs
#else
#ifdef CANNOT_DUMP
	mv temacs xemacs
#else
/* 92.10.21 by M.Higashida */
	$(execprefix)temacs -batch -l inc-vers
	$(execprefix)temacs -batch -l loadup.el dump
/* end of patch */
#endif /* not CANNOT_DUMP */
#endif /* not HAVE_SHM */

${etcdir}DOC: ${etcdir}make-docfile ${obj} ${lisp}
	rm -f ${etcdir}DOC
	${etcdir}make-docfile ${obj} ${lisp} ${lispdir}version.el > ${etcdir}DOC

/* 92.10.21 by M.Higashida */
${etcdir}make-docfile:
	${CD} ${etcdir}; ${MAKE} ${MFLAGS} make-docfile
/* end of patch */

/* Some systems define this to cause parallel Make-ing.  */
#ifndef MAKE_PARALLEL
#define MAKE_PARALLEL
#endif

/* 92.5.25 by M.Higashida */
temacs: MAKE_PARALLEL $(LOCALCPP) $(SHORT) $(STARTFILES) $(OLDXMENU) $(SUPPORTDOS) ${obj} ${otherobj} OBJECTS_SYSTEM OBJECTS_MACHINE
#ifndef MSDOS
  	$(LD) ${STARTFLAGS} ${LDFLAGS} -o temacs ${STARTFILES} ${obj} ${otherobj} OBJECTS_SYSTEM OBJECTS_MACHINE ${LIBES}
#else
	ls *.o | grep -v ${STARTFILES} >temacs.rf
	$(LD) ${STARTFLAGS} ${LDFLAGS} -o temacs ${STARTFILES} @temacs.rf ${LIBES}
#endif
/* end of patch */

/* These are needed for C compilation, on the systems that need them */
#ifdef NEED_CPP
CPP = ./localcpp
localcpp:
	cd ${cppdir}; ${MAKE} ${MFLAGS} EMACS=-DEMACS
	ln ${cppdir}cpp localcpp  /* Name where CFLAGS will refer to it */
/* cc appears to be cretinous and require all of these to exist
   if -B is specified -- we can't use one local pass and let the
   others be the standard ones.  What a loser.
   We can't even use ln, since they are probably
   on different disks.  */
	cp /lib/ccom localccom
	-cp /lib/optim localoptim
	-cp /lib/c2 localc2
	cp /bin/as localas
#else /* not NEED_CPP */
CPP = $(CC) -E
#endif /* need NEED_CPP */

#ifdef SHORTNAMES
shortnames:
	cd ${shortnamesdir}; ${MAKE} ${MFLAGS}
#endif /* SHORTNAMES */

/* Don't lose if this was not defined.  */
#ifndef OLDXMENU_OPTIONS
#define OLDXMENU_OPTIONS
#endif

#ifdef HAVE_X_WINDOWS
#ifdef HAVE_X_MENU
#ifdef HAVE_X11
$(OLDXMENU):
	cd ${oldXMenudir}; ${MAKE} ${MFLAGS} OLDXMENU_OPTIONS
	ln ${oldXMenudir}libXMenu11.a $(OLDXMENU) || cp ${oldXMenudir}libXMenu11.a $(OLDXMENU)
#endif /* HAVE_X11 */
#endif /* HAVE_X_MENU */
#endif /* HAVE_X_WINDOWS */

/* 92.05.25 by M.Higashida */
#ifdef MSDOS
$(SUPPORTDOS):
	${CD} $(supportdosdir); ${MAKE} ${MFLAGS}
#endif
/* end of patch */

paths.h: paths.h-dist
	echo paths.h needs to be set up from paths.h-dist
	exit 1

config.h: config.h-dist
	echo config.h needs to be set up from config.h-dist
	exit 1

mconfig.h: mconfig.h-dist
	echo mconfig.h needs to be set up from mconfig.h-dist
	exit 1

/* Some machines have alloca built-in.
   They should define HAVE_ALLOCA, or may just let alloca.s
   be used but generate no code.
   Some have it written in assembler in alloca.s.
   Some use the C version in alloca.c (these define C_ALLOCA in config.h).
   */

#ifdef C_ALLOCA
alloca.o : alloca.c
#else
#ifndef HAVE_ALLOCA
alloca.o : alloca.s config.h
/* $(CPP) is cc -E, which may get confused by filenames
   that do not end in .c.  So copy file to a safe name.  */
	cp alloca.s allocatem.c
/* remove any ^L, blank lines, and preprocessor comments,
   since some assemblers barf on them */
	$(CPP) allocatem.c | \
	sed -e 's///' -e 's/^#.*//' | \
	sed -n -e '/^..*$$/p' > allocatem.s
	-rm -f alloca.o
/* Xenix, in particular, needs to run assembler via cc.  */
	cc -c allocatem.s
	mv allocatem.o alloca.o
	rm allocatem.s allocatem.c
#endif /* HAVE_ALLOCA */
#endif /* not C_ALLOCA */

/* Nearly all the following files depend on lisp.h,
   but it is not included as a dependency because
   it is so often changed in ways that do not require any recompilation
   and so rarely changed in ways that do require any.  */

abbrev.o : abbrev.c buffer.h commands.h config.h 
buffer.o : buffer.c syntax.h buffer.h commands.h window.h config.h $(MULE_H)
callint.o : callint.c window.h commands.h buffer.h config.h 
callproc.o : callproc.c paths.h buffer.h commands.h config.h $(MULE_H) \
        $(CC_H) $(MCPATH_H)
casefiddle.o : casefiddle.c syntax.h commands.h buffer.h config.h 
/* 91.11.1 by K.Handa */
category.o : buffer.h category.h category.c config.h $(MULE_H)
/* 93.5.14 by K.Handa */
ccl.o : ccl.c codeconv.h
cm.o : cm.c cm.h termhooks.h config.h
cmds.o : cmds.c syntax.h buffer.h commands.h config.h $(MULE_H)
/* 91.11.1 by K.Handa */
codeconv.o: buffer.h codeconv.c $(MULE_H) $(CC_H)
crt0.o : crt0.c config.h
	$(CC) -c $(CFLAGS) C_SWITCH_ASM crt0.c
dired.o : dired.c commands.h buffer.h config.h regex.h $(MCPATH_H)
dispnew.o : dispnew.c commands.h window.h buffer.h dispextern.h termchar.h \
 termopts.h cm.h config.h lisp.h $(MULE_H)
doc.o : doc.c buffer.h config.h paths.h
doprnt.o : doprnt.c
editfns.o : editfns.c window.h buffer.h config.h $(MULE_H)
emacs.o : emacs.c commands.h config.h $(MULE_H) mconfig.h
#ifdef MAINTAIN_ENVIRONMENT
environ.o : environ.c buffer.h commands.h config.h
#endif /* MAINTAIN_ENVIRONMENT */
fileio.o : fileio.c window.h buffer.h config.h $(MULE_H) $(CC_H) $(MCPATH_H)
filelock.o : filelock.c buffer.h paths.h config.h  $(MCPATH_H)
filemode.o : filemode.c 
indent.o : indent.c window.h indent.h buffer.h config.h termchar.h termopts.h $(MULE_H)
insdel.o : insdel.c window.h buffer.h config.h 
keyboard.o : keyboard.c termchar.h termhooks.h termopts.h buffer.h commands.h window.h macros.h config.h $(MULE_H)
keymap.o : keymap.c buffer.h commands.h config.h $(MULE_H)
lastfile.o : lastfile.c 
macros.o : macros.c window.h buffer.h commands.h macros.h config.h
malloc.o : malloc.c config.h
marker.o : marker.c buffer.h config.h 
minibuf.o : minibuf.c syntax.h window.h buffer.h commands.h config.h 
mocklisp.o : mocklisp.c buffer.h config.h
/* 91.11.1 by K.Handa */
mule.o : mule.c mule.h buffer.h config.h mconfig.h $(MULE_H) $(CC_H)
process.o : process.c process.h buffer.h window.h termhooks.h termopts.h commands.h dispextern.h config.h $(MULE_H) $(CC_H) $(MCPATH_H)
regex.o : regex.c syntax.h buffer.h config.h regex.h $(MULE_H)
scroll.o : scroll.c termchar.h config.h dispextern.h termhooks.h
search.o : search.c regex.h commands.h buffer.h syntax.h config.h $(MULE_H)
syntax.o : syntax.c syntax.h buffer.h commands.h config.h $(MULE_H)
sysdep.o : sysdep.c config.h dispextern.h termhooks.h termchar.h termopts.h window.h $(MCPATH_H)
term.o : term.c termchar.h termhooks.h termopts.h config.h cm.h $(MULE_H) $(CC_H)
termcap.o : termcap.c config.h
terminfo.o : terminfo.c config.h
tparam.o : tparam.c config.h
undo.o : undo.c buffer.h commands.h config.h 
UNEXEC : config.h getpagesize.h mconfig.h puresize.h $(MCPATH_H)
window.o : window.c indent.h commands.h window.h buffer.h config.h termchar.h
xdisp.o : xdisp.c macros.h commands.h indent.h buffer.h dispextern.h termchar.h window.h config.h $(MULE_H)
xfns.o : xfns.c xterm.h window.h config.h
xmenu.o : xmenu.c xterm.h window.h config.h
xterm.o : xterm.c xterm.h termhooks.h termopts.h termchar.h \
 dispextern.h config.h sink.h sinkmask.h $(MULE_H)

x11fns.o : x11fns.c window.h x11term.h dispextern.h termchar.h config.h $(MULE_H)
x11term.o : x11term.c x11term.h termhooks.h termopts.h termchar.h \
 dispextern.h config.h sink11.h sink11mask.h lisp.h gettime.h emacssignal.h \
 xkeys-aix.h $(MULE_H) $(CC_H)
#ifdef WNN4
/* 92.5.18 by T.Shingu */
wnn4fns.o : wnn4fns.c $(MULE_H) mconfig.h
	$(CC) -c $(CFLAGS) $(WNNINC) wnn4fns.c
#endif
#ifdef CANNA
/* 92.8.5 by M.Minda */
canna.o: canna.c $(MULE_H) mconfig.h
	$(CC) -c $(CFLAGS) $(CANNAINC) canna.c
#endif
#ifdef MCPATH
$(MCPATH_OBJ): mcpath.c $(MCPATH_h) $(CC_H)
#endif /* MCPATH */

/* The files of Lisp proper */

alloc.o : alloc.c window.h buffer.h config.h mconfig.h puresize.h
bytecode.o : bytecode.c buffer.h config.h 
data.o : data.c buffer.h config.h 
eval.o : eval.c commands.h config.h
fns.o : fns.c buffer.h commands.h config.h
print.o : print.c process.h window.h buffer.h dispextern.h termchar.h config.h 
lread.o : lread.c buffer.h paths.h config.h $(MULE_H) $(MCPATH_H)

/* System-specific programs to be made.
   OTHER_FILES, OBJECTS_SYSTEM and OBJECTS_MACHINE
   select which of these should be compiled.  */

sunfns.o  : sunfns.c buffer.h config.h

${etcdir}emacstool: ${etcdir}emacstool.c
	cd ${etcdir}; ${MAKE} ${MFLAGS} emacstool

/* 92.3.31, 92.10.14 by K.Handa, 92.10.21 by M.Higashida */
sunterm.o : sunterm.c termchar.h termhooks.h termopts.h \
	dispextern.h config.h ${etcdir}bdf.h ${etcdir}bdf.c $(MULE_H)

${etcdir}bdf.o: config.h paths.h $(MULE_H) \
		${etcdir}bdf.h ${etcdir}bdf.c ${etcdir}Makefile
	${CD} ${etcdir}; ${MAKE} ${MFLAGS} bdf.o

${etcdir}charset: xemacs
#ifdef HAVE_SHM
	$(etcdir)env EMACSLOADPATH=${lispdir} $(execprefix)xemacs -batch -nl $(lispdir)mule-inst.el `pwd`/${etcdir}charset
#else
	$(etcdir)env EMACSLOADPATH=${lispdir} $(execprefix)xemacs -batch -l $(lispdir)mule-inst.el `pwd`/${etcdir}charset
#endif

${etcdir}CHARSETS: ${etcdir}charset ${etcdir}Makefile
	${CD} ${etcdir}; ${MAKE} ${MFLAGS} CHARSETS
/* end of patch */

/* 92.05.25, 92.10.21 by M.Higashida */
#ifdef MSDOS
dosfns.o : dosfns.c dosfns.h config.h
# ifdef HAVE_VGA_ADAPTER
vgaterm.o : vgaterm.c vgaterm.h termchar.h termhooks.h termopts.h \
	dispextern.h config.h $(MULE_H)
	$(CC) -c $(CFLAGS) -I${gcclibdir}include/grx vgaterm.c
# endif
#endif
/* end of patch */

