###############################################################################
#
# Makefile
#
# Make program to build coff renumbering tools
#
# Copyright (c) 1990-2007 Aldor Software Organization Ltd (Aldor.org).
#
###############################################################################
#
# Targets: all, junk, clean
#
#    make all   -- make the various tools for the Aldor compiler
#    make junk  -- list files which are not part of the tools
#    make clean -- remove generated files  (e.g. foo.c~)
#
###############################################################################
#
#  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

OKFILES = Makefile unnum.c renum.c

CFLAGS = -g

# $(ALDORROOT) is retrieved from the environment
ALDORSUBCMD = $(ALDORROOT)/bin

OKFILES = Makefile unnum.c renum.c

all: rs

rs:
	-(if [ "$(MACHINE)" = "rs4.2" ] || [ "$(MACHINE)" = "rs4.1" ] || [ "$(MACHINE)" = "rs3.2" ] || [ "$(MACHINE)" = "rs4.3" ]; then \
		$(MAKE) $(ALDORSUBCMD)/unnum $(ALDORSUBCMD)/renum ; \
	  fi)


clean::
	@ rm -f *~

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


$(ALDORSUBCMD)/unnum: unnum.c
	(SRC=`pwd` ; cd $(ALDORSUBCMD) ; \
	 $(CC) $(CFLAGS) $$SRC/unnum.c -o unnum )

$(ALDORSUBCMD)/renum: renum.c
	(SRC=`pwd` ; cd $(ALDORSUBCMD) ; \
	 $(CC) $(CFLAGS) $$SRC/renum.c -o renum )
