###############################################################################
#
# Makefile
#
# Make program to build portable tools for the Aldor compiler
#
# Copyright (c) 1990-2007 Aldor Software Organization Ltd (Aldor.org).
#
###############################################################################
#
# These tools can built on various platforms and
# can be used to help build and test a compiler.
#
###############################################################################
#
#  2006/Dec/22
#
#  On Solaris, the value of PWD does not change when make is invoked
#  recursively.  Consequently, it is necessary to explicitly set it
#  at the start of the makefile.
#
PWD = $(shell pwd)

SHELL	= /bin/sh
LN	= ln
RM	= rm -f
CFLAGS	= -O
# This is a K&R compatible C
CC      = gcc


# $(ALDORROOT) is retrieved from the environment
SRC   = ../../src
BIN   = $(ALDORROOT)/bin
TOOLS = $(ALDORROOT)/toolbin

OKFILES		= Makefile echon.c txt2txt.c dosify macify unixify

all:	$(BIN)/echon$(EXE) $(BIN)/axiomxl \
	$(BIN)/txt2txt$(EXE) $(BIN)/dosify $(BIN)/macify $(BIN)/unixify
	@ echon

clean:
	@ $(RM) *~

junk:
	@ ls -d $(OKFILES) * | sort | grep -v CVS | uniq -u

##############################################################################
#
# :: Portable tools
#
##############################################################################

# Allows obsolete scripts/Makefiles to continue to function.
$(BIN)/axiomxl: axiomxl
	cp axiomxl $(BIN)/axiomxl
	chmod 755 $(BIN)/axiomxl

# echon: Echo without newline for portable shell scripts.
$(BIN)/echon: echon.c
	@ (SRC=`pwd` ; cd $(BIN) ; \
		echo "$(CC) $(CFLAGS) $$SRC/echon.c -o echon" ; \
		$(CC) $(CFLAGS) $$SRC/echon.c -o echon \
	)

# Convert any Mac/DOS/Unix text file into a Mac/DOS/Unix text file
$(BIN)/txt2txt: txt2txt.c
	@ (SRC=`pwd` ; cd $(BIN) ; \
		echo "$(CC) $(CFLAGS) $$SRC/txt2txt.c -o txt2txt" ; \
		$(CC) $(CFLAGS) $$SRC/txt2txt.c -o txt2txt \
	)

$(BIN)/dosify: dosify
	cp dosify $(BIN)/dosify
	chmod 755 $(BIN)/dosify

$(BIN)/macify: macify
	cp macify $(BIN)/macify
	chmod 755 $(BIN)/macify

$(BIN)/unixify: unixify
	cp unixify $(BIN)/unixify
	chmod 755 $(BIN)/unixify

