[project @ 2002-02-12 15:45:46 by simonmar]
[ghc-hetmet.git] / mk / package.mk
1 # -----------------------------------------------------------------------------
2 # $Id: package.mk,v 1.2 2002/02/12 15:45:46 simonmar Exp $
3
4 ifneq "$(PACKAGE)" ""
5
6 # -----------------------------------------------------------------------------
7 # Build the package configuration file and tell the compiler about it.
8
9 ifeq "$(way)" ""
10
11 $(PACKAGE).conf.inplace   : $(PACKAGE).conf.in
12         $(CPP) $(RAWCPP_FLAGS) -I$(GHC_INCLUDE_DIR) -x c $(PACKAGE_CPP_OPTS) $< \
13                 | sed 's/^#.*$$//g' >$@
14
15 $(PACKAGE).conf.installed : $(PACKAGE).conf.in
16         $(CPP) $(RAWCPP_FLAGS) -I$(GHC_INCLUDE_DIR) -DINSTALLED -x c $(PACKAGE_CPP_OPTS) $< \
17                 | sed 's/^#.*$$//g' >$@
18
19 boot all :: $(PACKAGE).conf.inplace $(PACKAGE).conf.installed
20         -$(GHC_PKG_INPLACE) --remove-package $(PACKAGE)
21         $(GHC_PKG_INPLACE) --add-package <$(PACKAGE).conf.inplace
22         -$(GHC_PKG_INPLACE) -f $(GHC_DRIVER_DIR)/package.conf --remove-package $(PACKAGE)
23         $(GHC_PKG_INPLACE)  -f $(GHC_DRIVER_DIR)/package.conf --add-package <$(PACKAGE).conf.installed
24
25 CLEAN_FILES += $(PACKAGE).conf.installed $(PACKAGE).conf.inplace
26
27 endif # $(way) == ""
28
29 # -----------------------------------------------------------------------------
30 # Building the static library libHS<pkg>.a
31
32 HC              = $(GHC_INPLACE)
33
34 SRC_HSC2HS_OPTS += -I.
35
36 ifeq "$(NON_HS_PACKAGE)" ""
37 SRC_HC_OPTS     += -package-name $(PACKAGE)
38 SRC_HC_OPTS     += $(GhcLibHcOpts)
39 SRC_HC_OPTS     += $(patsubst %, -package %, $(PACKAGE_DEPS))
40 endif
41
42 LIBRARY         = libHS$(PACKAGE)$(_way).a
43
44 WAYS            = $(GhcLibWays)
45
46 all :: $(LIBRARY)
47
48 # POSSIBLE alternative version using --make:
49 #
50 # lib : $(HS_SRCS)
51 #       $(GHC_INPLACE) $(HC_OPTS) --make $(HS_SRCS)
52
53 # $(LIBNAME) : lib
54 #       $(RM) $@
55 #       $(AR) $(AR_OPTS) $@ $(HS_OBJS)
56 #       $(RANLIB) $@
57
58 # %.o : %.hs
59 #       $(GHC_INPLACE) $(HC_OPTS) --make $<
60 # %.o : %.lhs
61 #       $(GHC_INPLACE) $(HC_OPTS) --make $<
62
63 #--------------------------------------------------------------
64 # Building dynamically-linkable libraries for GHCi
65 #
66 # Build $(GHCI_LIBRARY) from $(OBJS)
67 #
68 # Why?  GHCi can only link .o files (at the moment), not .a files
69 # so we have to build libFoo.o as well as libFoo.a
70 #
71 # Furthermore, GHCi currently never loads 
72 # profiling libraries (or other non-std ways)
73 #
74 # Inputs:
75 #   $(GHCI_LIBRARY)
76 #
77 # Outputs:
78 #   Rule to build $(GHCI_LIBRARY)
79
80 ifeq "$(way)" ""
81 ifeq "$(GhcWithInterpreter)" "YES"
82
83 GHCI_LIBRARY = HS$(PACKAGE)$(_cbits)$(_way).o
84
85 INSTALL_LIBS += $(GHCI_LIBRARY)
86 CLEAN_FILES  += $(GHCI_LIBRARY)
87
88 all :: $(GHCI_LIBRARY)
89
90 ifneq "$(DONT_WANT_STD_GHCI_LIB_RULE)" "YES"
91 # If you don't want to build GHCI_LIBRARY the 'standard' way,
92 # set DONT_WANT_STD_GHCI_LIB_RULE to YES. The Prelude and
93 # hslibs/Win32 uses this 'feature', which will go away soon
94 # when we can use a "fixed" ld.
95 #
96 $(GHCI_LIBRARY) : $(LIBOBJS)
97         $(LD) -r $(LD_X) -o $@ $(LIBOBJS)
98
99 endif # DONT_WANT_STD_GHCI_LIB_RULE
100 endif # GhcWithInterpreter
101 endif # way
102
103 # -----------------------------------------------------------------------------
104 # Installation; need to install .hi files as well as libraries
105 #
106 # The interface files are put inside the $(libdir), since they
107 # might (potentially) be platform specific..
108 #
109 # override is used here because for binary distributions, datadir is
110 # set on the command line. sigh.
111 #
112
113 override datadir:=$(libdir)/imports/$(PACKAGE)
114
115 # -----------------------------------------------------------------------------
116 # Dependencies
117
118 MKDEPENDHS = $(GHC_INPLACE)
119 SRC_MKDEPENDC_OPTS += $(patsubst %,-I%,$(ALL_DIRS)) -I$(GHC_INCLUDE_DIR)
120
121 endif # $(PACKAGE) /= ""
122