# $Id: GNUMakefile,v 1.3 1997/11/09 23:52:45 lars Exp $
#--------------------------------------------------------------------------
# Makefile for MkDepend
#
# Written for use with SAS/C and GNU-Make.
#--------------------------------------------------------------------------
# Available targets:
#  MkDepend: creates the program.
#  clean   : deletes all objects, test.#? and a.out.
#  clobber : same as clean, also deletes the executable.
#  depend  : updates the Makefile by the source dependencies.
#  archive : creates an archive MkDepend-<version>.lha
#  deposit : deposits all existing files back into the RCS archive, using
#	     RCSTATE as release state when defined. The state of the files
#	     in the RCS deposit is not changed.
#--------------------------------------------------------------------------
# $Log: GNUMakefile,v $
# Revision 1.3  1997/11/09  23:52:45  lars
# RELEASE 1.4
#
# Revision 1.2	1997/11/08  19:00:08  lars
# Updated to archive GNUMakefile as well.
#
# Revision 1.1	1997/11/08  17:53:35  lars
# Initial revision, created from Makefile 1.8.
#
# Revision 1.8	1996/03/02  21:29:28  lars
# *** empty log message ***
#
# Revision 1.7	1996/03/02  21:23:03  lars
# More RCS tweaks to 'archive'.
#
# Revision 1.6	1996/03/02  21:18:36  lars
# RCS tweaks to target 'archive'.
#
# Revision 1.5	1996/03/02  20:58:11  lars
# Added new target 'deposit'.
#
# Revision 1.4	1996/03/02  20:46:56  lars
# New Release.
#
# Revision 1.3	1996/02/25  20:55:56  lars
# Put under RCS.
#
#--------------------------------------------------------------------------

# Release version, should match the version number in main.c and other
# makefiles.
VERSION= 1.4

#--------------------------------------------------------------------------
CFLAGS = PARAMETERS=R noSTACKCHECK noSTACKEXT STRINGMERGE STRINGSECTION=CODE noICONS noVER
LFLAGS = SC SD noICONS\
	HEIGHT 0 PWIDTH 12 SWIDTH 16 WIDTH 92
LIBS = LIB:sc.lib LIB:debug.lib LIB:small.lib

ifdef DEBUG
OBJ = Exp
CFLAGS += DEFINE=_DEBUG DEBUG=SYMBOLFLUSH
else
OBJ = Rel
CFLAGS += DEFINE=NDEBUG OPTIMIZE
LFLAGS += noDEBUG
endif

# Source files
SOURCES= args.c main.c reader.c nodes.c

# Other files to archive
OTHER= $(foreach file,$(basename $(SOURCES)),$(file).h) Makefile DMakefile \
       GNUMakefile HISTORY MkDepend.doc MkDepend.readme

# Object files to generate
OBJECTS= $(foreach file,$(basename $(SOURCES)),$(OBJ)/$(file).o)

# Default rule to compile objects into a subdirectory $(OBJ)/
$(OBJ)/%.o: %.c
	@Echo "--- Compiling $<"
	@SC $< OBJNAME=$@ $(CFLAGS)

# Set _RCSTATE to the check-in state.
ifdef RCSTATE
_RCSTATE= -s$(RCSTATE)
endif

#--------------------------------------------------------------------------

MkDepend : $(OBJ)

MkDepend : $(OBJECTS)
	@Echo "--- Linking $@"
	@Slink FROM LIB:c.o $(OBJECTS) LIB $(LIBS) TO $@ $(LFLAGS)

clean :
	rcsclean
	-delete #?.o test.#? a.out
	-delete $(OBJ)/#?.o

clobber : clean
	-delete MkDepend MkDepend-#?.readme MkDepend-#?.lha
	-delete $(OBJ) all

depend : $(SOURCES)
	MkDepend $(SOURCES) -p.c:$$(OBJ)/%n.o -fGNUMakefile


archive : $(SOURCES) $(OTHER) depend MkDepend
	delete GNUMakefile.bak force
	makedir MkDepend-$(VERSION)
	copy MkDepend $(SOURCES) $(OTHER) MkDepend-$(VERSION) clone
	copy MkDepend.readme MkDepend-$(VERSION).readme
	+protect MkDepend-$(VERSION) +wd all
	+protect MkDepend-$(VERSION).readme +wd
	-delete MkDepend-$(VERSION).lha
	lha -axmr a MkDepend-$(VERSION).lha MkDepend-$(VERSION)
	delete MkDepend-$(VERSION) all quiet
	@+echo "Archive created."

deposit :
	ci $(_RCSTATE) $(SOURCES) $(OTHER)

$(OBJ) :
	makedir $(OBJ)

# --- DO NOT MODIFY THIS LINE -- AUTO-DEPENDS FOLLOW ---
$(OBJ)/args.o : args.c main.h args.h

$(OBJ)/main.o : main.c nodes.h reader.h main.h args.h

$(OBJ)/nodes.o : nodes.c nodes.h

$(OBJ)/reader.o : reader.c reader.h

# --- DO NOT MODIFY THIS LINE -- AUTO-DEPENDS PRECEDE ---
