#  Makefile for GNU Emacs lib-src directory.
#   Geoff Voelker (voelker@cs.washington.edu)
#  Copyright (C) 1994 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 2, 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, Inc., 59 Temple Place - Suite 330,
#  Boston, MA 02111-1307, USA.
#

# 
# Sets up the system dependent macros.
#
!include ..\nt\makefile.def

LOCAL_FLAGS	= -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 -DNO_ARCHIVES=1 -I..\nt\inc -I..\src

LINK_FLAGS	= $(ARCH_LDFLAGS) -debug:PARTIAL -machine:$(ARCH) -subsystem:console -entry:mainCRTStartup setargv.obj

ALL	        = $(BLD)\make-docfile.exe \
		$(BLD)\hexl.exe		\
		$(BLD)\ctags.exe	\
		$(BLD)\etags.exe	\
		$(BLD)\movemail.exe	\
		$(BLD)\fakemail.exe	\

		
# don't know what (if) to do with these yet...
#
#		$(BLD)\sorted-doc.exe	\
#		$(BLD)\env.exe		\
#		$(BLD)\server.exe	\
#		$(BLD)\emacstool.exe	\
#		$(BLD)\leditcfns.exe	\
#		$(BLD)\emacsclient.exe	\
#		$(BLD)\cvtmail.exe	\
#		$(BLD)\digest-doc.exe	\
#		$(BLD)\test-distrib.exe	\


LIBS	      = $(BASE_LIBS)

$(BLD)\make-docfile.exe: 	$(BLD)\make-docfile.obj $(BLD)\ntlib.obj
		$(LINK) -out:$@ $(LINK_FLAGS) $(BLD)\make-docfile.obj $(BLD)\ntlib.obj $(LIBS)
$(BLD)\hexl.exe:		$(BLD)\hexl.obj
$(BLD)\movemail.exe: 		$(BLD)\movemail.obj $(BLD)\pop.obj $(BLD)\ntlib.obj
		$(LINK) -out:$@ $(LINK_FLAGS) -debug:FULL $(BLD)\movemail.obj $(BLD)\pop.obj $(BLD)\ntlib.obj $(LIBS) wsock32.lib
$(BLD)\fakemail.exe: 		$(BLD)\fakemail.obj $(BLD)\ntlib.obj
		$(LINK) -out:$@ $(LINK_FLAGS) -debug:full $(BLD)\fakemail.obj $(BLD)\ntlib.obj $(LIBS)

make-docfile:	$(BLD) $(BLD)\make-docfile.exe
etags:		$(BLD) $(BLD)\etags.exe
hexl:		$(BLD) $(BLD)\hexl.exe
movemail:	$(BLD) $(BLD)\movemail.exe
fakemail:	$(BLD) $(BLD)\fakemail.exe

ETAGSOBJ      = $(BLD)\etags.obj \
		$(BLD)\getopt.obj \
		$(BLD)\getopt1.obj \
		$(BLD)\ntlib.obj \
		$(BLD)\regex.obj \
		$(BLD)\alloca.obj


$(BLD)\etags.exe: 	$(ETAGSOBJ)
		$(LINK) -out:$@ $(LINK_FLAGS) $(ETAGSOBJ) $(LIBS)


$(BLD)\regex.obj: ../src/regex.c ../src/regex.h ../src/config.h
		$(CC)  $(CFLAGS) -DCONFIG_BROKETS -DINHIBIT_STRING_HEADER \
		../src/regex.c -Fo$@

ETAGS_CFLAGS  = -DETAGS_REGEXPS -DHAVE_GETCWD
$(BLD)\etags.obj: etags.c
		$(CC) $(CFLAGS) $(ETAGS_CFLAGS) -Fo$@ etags.c

CTAGSOBJ      = $(BLD)\ctags.obj \
		$(BLD)\getopt.obj \
		$(BLD)\getopt1.obj \
		$(BLD)\ntlib.obj \
		$(BLD)\regex.obj \
		$(BLD)\alloca.obj

$(BLD)\ctags.exe:           ctags.c $(CTAGSOBJ)
		$(LINK) -out:$@ $(LINK_FLAGS) $(CTAGSOBJ) $(LIBS)

ctags.c:	etags.c
		- $(DEL) ctags.c
		copy etags.c ctags.c

CTAGS_CFLAGS  = -DCTAGS $(ETAGS_CFLAGS)
$(BLD)\ctags.obj: ctags.c
		$(CC) $(CFLAGS) $(CTAGS_CFLAGS) -Fo$@ ctags.c

