1 # -----------------------------------------------------------------------------
2 # $Id: package.mk,v 1.23 2003/03/31 12:42:04 simonmar Exp $
6 # -----------------------------------------------------------------------------
7 # Build the package configuration file and tell the compiler about it.
11 $(PACKAGE).conf.inplace : $(PACKAGE).conf.in
12 $(CPP) $(RAWCPP_FLAGS) -I$(GHC_INCLUDE_DIR) -x c $(PACKAGE_CPP_OPTS) $< \
13 | sed 's/^#.*$$//g' >$@
15 $(PACKAGE).conf.installed : $(PACKAGE).conf.in
16 $(CPP) $(RAWCPP_FLAGS) -I$(GHC_INCLUDE_DIR) -DINSTALLING -x c $(PACKAGE_CPP_OPTS) $< \
17 | sed 's/^#.*$$//g' >$@
19 # we could be more accurate here and add a dependency on
20 # ghc/driver/package.conf, but that doesn't work too well because of
21 # make's limited accuracy with modification times: when doing 'make
22 # boot' in multiple packages, make won't detect that the package
23 # configuration needs updating if it was updated already in the last
26 # The stamp file goes in $(GHC_DRIVER_DIR), so that if someone happens
27 # to 'make clean' in ghc without cleaning in libraries too, the packages
28 # will be correctly re-installed.
30 STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
31 CLEAN_FILES += $(STAMP_PKG_CONF)
33 ifneq "$(BootingFromHc)" "YES"
34 boot all :: $(STAMP_PKG_CONF)
37 $(STAMP_PKG_CONF) : $(PACKAGE).conf.inplace $(PACKAGE).conf.installed
38 $(GHC_PKG_INPLACE) --update-package <$(PACKAGE).conf.inplace
39 $(GHC_PKG_INPLACE) -f $(GHC_DRIVER_DIR)/package.conf --update-package <$(PACKAGE).conf.installed
40 @touch $(STAMP_PKG_CONF)
42 CLEAN_FILES += $(PACKAGE).conf.installed $(PACKAGE).conf.inplace
46 # -----------------------------------------------------------------------------
47 # Building the static library libHS<pkg>.a
51 SRC_HSC2HS_OPTS += -I.
53 ifeq "$(NON_HS_PACKAGE)" ""
54 SRC_HC_OPTS += -package-name $(PACKAGE)
55 SRC_HC_OPTS += $(GhcLibHcOpts)
56 SRC_HC_OPTS += $(patsubst %, -package %, $(PACKAGE_DEPS))
59 LIBRARY = libHS$(PACKAGE)$(_way).a
65 # POSSIBLE alternative version using --make:
68 # $(GHC_INPLACE) $(HC_OPTS) --make $(HS_SRCS)
72 # $(AR) $(AR_OPTS) $@ $(HS_OBJS)
76 # $(GHC_INPLACE) $(HC_OPTS) --make $<
78 # $(GHC_INPLACE) $(HC_OPTS) --make $<
80 # -----------------------------------------------------------------------------
81 # Installation; need to install .hi files as well as libraries
83 ifeq "$(DLLized)" "YES"
84 INSTALL_PROGS += $(DLL_NAME)
85 INSTALL_LIBS += $(patsubst %.a,%_imp.a, $(LIBRARY))
88 # The interface files are put inside the $(libdir), since they
89 # might (potentially) be platform specific..
91 ifacedir = $(libdir)/imports/$(PACKAGE)
93 # If the lib consists of a hierachy of modules, we must retain the directory
94 # structure when we install the interfaces.
95 ifeq "$(HIERARCHICAL_LIB)" "YES"
96 INSTALL_IFACES_WITH_DIRS += $(HS_IFACES)
97 ifneq "$(ALL_DIRS)" ""
99 @for i in $(ALL_DIRS); do \
100 $(INSTALL_DIR) $(ifacedir)/$$i; \
104 INSTALL_IFACES += $(HS_IFACES)
107 # -----------------------------------------------------------------------------
110 MKDEPENDHS = $(GHC_INPLACE)
111 SRC_MKDEPENDC_OPTS += $(addprefix -I,$(ALL_DIRS)) -I$(GHC_INCLUDE_DIR)
113 endif # $(PACKAGE) /= ""
115 # install library (could be implicitly specified or explicitly, like libHS*_cbits.a)
116 INSTALL_LIBS += $(LIBRARY)
118 #--------------------------------------------------------------
119 # Building dynamically-linkable libraries for GHCi
121 # Build $(GHCI_LIBRARY) whenever we build $(LIBRARY)
123 # Why? GHCi can only link .o files (at the moment), not .a files
124 # so we have to build libFoo.o as well as libFoo.a
126 # Furthermore, GHCi currently never loads
127 # profiling libraries (or other non-std ways)
129 ifneq "$(LIBRARY)" ""
132 ifeq "$(GhcWithInterpreter)" "YES"
134 GHCI_LIBRARY = $(patsubst lib%.a,%.o,$(LIBRARY))
136 INSTALL_LIBS += $(GHCI_LIBRARY)
137 CLEAN_FILES += $(GHCI_LIBRARY)
139 all :: $(GHCI_LIBRARY)
141 ifneq "$(DONT_WANT_STD_GHCI_LIB_RULE)" "YES"
142 # If you don't want to build GHCI_LIBRARY the 'standard' way,
143 # set DONT_WANT_STD_GHCI_LIB_RULE to YES. The Prelude and
144 # hslibs/Win32 uses this 'feature', which will go away soon
145 # when we can use a "fixed" ld.
147 $(GHCI_LIBRARY) : $(LIBOBJS)
148 $(LD) -r $(LD_X) -o $@ $(STUBOBJS) $(LIBOBJS)
150 endif # DONT_WANT_STD_GHCI_LIB_RULE
151 endif # GhcWithInterpreter
154 # -----------------------------------------------------------------------------
155 # Doc building with Haddock
157 ifneq "$(NO_HADDOCK_DOCS)" "YES"
159 HS_PPS = $(addsuffix .raw-hs, $(basename $(filter-out $(EXCLUDED_HADDOCK_SRCS), $(HS_SRCS))))
162 HTML_DOC = $(HTML_DIR)/index.html
166 CLEAN_FILES += $(HS_PPS) $(addsuffix .tmp, $(HS_SRCS))
170 @echo Haddock must be installed in order to build HTML library documentation.
171 @echo Please install Haddock and re-configure.
178 $(RM) -rf $(HTML_DIR)
180 $(HTML_DOC) : $(HS_PPS)
181 @$(INSTALL_DIR) $(HTML_DIR)
182 $(HADDOCK) $(HADDOCK_OPTS) -h -o $(HTML_DIR) $(HS_PPS) \
183 --dump-interface=$(PACKAGE).haddock \
184 $(foreach pkg, $(PACKAGE_DEPS), \
185 --read-interface=../$(pkg),../$(pkg)/$(pkg).haddock)
188 $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
191 $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
193 install-docs :: $(HTML_DOC)
194 @$(INSTALL_DIR) $(datadir)/html/$(PACKAGE)
195 @for i in $(HTML_DIR)/*; do \
196 echo $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/$(PACKAGE); \
197 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/$(PACKAGE); \
199 $(INSTALL_DATA) $(INSTALL_OPTS) $(PACKAGE).haddock $(datadir)/html/$(PACKAGE)
202 endif # NO_HADDOCK_DOCS
204 # -----------------------------------------------------------------------------
206 endif # $(LIBRARY) /= ""