d06c422397e5fde69dd1cf8d03d341e7d711fba1
[ghc-hetmet.git] / mk / script.mk
1 #-----------------------------------------------------------------------------
2 # $Id: script.mk,v 1.2 1996/11/21 16:50:39 simonm Exp $
3
4 # Useful variables:
5
6 #       PROG =                  program name
7 #       DEPLIST =               (optional) dependencies
8 #       SRC =                   source file
9 #       INTERP =                (optional) interpretter
10 #       DESTDIR =               where to install
11 #       INSTALLED_NAME =        (optional) name to install as
12
13 #-----------------------------------------------------------------------------
14
15 ifndef INSTALLED_NAME
16 INSTALLED_NAME  = $(PROG)
17 endif
18
19 all     :: $(PROG)
20
21 # Hack alert!  Since the variables msub needs aren't in the immediate
22 # Makefile, we must include the relevant files directly.
23
24 MSUB_OPTS = -f Makefile -f $(TOP)/mk/platform.mk -f $(TOP)/mk/utils.mk
25
26 $(PROG) ::  $(SRC) $(DEPLIST)
27         $(RM) $@
28 ifdef INTERP
29         echo "#!"$(INTERP) > $@
30 endif
31         $(MSUB) $(MSUBFLAGS) INSTALLING=0 $(SRC) >> $@ \
32                 || ( $(RM) $@ && exit 1 )
33         chmod a+x $@
34
35 # aaargh: scripts sometimes do different things depending on whether they
36 # are installed versions or not (eg. use installed programs rather than
37 # those in the source tree) hence the following hack:
38
39 install :: $(PROG)_tmp
40         $(INSTALL) $(INSTSCRIPTFLAGS) $(PROG)_tmp $(DESTDIR)/$(INSTALLED_NAME)
41         $(RM) $(PROG)_tmp
42
43 $(PROG)_tmp :  $(SRC)
44         $(RM) $@
45 ifdef INTERP
46         echo "#!"$(INTERP) > $@
47 endif
48         $(MSUB) $(MSUBFLAGS) INSTALLING=1 $(SRC) >> $@ \
49                 || ( $(RM) $@ && exit 1 )
50         chmod a+x $@
51
52 clean   :: 
53         $(RM) $(PROG) $(PROG)_tmp