#
# don't know what to do with these yet...
#
# $(BLD)\sorted-doc.exe: 	$(BLD)\sorted-doc.obj
# $(BLD)\yow.exe: 		$(BLD)\yow.obj
# $(BLD)\emacstool.exe: 	$(BLD)\emacstool.obj
# $(BLD)\leditcfns.exe: 	$(BLD)\leditcfns.obj
# $(BLD)\server.exe: 		$(BLD)\server.obj
# $(BLD)\cvtmail.exe: 		$(BLD)\cvtmail.obj
# $(BLD)\digest-doc.exe: 	$(BLD)\digest-doc.obj
# $(BLD)\emacsclient.exe: 	$(BLD)\emacsclient.obj
# $(BLD)\test-distrib.exe: 	$(BLD)\test-distrib.obj

#
# From ..\src\makefile.nt.
#
obj = abbrev.c alloc.c alloca.c buffer.c bytecode.c callint.c callproc.c casefiddle.c cm.c cmds.c data.c dired.c dispnew.c doc.c  doprnt.c editfns.c eval.c fileio.c filelock.c filemode.c fns.c  indent.c insdel.c keyboard.c keymap.c lastfile.c lread.c macros.c marker.c minibuf.c xfaces.c mocklisp.c nt.c ntheap.c ntinevt.c ntproc.c ntterm.c print.c process.c regex.c scroll.c search.c syntax.c sysdep.c term.c termcap.c tparam.c undo.c unexnt.c window.c xdisp.c casetab.c floatfns.c frame.c gmalloc.c intervals.c ralloc.c textprop.c vm-limit.c region-cache.c strftime.c w32term.c w32xfns.c w32fns.c w32faces.c w32select.c w32menu.c w32reg.c

lispdir = ..\lisp

#
# These are the lisp files that are loaded up in loadup.el
#
lisp= \
	$(lispdir)\subr.elc \
	$(lispdir)\byte-run.elc \
	$(lispdir)\map-ynp.elc \
	$(lispdir)\loaddefs.el \
	$(lispdir)\simple.elc \
	$(lispdir)\help.elc \
	$(lispdir)\files.elc \
	$(lispdir)\format.elc \
	$(lispdir)\indent.elc \
	$(lispdir)\window.elc \
	$(lispdir)\frame.elc \
	$(lispdir)\mouse.elc \
	$(lispdir)\menu-bar.elc \
	$(lispdir)\scroll-bar.elc \
	$(lispdir)\select.elc \
	$(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)\ls-lisp.elc \
	$(lispdir)\winnt.elc \
	$(lispdir)\float-sup.elc \
	$(lispdir)\vc-hooks.elc \
	$(lispdir)\version.el \
	$(lispdir)\dos-nt.elc

DOC	      = DOC 
$(DOC):		$(BLD)\make-docfile.exe
		- $(DEL) $(DOC)
		$(BLD)\make-docfile -d ..\src $(obj) > $(DOC)
		$(BLD)\make-docfile -d ..\src $(lisp) >> $(DOC)
		$(CP) $(DOC) ..\etc\DOC-X
		- mkdir ..\src\$(OBJDIR)
		- mkdir ..\src\$(OBJDIR)\etc
		$(CP) $(DOC) ..\src\$(OBJDIR)\etc\DOC-X

{$(BLD)}.obj{$(BLD)}.exe:
		$(LINK) -out:$@ $(LINK_FLAGS) $*.obj $(LIBS)

.c{$(BLD)}.obj:
		$(CC) $(CFLAGS) -Fo$@ $<

#
# Build the executables
#
all:		$(BLD) $(ALL) $(DOC)

#
# Assuming INSTALL_DIR is defined, build and install emacs in it.
#
INSTALL_FILES = $(ALL)
install:	$(INSTALL_FILES)
		- mkdir $(INSTALL_DIR)\bin
		$(CP) $(BLD)\etags.exe $(INSTALL_DIR)\bin
		$(CP) $(BLD)\ctags.exe $(INSTALL_DIR)\bin
		$(CP) $(BLD)\hexl.exe $(INSTALL_DIR)\bin
		$(CP) $(BLD)\movemail.exe $(INSTALL_DIR)\bin
		$(CP) $(BLD)\fakemail.exe $(INSTALL_DIR)\bin
		- mkdir $(INSTALL_DIR)\etc
		$(CP) $(DOC) $(INSTALL_DIR)\etc

