[project @ 1999-06-24 14:10:18 by simonmar]
[ghc-hetmet.git] / Makefile
1 ############################################################################
2 #
3 #                       fptools/Makefile
4 #
5 #               This is the main Makefile for fptools.
6 #
7 ############################################################################
8
9 TOP=.
10 include $(TOP)/mk/boilerplate.mk
11 SRC_DIST_DIR=$(shell pwd)/$(SRC_DIST_NAME)
12
13 #
14 # Totally evil hack to make the setting of SUBDIRS be dependent
15 # on whether we do `make install' or not. Having a $(ifeq ... ) would
16 # be preferable..
17 CURRENT_TARGET = $(MAKECMDGOALS)
18 SUBDIRS = $(shell if (test x$(CURRENT_TARGET) = xinstall) ; then echo $(ProjectsToInstall); else echo $(ProjectsToBuild); fi)
19
20 ifneq "$(Project)" ""
21    include $(shell echo $(Project) | tr A-Z a-z)/mk/config.mk
22 endif
23
24 #
25 # Files to include in fptools source distribution
26 #
27 SRC_DIST_DIRS += mk docs CONTRIB distrib $(ProjectsToBuild)
28 SRC_DIST_FILES += configure.in config.guess config.sub configure aclocal.m4 acconfig.h README INSTALL Makefile install-sh
29
30 #
31 # Making a binary distribution
32 #
33 # To make a particular binary distribution: 
34 # set $(Project) to the name of the project (currently Ghc or Happy).
35
36 BIN_DIST_TMPDIR=$(shell pwd)
37 BIN_DIST_NAME=fptools
38
39 #
40 # list of toplevel directories to include in binary distrib.
41 #
42 BIN_DIST_MAIN_DIR=$($(Project)MainDir)
43 BIN_DIST_DIRS=$($(Project)BinDistDirs)
44
45 binary-dist:: binary-dist-pre
46
47 BIN_DIST_TOP= distrib/Makefile-bin.in \
48               distrib/configure-bin.in \
49               README \
50               distrib/INSTALL \
51               $(BIN_DIST_MAIN_DIR)/ANNOUNCE \
52               $(BIN_DIST_MAIN_DIR)/PATCHLEVEL \
53               $(BIN_DIST_MAIN_DIR)/RELEASE \
54               $(BIN_DIST_MAIN_DIR)/LICENSE \
55               glafp-utils/mkdirhier/mkdirhier \
56               install-sh \
57               config.guess \
58               config.sub   \
59               aclocal.m4
60
61 binary-dist::
62         @for i in $(BIN_DIST_TOP); do \
63           if test -f "$$i"; then \
64              echo cp $$i $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME); \
65              cp $$i $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME); \
66           fi; \
67         done;
68         @echo "Configuring the Makefile for this project..."
69         touch $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
70         echo "package = $(ProjectNameShort)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
71         echo "version = $(ProjectVersion)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
72         echo "PACKAGE_SH_SCRIPTS = $($(Project)BinDistShScripts)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
73         echo "PACKAGE_PRL_SCRIPTS = $($(Project)BinDistPrlScripts)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
74         echo "PACKAGE_LIB_PRL_SCRIPTS = $($(Project)BinDistLibPrlScripts)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
75         echo "PACKAGE_BINS = $($(Project)BinDistBins)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
76         cat $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile-bin.in >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in
77         @echo "Generating a shippable configure script.."
78         $(MV) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/configure-bin.in $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/configure.in 
79         ( cd $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME); autoconf )
80
81 #
82 # binary dist'ing the documentation.  
83 # Which documentation to build/install is hardcoded below.
84 #
85
86 BINDIST_DOCS = $($(Project)BinDistDocs)
87 BINDIST_DOCS_WAYS = html info dvi
88
89 binary-dist ::
90         @for way in $(BINDIST_DOCS_WAYS); do \
91            $(MKDIRHIER) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/$$way/$(ProjectNameShort)-$(ProjectVersion); \
92            for dir in $(BINDIST_DOCS); do \
93              echo Making $$way documentation in $$dir && \
94              $(MAKE) -C $$dir --no-print-directory $(MFLAGS) $$way && \
95              echo cp -f $$dir/*.$$way $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/$$way/$(ProjectNameShort)-$(ProjectVersion) && \
96              cp -f $$dir/*.$$way $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/$$way/$(ProjectNameShort)-$(ProjectVersion) && \
97              echo "Done."; \
98            done; \
99         done
100
101 # Rename scripts to $i.prl and $i.sh where necessary.
102 # ToDo: do this in a cleaner way...
103
104 ifneq "$($(Project)BinDistPrlScripts)" ""
105 binary-dist::
106         @for i in $($(Project)BinDistPrlScripts); do \
107              echo "Renaming $$i to $$i.prl"; \
108             $(MV) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM)/$(ProjectNameShort)-$(ProjectVersion)/$$i  $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM)/$(ProjectNameShort)-$(ProjectVersion)/$$i.prl; \
109         done
110 endif
111
112 ifneq "$($(Project)BinDistLibPrlScripts)" ""
113 binary-dist::
114         @for i in $($(Project)BinDistLibPrlScripts); do \
115              echo "Renaming $$i to $$i.prl"; \
116             $(MV) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM)/$(ProjectNameShort)-$(ProjectVersion)/$$i  $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/lib/$(TARGETPLATFORM)/$(ProjectNameShort)-$(ProjectVersion)/$$i.prl; \
117         done
118 endif
119
120 ifneq "$($(Project)BinDistShScripts)" ""
121 binary-dist::
122         @for i in $($(Project)BinDistShScripts); do \
123              echo "Renaming $$i to $$i.sh"; \
124             $(MV) $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM)/$(ProjectNameShort)-$(ProjectVersion)/$$i  $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/bin/$(TARGETPLATFORM)/$(ProjectNameShort)-$(ProjectVersion)/$$i.sh; \
125         done
126 endif
127
128 dist :: dist-pre
129 include $(TOP)/mk/target.mk
130 dist :: dist-post
131
132 binary-dist::
133         @echo "Mechanical and super-natty! Inspect the result and *if* happy; freeze, sell and get some sleep!"