1 # -----------------------------------------------------------------------------
2 # $Id: package.mk,v 1.15 2002/07/02 08:41:28 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 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
23 CLEAN_FILES += $(PACKAGE).conf.installed $(PACKAGE).conf.inplace
27 # -----------------------------------------------------------------------------
28 # Building the static library libHS<pkg>.a
32 SRC_HSC2HS_OPTS += -I.
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))
40 LIBRARY = libHS$(PACKAGE)$(_way).a
46 # POSSIBLE alternative version using --make:
49 # $(GHC_INPLACE) $(HC_OPTS) --make $(HS_SRCS)
53 # $(AR) $(AR_OPTS) $@ $(HS_OBJS)
57 # $(GHC_INPLACE) $(HC_OPTS) --make $<
59 # $(GHC_INPLACE) $(HC_OPTS) --make $<
61 # -----------------------------------------------------------------------------
62 # Installation; need to install .hi files as well as libraries
64 ifeq "$(DLLized)" "YES"
65 INSTALL_PROGS += $(DLL_NAME)
66 INSTALL_LIBS += $(patsubst %.a,%_imp.a, $(LIBRARY))
69 # The interface files are put inside the $(libdir), since they
70 # might (potentially) be platform specific..
72 ifacedir = $(libdir)/imports/$(PACKAGE)
74 # If the lib consists of a hierachy of modules, we must retain the directory
75 # structure when we install the interfaces.
76 ifeq "$(HIERARCHICAL_LIB)" "YES"
77 INSTALL_IFACES_WITH_DIRS += $(HS_IFACES)
78 ifneq "$(ALL_DIRS)" ""
80 @for i in $(ALL_DIRS); do \
81 $(INSTALL_DIR) $(ifacedir)/$$i; \
85 INSTALL_IFACES += $(HS_IFACES)
88 # -----------------------------------------------------------------------------
91 MKDEPENDHS = $(GHC_INPLACE)
92 SRC_MKDEPENDC_OPTS += $(addprefix -I,$(ALL_DIRS)) -I$(GHC_INCLUDE_DIR)
94 endif # $(PACKAGE) /= ""
96 # install library (could be implicitly specified or explicitly, like libHS*_cbits.a)
97 INSTALL_LIBS += $(LIBRARY)
99 #--------------------------------------------------------------
100 # Building dynamically-linkable libraries for GHCi
102 # Build $(GHCI_LIBRARY) whenever we build $(LIBRARY)
104 # Why? GHCi can only link .o files (at the moment), not .a files
105 # so we have to build libFoo.o as well as libFoo.a
107 # Furthermore, GHCi currently never loads
108 # profiling libraries (or other non-std ways)
110 ifneq "$(LIBRARY)" ""
113 ifeq "$(GhcWithInterpreter)" "YES"
115 GHCI_LIBRARY = $(patsubst lib%.a,%.o,$(LIBRARY))
117 INSTALL_LIBS += $(GHCI_LIBRARY)
118 CLEAN_FILES += $(GHCI_LIBRARY)
120 all :: $(GHCI_LIBRARY)
122 ifneq "$(DONT_WANT_STD_GHCI_LIB_RULE)" "YES"
123 # If you don't want to build GHCI_LIBRARY the 'standard' way,
124 # set DONT_WANT_STD_GHCI_LIB_RULE to YES. The Prelude and
125 # hslibs/Win32 uses this 'feature', which will go away soon
126 # when we can use a "fixed" ld.
128 $(GHCI_LIBRARY) : $(LIBOBJS)
129 $(LD) -r $(LD_X) -o $@ $(STUBOBJS) $(LIBOBJS)
131 endif # DONT_WANT_STD_GHCI_LIB_RULE
132 endif # GhcWithInterpreter
135 # -----------------------------------------------------------------------------
136 # Doc building with Haddock
138 ifneq "$(NO_HADDOCK_DOCS)" "YES"
140 HS_PPS = $(addsuffix .raw-hs, $(basename $(filter-out $(EXCLUDED_HADDOCK_SRCS), $(HS_SRCS))))
143 HTML_DOC = $(HTML_DIR)/index.html
148 $(HTML_DOC) : $(HS_PPS) $(HADDOCK_INPLACE)
149 @$(INSTALL_DIR) $(HTML_DIR)
150 $(HADDOCK_INPLACE) $(HADDOCK_OPTS) -h -o $(HTML_DIR) $(HS_PPS) \
151 --dump-interface=$(PACKAGE).haddock \
152 $(foreach pkg, $(PACKAGE_DEPS), \
153 --read-interface=../$(pkg),../$(pkg)/$(pkg).haddock)
156 $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
159 $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
161 install-docs :: $(HTML_DOC)
162 @$(INSTALL_DIR) $(datadir)/html/$(PACKAGE)
163 @for i in $(HTML_DIR)/*; do \
164 echo $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/$(PACKAGE); \
165 $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/$(PACKAGE); \
169 endif # NO_HADDOCK_DOCS
171 # -----------------------------------------------------------------------------
173 endif # $(LIBRARY) /= ""