# Makefile for jam

CC = cc
TARGET = -o jam0
CFLAGS = 

# Special flavors - uncomment appropriate lines

# NCR seems to have a broken readdir() -- use gnu
#CC = gcc

# AIX needs -lbsd, and has no identifying cpp symbol
# Use _AIX41 if you're not on 3.2 anymore.
#LINKLIBS = -lbsd
#CFLAGS = -D_AIX
#CFLAGS = -D_AIX41

ifneq "$(filter C:%, $(NEXT_ROOT))" ""
# NT (with Microsoft compiler)
# Use FATFS if building on a DOS FAT file system
#Lib = $(MSVCNT)/lib
#Include = $(MSVCNT)/include
#CC = cl /nologo
CC = gcc
#CFLAGS = -I $(Include) -DNT 
CFLAGS = -DNT
#TARGET = /Fejam0
#LINKLIBS = $(Lib)/oldnames.lib $(Lib)/kernel32.lib $(Lib)/libc.lib
EXE = .exe
endif

# BeOS - Metroworks CodeWarrior
#CC = mwcc
#Include = /NewDisk/develop/headers/posix
#CFLAGS = -I $(Include)
YACC = yacc
YACCFLAGS = -d
MV = mv

SOURCES = \
	command.c compile.c execunix.c execvms.c expand.c \
	filent.c fileos2.c fileunix.c filevms.c glob.c hash.c \
	headers.c jam.c jambase.c jamgram.c lists.c make.c make1.c \
	newstr.c option.c parse.c pathunix.c pathvms.c regexp.c \
	rules.c scan.c search.c timestamp.c variable.c

JAM0 = jam0$(EXE)

all: $(JAM0)
	$(JAM0) -fJambase

install: $(JAM0)
	$(JAM0) -fJambase install

clean:
	rm -rf $(JAM0) bin.*
	rm -f jamgram.h jamgram.c

jamgram.c: jamgram.y
	$(YACC) $(YACCFLAGS) jamgram.y
	$(MV) y.tab.c jamgram.c
	$(MV) y.tab.h jamgram.h
	
jam0: jamgram.c
	$(CC) $(TARGET) $(CFLAGS) $(SOURCES) $(LINKLIBS)
