1 # -----------------------------------------------------------------------------
2 # $Id: package.mk,v 1.17 2002/07/23 11:23:55 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 STAMP_PKG_CONF = stamp-pkg-conf
27 CLEAN_FILES += $(STAMP_PKG_CONF)
29 boot all :: $(STAMP_PKG_CONF)
31 $(STAMP_PKG_CONF) : $(PACKAGE).conf.inplace $(PACKAGE).conf.installed
32 $(GHC_PKG_INPLACE) --update-package <$(PACKAGE).conf.inplace
33 $(GHC_PKG_INPLACE) -f $(GHC_DRIVER_DIR)/package.conf --update-package <$(PACKAGE).conf.installed
34 @touch $(STAMP_PKG_CONF)
36 CLEAN_FILES += $(PACKAGE).conf.installed $(PACKAGE).conf.inplace
40 # -----------------------------------------------------------------------------
41 # Building the static library libHS<pkg>.a
45 SRC_HSC2HS_OPTS += -I.
47 ifeq "$(NON_HS_PACKAGE)" ""
48 SRC_HC_OPTS += -package-name $(PACKAGE)
49 SRC_HC_OPTS += $(GhcLibHcOpts)
50 SRC_HC_OPTS += $(patsubst %, -package %, $(PACKAGE_DEPS))
53 LIBRARY = libHS$(PACKAGE)$(_way).a
59 # POSSIBLE alternative version using --make:
62 # $(GHC_INPLACE) $(HC_OPTS) --make $(HS_SRCS)
66 # $(AR) $(AR_OPTS) $@ $(HS_OBJS)
70 # $(GHC_INPLACE) $(HC_OPTS) --make $<
72 # $(GHC_INPLACE) $(HC_OPTS) --make $<
74 # -----------------------------------------------------------------------------
75 # Installation; need to install .hi files as well as libraries
77 ifeq "$(DLLized)" "YES"
78 INSTALL_PROGS += $(DLL_NAME)
79 INSTALL_LIBS += $(patsubst %.a,%_imp.a, $(LIBRARY))
82 # The interface files are put inside the $(libdir), since they
83 # might (potentially) be platform specific..
85 ifacedir = $(libdir)/imports/$(PACKAGE)
87 # If the lib consists of a hierachy of modules, we must retain the directory
88 # structure when we install the interfaces.
89 ifeq "$(HIERARCHICAL_LIB)" "YES"
90 INSTALL_IFACES_WITH_DIRS += $(HS_IFACES)
91 ifneq "$(ALL_DIRS)" ""
93 @for i in $(ALL_DIRS); do \
94 $(INSTALL_DIR) $(ifacedir)/$$i; \
98 INSTALL_IFACES += $(HS_IFACES)
101 # -----------------------------------------------------------------------------
104 MKDEPENDHS = $(GHC_INPLACE)
105 SRC_MKDEPENDC_OPTS += $(addprefix -I,$(ALL_DIRS)) -I$(GHC_INCLUDE_DIR)
107 endif # $(PACKAGE) /= ""
109 # install library (could be implicitly specified or explicitly, like libHS*_cbits.a)
110 INSTALL_LIBS += $(LIBRARY)
112 #--------------------------------------------------------------
113 # Building dynamically-linkable libraries for GHCi
115 # Build $(GHCI_LIBRARY) whenever we build $(LIBRARY)
117 # Why? GHCi can only link .o files (at the moment), not .a files
118 # so we have to build libFoo.o as well as libFoo.a
120 # Furthermore, GHCi currently never loads
121 # profiling libraries (or other non-std ways)
123 ifneq "$(LIBRARY)" ""
126 ifeq "$(GhcWithInterpreter)" "YES"
128 GHCI_LIBRARY = $(patsubst lib%.a,%.o,$(LIBRARY))
130 INSTALL_LIBS += $(GHCI_LIBRARY)
131 CLEAN_FILES += $(GHCI_LIBRARY)
133 all :: $(GHCI_LIBRARY)
135 ifneq "$(DONT_WANT_STD_GHCI_LIB_RULE)" "YES"
136 # If you don't want to build GHCI_LIBRARY the 'standard' way,
137 # set DONT_WANT_STD_GHCI_LIB_RULE to YES. The Prelude and
138 # hslibs/Win32 uses this 'feature', which will go away soon
139 # when we can use a "fixed" ld.
141 $(GHCI_LIBRARY) : $(LIBOBJS)
142 $(LD) -r $(LD_X) -o $@ $(STUBOBJS) $(LIBOBJS)
144 endif # DONT_WANT_STD_GHCI_LIB_RULE
145 endif # GhcWithInterpreter
148 # -----------------------------------------------------------------------------
149 # Doc building with Haddock
151 ifneq "$(NO_HADDOCK_DOCS)" "YES"
153 HS_PPS = $(addsuffix .raw-hs, $(basename $(filter-out $(EXCLUDED_HADDOCK_SRCS), $(HS_SRCS))))
156 HTML_DOC = $(HTML_DIR)/index.html
161 $(HTML_DOC) : $(HS_PPS)
162 @$(INSTALL_DIR) $(HTML_DIR)
163 $(HADDOCK) $(HADDOCK_OPTS) -h -o $(HTML_DIR) $(HS_PPS) \
164 --dump-interface=$(PACKAGE).haddock \
165 $(foreach pkg, $(PACKAGE_DEPS), \
166 --read-interface=../$(pkg),../$(pkg)/$(pkg).haddock)
169 $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
172 $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
174 install-docs :: $(HTML_DOC)
175 @$(INSTALL_DIR) $(datadir)/html/$(PACKAGE)
176 @for i in $(HTML_DIR)/*; do \
177 echo $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/$(PACKAGE); \
178 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/$(PACKAGE); \
182 endif # NO_HADDOCK_DOCS
184 # -----------------------------------------------------------------------------
186 endif # $(LIBRARY) /= ""