#
# Makefile for hsc ("html sucks completely")
#
# Copyright (C) 1995-1998  Thomas Aglassinger
# Copyright (C) 2001-2004 Matthias Bethke
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

# Windows NT/2000/XP, Visual C++ 6.0
#
# NOTES: 
#  - ignore the link-errors (making the makefile use *.obj 
#    instead of *.o would be more trouble)
#  - use 'nmake' to build hsc.exe
#  - 'nmake install' doesn't work.
#
#------------------------------------------------
CC	= cl
CFLAGS	= -Ox -nologo
SYS	= -DWINNT

#--------------------------------------------------------------------
# avoid fooling around below this line
#--------------------------------------------------------------------

.PHONY: all docs depend 

COMP	= $(CC) -Fo$@ $(SYS) -I. -c

LINK	= $(CC) -o $@ $(SYS) -I.
MOVE	= mv
COPY	= cp
DELETE	= rm -f
DELETEALL= rm -Rf

#--------------------------------------------------------------------
# do not touch anything below this line
#--------------------------------------------------------------------

PROJECT_DIRS = hsc hsclib hscprj hsctools riscos ugly
DEPENDENCIES = .deps
#
# symbols for objects and executables
#
OBJ_TOOLS	= ugly/umemory.o ugly/ustring.o ugly/unikot.o ugly/expstr.o \
		ugly/fname.o ugly/dllist.o ugly/ufile.o ugly/uargs.o \
		ugly/ustrlist.o ugly/infile.o ugly/prginfo.o \
		hscprj/document.o hscprj/license.o hscprj/project.o \
		hscprj/readprj.o hscprj/writeprj.o

OBJ_HSC		= $(OBJ_TOOLS) \
		hsclib/lmessage.o hsclib/entity.o hsclib/tag.o hsclib/attrib.o \
		hsclib/idref.o hsclib/hscprc.o hsclib/lstatus.o hsclib/input.o \
		hsclib/skip.o hsclib/uri.o hsclib/eval.o hsclib/posteval.o \
		hsclib/defattr.o hsclib/deftag.o hsclib/css.o hsclib/parse.o \
		hsclib/include.o hsclib/linit.o hsclib/size.o hsclib/tag_misc.o \
		hsclib/tag_a.o hsclib/tag_hsc.o hsclib/tag_if.o \
		hsclib/tag_macro.o hsclib/tcpip.o \
		hsc/global.o hsc/status.o hsc/callback.o hsc/args.o \
		hsc/output.o hsc/hsc.o
OBJ_DEPP	= hsctools/hscdepp.o
OBJ_PITT	= hsctools/hscpitt.o
OBJ_ALL		= $(OBJ_HSC)
EXE_ALL		= hsc/hsc hsctools/hscdepp hsctools/hscpitt

#
# compile all tools
#
all : $(EXE_ALL) docs

# implict rule for object-files
# (old-style implicit rule)
.c.o :
	$(COMP)  $(CFLAGS) -c $<

hsc/hsc : $(OBJ_HSC)
	$(LINK) $(OBJ_HSC) $(CFLAGS)

hsctools/hscdepp : $(OBJ_TOOLS) $(OBJ_DEPP)
	$(LINK) $(OBJ_DEPP) $(OBJ_TOOLS) $(CFLAGS)

hsctools/hscpitt : $(OBJ_TOOLS) $(OBJ_PITT)
	$(LINK) $(OBJ_PITT) $(OBJ_TOOLS) $(CFLAGS)

#--------------------------------------------------------------------
# update dependencies
#--------------------------------------------------------------------
depend: $(DEPENDENCIES)

$(DEPENDENCIES):
	$(DELETE) $@
	for d in amiga hsc hsclib hscprj hsctools riscos ugly; do \
		for f in `ls $$d/*.c`; do \
			gcc -DUNIX -I. -MM "$$f" | \
			sed -e "s/^\w\+\.o:/$$d\/&/" >>$@; \
		done; \
	done


include .deps
