Commit 0065d5ab authored by Simon Marlow's avatar Simon Marlow
Browse files

Reorganisation of the source tree

Most of the other users of the fptools build system have migrated to
Cabal, and with the move to darcs we can now flatten the source tree
without losing history, so here goes.

The main change is that the ghc/ subdir is gone, and most of what it
contained is now at the top level.  The build system now makes no
pretense at being multi-project, it is just the GHC build system.

No doubt this will break many things, and there will be a period of
instability while we fix the dependencies.  A straightforward build
should work, but I haven't yet fixed binary/source distributions.
Changes to the Building Guide will follow, too.
parent 28a464a7
############################################################################
#
# fptools/Makefile
# This is the top-level Makefile for GHC
#
# This is the main Makefile for fptools.
# Targets:
#
# bootsrap (DEFAULT)
# Builds GHC, then builds the libraries,
# then uses this GHC ("stage 1") to build itself
# ("stage 2").
#
# bootstrap2
# Same as bootstrap
#
# bootstrap3
# bootstrap2 + we build GHC one more time ("stage 3")
#
# stage1
# Just build up to stage 1
#
# stage2
# Just build stage 2 (stage 1 must be built)
#
# stage3
# Just build stage 3 (stage 2 must be built)
#
# all
# Same as bootstrap
#
# install
# Install everything, including stage 2 compiler by default
# (override with stage=3, for example).
#
# dist
# Make a source dist (WARNING: runs 'make distclean' first)
#
# binary-dist
# Builds a binary distribution
#
# hc-file-bundle
# Builds an HC-file bundle, for bootstrapping
#
# clean, distclean, maintainer-clean
# Increasing levels of cleanliness
#
############################################################################
TOP=.
include $(TOP)/mk/boilerplate.mk
# find the projects that actually exist...
ProjectsThatExist = $(filter $(patsubst %/, %, $(wildcard */)), $(AllProjects))
# and filter only those that the user requested, if necessary
ifeq "$(ProjectsToBuild)" ""
SUBDIRS = $(ProjectsThatExist)
else
SUBDIRS = $(filter $(ProjectsToBuild), $(ProjectsThatExist))
endif
ifneq "$(Project)" ""
ifeq "$(Project)" "GreenCard"
ProjectDirectory=greencard
else
ifeq "$(Project)" "HaskellDirect"
ProjectDirectory=hdirect
else
ProjectDirectory=$(Project)
endif
endif
-include $(shell echo $(ProjectDirectory) | tr A-Z a-z)/mk/config.mk
-include $(shell echo $(ProjectDirectory) | tr A-Z a-z)/mk/version.mk
endif
# -----------------------------------------------------------------------------
# Certain targets require that Project is set from the command line.
CURRENT_TARGET = $(MAKECMDGOALS)
project-check :
@if [ "$(Project)" = "" ]; then \
echo " You need to set \"Project\" in order to make $(CURRENT_TARGET)"; \
echo " eg. make $(CURRENT_TARGET) Project=Ghc"; \
exit 1; \
fi
# -----------------------------------------------------------------------------
# Targets: all, stage1, stage2, stage3
DIST_CLEAN_FILES += config.cache config.status mk/config.h mk/stamp-h
extraclean::
$(RM) -rf autom4te.cache
#
# If you've ended up using an in-place version of Happy,
# make sure it gets built early on.
# Order is important! It's e.g. necessary to descend into include/
# before the rest to have a config.h, etc.
#
ifeq "$(HAPPY)" "$(FPTOOLS_TOP_ABS)/happy/src/happy-inplace"
build :: $(FPTOOLS_TOP_ABS)/happy/src/happy-inplace
# If we're booting from .hc files, swap the order
# we descend into subdirs - to boot utils must be before driver.
#
.PHONY: stage1 stage2 stage3 bootstrap bootstrap2 bootstrap3
$(FPTOOLS_TOP_ABS)/happy/src/happy-inplace : glafp-utils
$(MAKE) -C happy boot all
# We can't 'make boot' in libraries until stage1 is built
ifeq "$(BootingFromHc)" "YES"
SUBDIRS_NOLIB = includes rts docs compiler compat utils driver
else
SUBDIRS_NOLIB = includes compat utils driver docs compiler rts
endif
# Build all projects that we know about
build ::
SUBDIRS = $(SUBDIRS_NOLIB) libraries
stage1 :
$(MAKE) -C utils/mkdependC boot
@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
for i in $(SUBDIRS); do \
if [ -d $$i ]; then \
$(MAKE) -C $$i boot; \
if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
$(MAKE) -C $$i all; \
if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
fi; \
for i in $(SUBDIRS_NOLIB); do \
echo "------------------------------------------------------------------------"; \
echo "== $(MAKE) boot $(MFLAGS);"; \
echo " in $(shell pwd)/$$i"; \
echo "------------------------------------------------------------------------"; \
$(MAKE) --no-print-directory -C $$i $(MFLAGS) boot; \
if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
done; \
for i in $(SUBDIRS_NOLIB); do \
echo "------------------------------------------------------------------------"; \
echo "== $(MAKE) all $(MFLAGS);"; \
echo " in $(shell pwd)/$$i"; \
echo "------------------------------------------------------------------------"; \
$(MAKE) --no-print-directory -C $$i $(MFLAGS) all; \
if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
done
ifeq "$(findstring ghc, $(SUBDIRS))" "ghc"
.PHONY: stage1 stage2 stage3 bootstrap bootstrap2 bootstrap3
stage1 : build
@$(MAKE) -C libraries boot
@$(MAKE) -C libraries all
stage2 :
$(MAKE) -C ghc/compiler boot stage=2
$(MAKE) -C ghc/compiler stage=2
$(MAKE) -C compiler boot stage=2
$(MAKE) -C compiler stage=2
stage3 :
$(MAKE) -C ghc/compiler boot stage=3
$(MAKE) -C ghc/compiler stage=3
$(MAKE) -C compiler boot stage=3
$(MAKE) -C compiler stage=3
bootstrap : bootstrap2
......@@ -99,6 +106,9 @@ bootstrap3 : bootstrap2
all :: bootstrap
# -----------------------------------------------------------------------------
# Installing
# We want to install the stage 2 bootstrapped compiler by default, but we let
# the user override this by saying 'make install stage=1', for example.
ifeq "$(stage)" ""
......@@ -107,27 +117,25 @@ else
INSTALL_STAGE =
endif
else # Not building GHC
all :: build
INSTALL_STAGE =
endif
boot ::
@echo "Please use \`make all' only from the top-level, or \`make boot' followed"
@echo "by \`make all' in an individual project subdirectory (ghc, hslibs etc.)."
# Same as default rule, but we pass $(INSTALL_STAGE) to $(MAKE) too
install ::
@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
for i in $(filter-out $(ProjectsDontInstall), $(SUBDIRS)); do \
if [ -d $$i ]; then \
$(MAKE) -C $$i $(INSTALL_STAGE) install; \
if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
fi; \
for i in $(SUBDIRS); do \
echo "------------------------------------------------------------------------"; \
echo "== $(MAKE) $@ $(MFLAGS);"; \
echo " in $(shell pwd)/$$i"; \
echo "------------------------------------------------------------------------"; \
$(MAKE) --no-print-directory -C $$i $(INSTALL_STAGE) $(MFLAGS) $@; \
if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
done
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
# These files need to be in the InstallShield
# INSTALL_DATAS rather than INSTALL_DOCS is used so these files go
# in the top-level directory of the distribution
INSTALL_DATAS += ANNOUNCE LICENSE README VERSION
endif
# If installing on Windows with MinGW32, copy the gcc compiler, headers and libs
# and the perl interpreter and dll into the GHC prefix directory.
# Gcc and Perl source locations derived from configuration data.
......@@ -152,11 +160,13 @@ endif
install-docs ::
@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
for i in $(filter-out $(ProjectsDontInstall), $(SUBDIRS)); do \
if [ -d $$i ]; then \
$(MAKE) -C $$i $(INSTALL_STAGE) install-docs; \
if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
fi; \
for i in $(SUBDIRS); do \
echo "------------------------------------------------------------------------"; \
echo "== $(MAKE) $@ $(MFLAGS);"; \
echo " in $(shell pwd)/$$i"; \
echo "------------------------------------------------------------------------"; \
$(MAKE) --no-print-directory -C $$i $(INSTALL_STAGE) $(MFLAGS) $@; \
if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
done
# -----------------------------------------------------------------------------
......@@ -185,7 +195,18 @@ install-docs ::
# binary-dist is an FPtools addition for binary distributions
#
binary-dist :: project-check
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
GhcBinDistShScripts = ghc-$(ProjectVersion) ghci-$(ProjectVersion) ghc-pkg-$(ProjectVersion) hsc2hs
else
GhcBinDistShScripts =
endif
GhcBinDistPrlScripts = ghcprof
GhcBinDistLibPrlScripts = ghc-asm ghc-split
GhcBinDistBins = hp2ps runghc
GhcBinDistOptBins = runhaskell
GhcBinDistLinks = ghc ghci ghc-pkg
GhcBinDistLibSplicedFiles = package.conf
BIN_DIST_TMPDIR=$(FPTOOLS_TOP_ABS)
BIN_DIST_NAME=$(ProjectNameShort)-$(ProjectVersion)
......@@ -391,7 +412,7 @@ binary-dist::
# Do it like this:
#
# $ make
# $ make dist Project=Ghc
# $ make dist
#
# WARNING: `make dist' calls `make distclean' before tarring up the tree.
#
......@@ -453,30 +474,42 @@ dist-package-zip ::
hc-file-bundle : project-check
$(RM) -r $(ProjectNameShort)-$(ProjectVersion)
$(LN_S) . $(ProjectNameShort)-$(ProjectVersion)
$(FIND) $(ProjectNameShort)-$(ProjectVersion)/ghc/compiler \
$(ProjectNameShort)-$(ProjectVersion)/ghc/utils \
$(ProjectNameShort)-$(ProjectVersion)/ghc/lib \
$(FIND) $(ProjectNameShort)-$(ProjectVersion)/compiler \
$(ProjectNameShort)-$(ProjectVersion)/utils \
$(ProjectNameShort)-$(ProjectVersion)/compat \
$(ProjectNameShort)-$(ProjectVersion)/libraries -follow \
\( -name "*.hc" -o -name "*_hsc.[ch]" -o -name "*_stub.[ch]" \) -print > hc-files-to-go
for f in `$(FIND) $(ProjectNameShort)-$(ProjectVersion)/ghc/compiler $(ProjectNameShort)-$(ProjectVersion)/ghc/utils $(ProjectNameShort)-$(ProjectVersion)/libraries -name "*.hsc" -follow -print` ""; do \
for f in `$(FIND) $(ProjectNameShort)-$(ProjectVersion)/compiler $(ProjectNameShort)-$(ProjectVersion)/utils $(ProjectNameShort)-$(ProjectVersion)/libraries -name "*.hsc" -follow -print` ""; do \
if test "x$$f" != "x" && test -e `echo "$$f" | sed 's/hsc$$/hs/g'`; then \
echo `echo "$$f" | sed 's/hsc$$/hs/g' ` >> hc-files-to-go ; \
fi; \
done;
for f in `$(FIND) $(ProjectNameShort)-$(ProjectVersion)/ghc/compiler $(ProjectNameShort)-$(ProjectVersion)/ghc/rts -name "*.cmm" -follow -print` ""; do \
for f in `$(FIND) $(ProjectNameShort)-$(ProjectVersion)/compiler $(ProjectNameShort)-$(ProjectVersion)/rts -name "*.cmm" -follow -print` ""; do \
if test "x$$f" != "x"; then \
echo `echo "$$f" | sed 's/cmm$$/hc/g' ` >> hc-files-to-go ; \
fi; \
done;
echo $(ProjectNameShort)-$(ProjectVersion)/libraries/base/GHC/PrimopWrappers.hs >> hc-files-to-go
echo $(ProjectNameShort)-$(ProjectVersion)/ghc/compiler/parser/Parser.hs >> hc-files-to-go
echo $(ProjectNameShort)-$(ProjectVersion)/ghc/compiler/parser/ParserCore.hs >> hc-files-to-go
echo $(ProjectNameShort)-$(ProjectVersion)/ghc/compiler/main/ParsePkgConf.hs >> hc-files-to-go
echo $(ProjectNameShort)-$(ProjectVersion)/compiler/parser/Parser.hs >> hc-files-to-go
echo $(ProjectNameShort)-$(ProjectVersion)/compiler/parser/ParserCore.hs >> hc-files-to-go
echo $(ProjectNameShort)-$(ProjectVersion)/compiler/main/ParsePkgConf.hs >> hc-files-to-go
echo $(ProjectNameShort)-$(ProjectVersion)/libraries/haskell-src/Language/Haskell/Parser.hs >> hc-files-to-go
tar czf $(ProjectNameShort)-$(ProjectVersion)-$(TARGETPLATFORM)-hc.tar.gz `cat hc-files-to-go`
# -----------------------------------------------------------------------------
# Cleaning
CLEAN_FILES += hc-files-to-go *-hc.tar.gz
DIST_CLEAN_FILES += config.cache config.status mk/config.h mk/stamp-h \
ghc.spec docs/users_guide/ug-book.xml
# don't clean config.mk: it's needed when cleaning stuff later on
LATE_DIST_CLEAN_FILES += mk/config.mk
extraclean::
$(RM) -rf autom4te.cache
# -----------------------------------------------------------------------------
# Turn off target.mk's rules for 'all', 'boot' and 'install'.
......
GHC build system
================
The Glasgow Haskell Compiler
============================
This is the top-level directory of the fptools build system. Several
packages are part of this build system; if you got this as part of a
source distribution (eg. for GHC), then you will have one or more of
the following directories:
This is the source tree for GHC, a compiler and interactive
environment for the Haskell functional programming language.
ghc The Glasgow Haskell Compiler
hslibs A Collection of Haskell libraries
haddock A Haskell documentation tool
haggis The Haggis GUI toolkit
happy The Happy Haskell parser generator
hdirect Haskell interop tool
greencard A foreign function interface pre-processor for Haskell.
libraries Haskell libraries (reqd. by ghc)
nofib The NoFib Haskell benchmarking suite
For more information, visit GHC's web site:
Additional documentation for each project can be found in its
respective directory.
http://www.haskell.org/ghc/
In addition, the following directories contain project-independent bits:
Information for developers of GHC can be found here:
mk GNU make setup used by all of fptools
glafp-utils Shared utility programs
docs Documentation on the installing and using
the fptools build system.
distrib Tools and additional bits for building distributions
http://hackage.haskell.org/trac/ghc/
Quick start: the following is *supposed* to work
Building & Installing
=====================
NB. you need GHC installed in order to build GHC, because the compiler
is itself written in Haskell. It is possible to build GHC using just
a C compiler, but we don't recommend this as the normal route. If you
*really* want to do it this way, then see the Building Guide (link
below).
You also need a few other tools installed: Happy [4], Alex [5], and
Haddock [6] (for building library documentation), and a good DocBook
XML toolchain if you want to build the compiler documentation.
Quick start: the following gives you a default build:
$ autoreconf
$ ./configure
$ make
$ make install
where 'make' is whatever GNU make is called on your system (GNU make
is *required*). If there are any other tools required for the build,
then the configure script will detect them and tell you if any are
missing. For example, a working GHC installation is required for
building most of the tools (including GHC itself).
The autoreconf step is only necessary if this is a tree checked out
from darcs. For source distributions downloaded from GHC's web site,
this step has already been performed.
These steps give you the default build, which includes everything
optimised and built in various ways (eg. profiling libs are built).
It can take a long time. To customise the build, see the file
HACKING.
For full information on building GHC, see the GHC Building Guide [3],
which is also available in source form (DocBook XML) in docs/building.
The configuration script is a standard GNU autoconf script which
accepts all the normal arguments, eg. --prefix=<blah> to install the
package somewhere other than /usr/local. Try ./configure --help to
get a full list of the options.
There is usually an ANNOUNCE* file with any distribution. Please
consult that, or the <piece>/README file, to find out how to proceed.
References
==========
Full documentation for the fptools build system can be found in the
Building Guide:
[1] http://www.haskell.org/ghc/ GHC Home Page
[2] http://hackage.haskell.org/trac/ghc GHC Developer's Wiki
[3] http://www.haskell.org/ghc/docs/latest/html/building/index.html
Building Guide
http://www.haskell.org/ghc/docs/latest/html/building/building-guide.html
[4] http://www.haskell.org/happy/ Happy
[5] http://www.haskell.org/alex/ Alex
[6] http://www.haskell.org/haddock/ Haddock
More information about GHC can be found here:
http://www.haskell.org/ghc/
Contributors
============
--
The GHC Team, glasgow-haskell-users@haskell.org
Please see
http://www.haskell.org/ghc/contributors.html
......@@ -1055,4 +1055,65 @@ else
GhcPkgCmd=$fp_cv_matching_ghc_pkg
fi])# FP_PROG_GHC_PKG
# FP_GHC_HAS_READLINE
# -------------------
AC_DEFUN([FP_GHC_HAS_READLINE],
[AC_REQUIRE([FP_PROG_GHC_PKG])
AC_CACHE_CHECK([whether ghc has readline package], [fp_cv_ghc_has_readline],
[if "${GhcPkgCmd-ghc-pkg}" --show-package readline >/dev/null 2>&1; then
fp_cv_ghc_has_readline=yes
else
fp_cv_ghc_has_readline=no
fi])
AC_SUBST([GhcHasReadline], [`echo $fp_cv_ghc_has_readline | sed 'y/yesno/YESNO/'`])
])# FP_GHC_HAS_READLINE
# FP_GCC_NEEDS_NO_OMIT_LFPTR
# --------------------------
# Some OSs (Mandrake Linux, in particular) configure GCC with
# -momit-leaf-frame-pointer on by default. If this is the case, we need to turn
# it off for mangling to work. The test is currently a bit crude, using only the
# version number of gcc. Defines HAVE_GCC_MNO_OMIT_LFPTR.
AC_DEFUN([FP_GCC_NEEDS_NO_OMIT_LFPTR],
[AC_REQUIRE([FP_HAVE_GCC])
AC_CACHE_CHECK([whether gcc needs -mno-omit-leaf-frame-pointer], [fp_cv_gcc_needs_no_omit_lfptr],
[FP_COMPARE_VERSIONS([$gcc_version_str], [-ge], [3.2],
[fp_cv_gcc_needs_no_omit_lfptr=yes],
[fp_cv_gcc_needs_no_omit_lfptr=no])])
if test "$fp_cv_gcc_needs_no_omit_lfptr" = "yes"; then
AC_DEFINE([HAVE_GCC_MNO_OMIT_LFPTR], [1], [Define to 1 if gcc supports -mno-omit-leaf-frame-pointer.])
fi])# FP_GCC_NEEDS_NO_OMIT_LFPTR
# FP_SETUP_PROJECT_VERSION
# ---------------------
AC_DEFUN([FP_SETUP_PROJECT_VERSION],
[# Some renamings
AC_SUBST([ProjectVersion], [$PACKAGE_VERSION])
# Split PACKAGE_VERSION into (possibly empty) parts
VERSION_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
VERSION_TMP=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
VERSION_MINOR=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
ProjectPatchLevel=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
# Calculate project version as an integer, using 2 digits for minor version
case $VERSION_MINOR in
?) ProjectVersionInt=${VERSION_MAJOR}0${VERSION_MINOR} ;;
??) ProjectVersionInt=${VERSION_MAJOR}${VERSION_MINOR} ;;
*) AC_MSG_ERROR([bad minor version in $PACKAGE_VERSION]) ;;
esac
AC_SUBST([ProjectVersionInt])
# The project patchlevel is zero unless stated otherwise
test -z "$ProjectPatchLevel" && ProjectPatchLevel=0
# Remove dots from the patch level; this allows us to have versions like 6.4.1.20050508
ProjectPatchLevel=`echo $ProjectPatchLevel | sed 's/\.//'`
AC_SUBST([ProjectPatchLevel])
])# FP_SETUP_PROJECT_INFO
# LocalWords: fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment