# Makefile for ccg
# 
# Copyright (C) 1998, 1999, 2000 Ian.Piumarta@INRIA.Fr
# 
# This 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 software 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 file COPYING for more details.
# 
# Last edited: Thu Aug 10 02:03:42 2000 by piumarta (Ian Piumarta) on emilia

VERSION:=	1.2

PROGS:=		ccg
CC:=		gcc
override \
CFLAGS+=	-O -pipe -g -Wall -DCCGVERSION="\"$(VERSION)\""

DISTDIR:=	../dist/ccg
DISTFILES:=	COPYING Makefile alpha asm-*.h ccg.c ccg.mk
SUBDIRS:=	doc util examples

INSNS:=		insns-ppc.h insns-sparc.h insns-i386.h

.PHONY:		ansi dist verify clean sunos

all:		$(PROGS)

ansi:
		$(MAKE) all CFLAGS+="-ansi -pedantic -D_POSIX_SOURCE"

ccg.o:		$(INSNS)

insns-%.h:	asm-%.h
		util/mkinsns $< > $@

dist:
		/bin/rm -rf $(DISTDIR)
		mkdir -p $(DISTDIR)
		echo $(shell date) > $(DISTDIR)/STAMP
		cp -p $(DISTFILES) $(DISTDIR)
		for i in $(SUBDIRS); do $(MAKE) -C $$i dist DISTDIR=../$(DISTDIR)/$$i; done
		(cd $(DISTDIR)/..; tar cfz ccg-$(VERSION).tgz ccg; )
		-/bin/rm -rf $(DISTDIR)

publish:	dist
		$(MAKE) -C doc ccg.html
		cp -p doc/*.html doc/*.gif dist
		$(MAKE) -C dist publish

verify:
		util/defck asm-common.h
		util/defck asm-ppc.h
		util/defck asm-sparc.h
		util/defck asm-i386.h

clean:
		/bin/rm -f *.s *.i *.o *~ core a.out $(INSNS)

spotless:	clean
		/bin/rm -f $(PROGS)

distclean:	spotless
		for i in $(SUBDIRS); do $(MAKE) -C $$i distclean; done

sunos:
		$(MAKE) CPPFLAGS="-I/usr/5include" LDFLAGS="-L/usr/5lib"