#
# Maintenance
# 
clean:;		- $(DEL) *~ *.pdb DOC*
		- $(DEL_TREE) deleted
		- $(DEL_TREE) $(OBJDIR)

#
# Headers we would preprocess if we could.
#
..\src\config.h:	..\nt\$(CONFIG_H)
			$(CP) $** $@
..\src\paths.h:		..\nt\paths.h
			$(CP) $** $@

### DEPENDENCIES ###

EMACS_ROOT	= ..
SRC		= .

$(BLD)\alloca.obj : \
	$(SRC)\alloca.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\src\config.h \
	$(EMACS_ROOT)\src\blockinput.h

$(BLD)\b2m.obj : \
	$(SRC)\b2m.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\lib-src\..\src\config.h

$(BLD)\cvtmail.obj : \
	$(SRC)\cvtmail.c

$(BLD)\digest-doc.obj : \
	$(SRC)\digest-doc.c

$(BLD)\emacsclient.obj : \
	$(SRC)\emacsclient.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\lib-src\..\src\config.h

$(BLD)\emacsserver.obj : \
	$(SRC)\emacsserver.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\lib-src\..\src\config.h \
	$(EMACS_ROOT)\nt\inc\sys\file.h

$(BLD)\emacstool.obj : \
	$(SRC)\emacstool.c \
	$(EMACS_ROOT)\nt\inc\sys\file.h

$(BLD)\etags.obj : \
	$(SRC)\etags.c \
	$(EMACS_ROOT)\nt\inc\sys\param.h \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\lib-src\..\src\config.h \
	$(SRC)\getopt.h

$(BLD)\fakemail.obj : \
	$(SRC)\fakemail.c \
	$(SRC)\ntlib.h \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\lib-src\..\src\config.h \
	$(EMACS_ROOT)\nt\inc\pwd.h

$(BLD)\getdate.obj : \
	$(SRC)\getdate.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\src\config.h \
	$(MSTOOLS_SYS)\types.h

$(BLD)\getopt.obj : \
	$(SRC)\getopt.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\src\config.h \
	$(SRC)\getopt.h

$(BLD)\getopt1.obj : \
	$(SRC)\getopt1.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\src\config.h \
	$(SRC)\getopt.h

$(BLD)\hexl.obj : \
	$(SRC)\hexl.c

$(BLD)\leditcfns.obj : \
	$(SRC)\leditcfns.c

$(BLD)\make-docfile.obj : \
	$(SRC)\make-docfile.c \
	$(EMACS_ROOT)\src\config.h

$(BLD)\make-path.obj : \
	$(SRC)\make-path.c

$(BLD)\movemail.obj : \
	$(SRC)\movemail.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\lib-src\..\src\config.h \
	$(EMACS_ROOT)\nt\inc\sys\file.h \
	$(EMACS_ROOT)\src\vmsproc.h \
	$(EMACS_ROOT)\lib-src\..\src\syswait.h \
	$(EMACS_ROOT)\nt\inc\pwd.h
		$(CC) $(CFLAGS) -DUSG -Fo$@ movemail.c

$(BLD)\ntlib.obj : \
	$(SRC)\ntlib.c \
	$(SRC)\ntlib.h \
	$(EMACS_ROOT)\nt\inc\pwd.h

$(BLD)\pop.obj : \
	$(SRC)\pop.c \
	$(SRC)\pop.h \
	$(SRC)\ntlib.h

$(BLD)\profile.obj : \
	$(SRC)\profile.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\lib-src\..\src\config.h \
	$(EMACS_ROOT)\src\vmstime.h \
	$(EMACS_ROOT)\lib-src\..\src\systime.h

$(BLD)\qsort.obj : \
	$(SRC)\qsort.c

$(BLD)\sorted-doc.obj : \
	$(SRC)\sorted-doc.c

$(BLD)\tcp.obj : \
	$(SRC)\tcp.c

$(BLD)\test-distrib.obj : \
	$(SRC)\test-distrib.c

$(BLD)\timer.obj : \
	$(SRC)\timer.c \
	$(EMACS_ROOT)\src\s\windowsnt.h \
	$(EMACS_ROOT)\src\m\intel386.h \
	$(EMACS_ROOT)\lib-src\..\src\config.h

$(BLD)\yow.obj : \
	$(SRC)\yow.c \
	$(EMACS_ROOT)\lib-src\..\src\paths.h
