# IDoc makefile
#
# Author : Manuel M T Chakravarty
# Created: 24 February 2002
#
# Version $Revision: 1.2 $ from $Date: 2002/02/28 06:33:03 $
#
# Copyright (c) 2002 Manuel M T Chakravarty
#
# This file 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 file 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.
#
# = DOCU =====================================================================
#
# This makefile is made to work without an extra configuration step to keep
# everything as simple as possible for the user.
#
# The default compiler is GHC, but you can overwrite makefile variables by
# providing alternatives values as argument to the invocation of `make'.
#
# ***************************************
# !!! This makefile requires GNU make !!!
# ***************************************
# variables that you may like to overwrite
#
# * HC : Haskell compiler to be used
# * HCFLAGS: flags passed to the Haskell compiler for compiling and linking
# * PREFIX : subtree into which to install the tool
#
HC = ghc
HCFLAGS =
PREFIX = /usr/local
# compute compiler dependent options
#
SYS = $(notdir $(HC))
ifeq ($(strip $(SYS)),ghc)
HCFLAGS=-O
endif
# install paths
#
prefix = $(PREFIX)
bindir = $(prefix)/bin
# package name as well as source and object files
#
PACKAGE = idoc
SRCS = GetOpt.hs IDoc.hs
OBJS = $(patsubst %.hs,%.o,$(filter %.hs,$(SRCS)))
# file that contains a `versnum = "x.y.z"' line
#
VERSFILE = IDoc.hs
# this is far from elegant, but extracts the plain version number
#
VERSION =$(shell grep '^versnum' $(VERSFILE)\
| sed '-e s/versnum.* "//' '-e s/"//')
# define what get dumped into a source distribution
#
MKFILES = Makefile
NONCODE = COPYING ChangeLog README
TESTFILES= $(wildcard test/*.hs)
DISTFILES= $(NONCODE) $(MKFILES) $(SRCS) $(TESTFILES)
# default target
#
default: idoc
# compile rules
#
%.o: %.hs
$(RM) $@
$(HC) -c $(HCFLAGS) $<
%.hi: %.o
@:
# link target
#
idoc: $(OBJS)
$(HC) $(HCFLAGS) -o $@ $^
# install target
#
.PHONY: install
install: idoc
mkdir -p $(bindir)
cp idoc $(bindir)/idoc
-strip $(bindir)/idoc
chmod a+x $(bindir)/idoc
# admin targets
#
.PHONY: clean cleanhi cleanall tar
clean:
-$(RM) *.o idoc
cleanhi:
-$(RM) *.hi
cleanall: clean cleanhi
tar:
-ln -s . $(PACKAGE)-$(VERSION)
tar czf $(PACKAGE)-$(VERSION).tar.gz\
$(addprefix $(PACKAGE)-$(VERSION)/,$(DISTFILES))
$(RM) $(PACKAGE)-$(VERSION)
# dependencies
#
IDoc.o : IDoc.hs GetOpt.hi
GetOpt.o: GetOpt.hs
syntax highlighted by Code2HTML, v. 0.9.1