[project @ 2002-02-17 17:41:44 by panne]
[ghc-hetmet.git] / mk / package.mk
1 # -----------------------------------------------------------------------------
2 # $Id: package.mk,v 1.7 2002/02/17 17:41:44 panne 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) --update-package <$(PACKAGE).conf.inplace
21         $(GHC_PKG_INPLACE)  -f $(GHC_DRIVER_DIR)/package.conf --update-package <$(PACKAGE).conf.installed
22
23 CLEAN_FILES += $(PACKAGE).conf.installed $(PACKAGE).conf.inplace
24
25 endif # $(way) == ""
26
27 # -----------------------------------------------------------------------------
28 # Building the static library libHS<pkg>.a
29
30 HC              = $(GHC_INPLACE)
31
32 SRC_HSC2HS_OPTS += -I.
33
34 ifeq "$(NON_HS_PACKAGE)" ""
35 SRC_HC_OPTS     += -package-name $(PACKAGE)
36 SRC_HC_OPTS     += $(GhcLibHcOpts)
37 SRC_HC_OPTS     += $(patsubst %, -package %, $(PACKAGE_DEPS))
38 endif
39
40 LIBRARY         = libHS$(PACKAGE)$(_way).a
41
42 WAYS            = $(GhcLibWays)
43
44 all :: $(LIBRARY)
45
46 # POSSIBLE alternative version using --make:
47 #
48 # lib : $(HS_SRCS)
49 #       $(GHC_INPLACE) $(HC_OPTS) --make $(HS_SRCS)
50
51 # $(LIBNAME) : lib
52 #       $(RM) $@
53 #       $(AR) $(AR_OPTS) $@ $(HS_OBJS)
54 #       $(RANLIB) $@
55
56 # %.o : %.hs
57 #       $(GHC_INPLACE) $(HC_OPTS) --make $<
58 # %.o : %.lhs
59 #       $(GHC_INPLACE) $(HC_OPTS) --make $<
60
61 # -----------------------------------------------------------------------------
62 # Installation; need to install .hi files as well as libraries
63
64 ifeq "$(DLLized)" "YES"
65 INSTALL_PROGS += $(DLL_NAME)
66 INSTALL_LIBS += $(patsubst %.a,%_imp.a, $(LIBRARY))
67 endif
68
69 # The interface files are put inside the $(libdir), since they
70 # might (potentially) be platform specific..
71 #
72 # override is used here because for binary distributions, datadir is
73 # set on the command line. sigh.
74 override datadir:=$(libdir)/imports/$(PACKAGE)
75
76 # If the lib consists of a hierachy of modules, we must retain the directory
77 # structure when we install the interfaces.
78 ifeq "$(HIERARCHICAL_LIB)" "YES"
79 INSTALL_DATAS_WITH_DIRS += $(HS_IFACES)
80 ifneq "$(ALL_DIRS)" ""
81 install ::
82         @for i in $(ALL_DIRS); do \
83                 $(INSTALL_DIR) $(datadir)/$$i; \
84         done
85 endif
86 else
87 INSTALL_DATAS += $(HS_IFACES)
88 endif
89
90 # -----------------------------------------------------------------------------
91 # Dependencies
92
93 MKDEPENDHS = $(GHC_INPLACE)
94 SRC_MKDEPENDC_OPTS += $(patsubst %,-I%,$(ALL_DIRS)) -I$(GHC_INCLUDE_DIR)
95
96 endif # $(PACKAGE) /= ""
97
98 # install library (could be implicitly specified or explicitly, like libHS*_cbits.a)
99 INSTALL_LIBS  += $(LIBRARY)
100
101 #--------------------------------------------------------------
102 # Building dynamically-linkable libraries for GHCi
103 #
104 # Build $(GHCI_LIBRARY) whenever we build $(LIBRARY)
105 #
106 # Why?  GHCi can only link .o files (at the moment), not .a files
107 # so we have to build libFoo.o as well as libFoo.a
108 #
109 # Furthermore, GHCi currently never loads 
110 # profiling libraries (or other non-std ways)
111
112 ifneq "$(LIBRARY)" ""
113
114 ifeq "$(way)" ""
115 ifeq "$(GhcWithInterpreter)" "YES"
116
117 GHCI_LIBRARY = $(patsubst lib%.a,%.o,$(LIBRARY))
118
119 INSTALL_LIBS += $(GHCI_LIBRARY)
120 CLEAN_FILES  += $(GHCI_LIBRARY)
121
122 all :: $(GHCI_LIBRARY)
123
124 ifneq "$(DONT_WANT_STD_GHCI_LIB_RULE)" "YES"
125 # If you don't want to build GHCI_LIBRARY the 'standard' way,
126 # set DONT_WANT_STD_GHCI_LIB_RULE to YES. The Prelude and
127 # hslibs/Win32 uses this 'feature', which will go away soon
128 # when we can use a "fixed" ld.
129 #
130 $(GHCI_LIBRARY) : $(LIBOBJS)
131         $(LD) -r $(LD_X) -o $@ $(LIBOBJS)
132
133 endif # DONT_WANT_STD_GHCI_LIB_RULE
134 endif # GhcWithInterpreter
135 endif # way
136
137 endif # $(LIBRARY) /= ""