#
# Jamfile to build Jam (a make(1)-like program)
#
# There are no user-serviceable parts in this file.
#

# Put executables in platform-specific  subdirectory.
# If $(OSVER) isn't set, second value is used.

LOCATE_TARGET ?= BIN.$(OS)$(OSVER) BIN.$(OS) ;

# Leave generated source in current directory; it would be nice to use
# these lines below to build the source into the platform-specific
# directory, but getting scan.c to include the right jambase.h is
# hard: with ""'s, it always gets the bootstrap version; with <>'s,
# it won't find the bootstrap version.

# LOCATE_SOURCE ?= $(LOCATE_TARGET) ;
# SEARCH_SOURCE = $(LOCATE_TARGET) $(DOT) ;

#
# We have some different files for UNIX, VMS, and NT.
#

if $(NT) 	{ code = execnt.c filent.c pathunix.c ; } 
else if $(OS2)	{ code = execnt.c fileos2.c pathunix.c ; } 
else if $(VMS) 	{ code = execvms.c filevms.c pathvms.c ; } 
else 		{ code = execunix.c fileunix.c pathunix.c ; }

if $(OS) = NT { CCFLAGS += /DNT ; }
if $(OS) = SOLARIS { CCFLAGS += -Dsolaris ; }
if $(OS) = MVS { CCFLAGS += -DMVS ; }

#
# How to build the compiled in jambase.
#

Main		mkjambase : mkjambase.c ;

rule GenFile 
{
	MakeLocate $(<) : $(LOCATE_SOURCE) ;
	Depends $(<) : $(>[1]:S=$(SUFEXE)) $(>[2]) ;
	GenFile1 $(<) : $(>[1]:S=$(SUFEXE)) $(>[2]) ;
	Clean clean : $(<) ;
}

actions GenFile1
{
	$(>[1]) $(<) $(>[2-])
}

#
# The guts of the Jamfile: how to build Jam
#

Main 		jam : jam.c jambase.c ;
LinkLibraries 	jam : libjam.a ;
GenFile 	jambase.c : mkjambase Jambase ;

Library         libjam.a : 
		    command.c compile.c $(code) expand.c
		    glob.c hash.c headers.c jamgram.y
		    lists.c make.c make1.c newstr.c option.c parse.c
		    regexp.c rules.c scan.c search.c timestamp.c
		    variable.c ;

#
# On UNIX, we install this stuff for easy use.
# On VMS, one must define a symbol:  jam :== $jam.exe -f jambase
# On NT, you're on your own.
#

if $(UNIX)
{
	InstallBin $(BINDIR) : jam ;
	InstallMan $(MANDIR) : jam.1 Jambase.5 Jamfile.5 ;
}

