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