Replace "tail -n +2" with "sed 1d", as Solaris doesn't understand the former
[ghc.git] / compat / Makefile
1 TOP=..
2 include $(TOP)/mk/boilerplate.mk
3
4 ALL_DIRS = \
5 Data \
6 Compat \
7 Distribution \
8 Distribution/Compat \
9 Distribution/Simple \
10 Language/Haskell \
11 System \
12 System/FilePath \
13 System/Directory \
14 Trace/Hpc \
15 cbits
16
17 SplitObjs=NO
18 LIBRARY = libghccompat.a
19
20 # We don't want this installed
21 NO_INSTALL_LIBRARY = YES
22
23 # Avoid building the GHCi lib, since we don't need it
24 GhcWithInterpreter = NO
25
26 # There are lots of warnings in here due to things like modules being
27 # imported that, in some versions of GHC, aren't used. Thus we don't
28 # give any warnings in here, and therefore validating with -Werror won't
29 # make the build fail.
30 SRC_HC_OPTS += -w
31
32 # Needed so that the libraries can #include relative to this directory.
33 INCLUDE_DIRS=-I. -Iinclude
34
35 SRC_HC_OPTS += $(INCLUDE_DIRS)
36 SRC_CC_OPTS += $(INCLUDE_DIRS)
37 MKDEPENDC_OPTS += $(INCLUDE_DIRS)
38
39 # Just to silence warnings
40 MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
41
42 UseGhcForCc = YES
43
44 # This library is linked to the compiler, at least in stage1, so we
45 # better make sure it is built the same "way".
46 #
47 # BUT, if GhcHcOpts includes -DDEBUG we *don't* want to compile
48 # lib/compat with -DDEBUG, because the preprocessor symbols used
49 # by the compiler may be understood differently by library code.
50 # In this particular case, it turned out that -DDEBUG made Cabal
51 # import HUnit, which might not be installed for the compiler we are
52 # compiling with (e.g. 6.2.1). Hence the filter-out.
53 SRC_HC_OPTS += $(filter-out -D%, $(GhcHcOpts) $(GhcStage1HcOpts))
54
55 # GHC 6.4 didn't have WCsubst.c, but 6.4.1 did, and we need to know
56 # this in cbits/unicode.c The patchlevel isn't normally exposed as a
57 # CPP symbol, so we have to do it by hand:
58 SRC_CC_OPTS += -D__GHC_PATCHLEVEL__=$(GhcPatchLevel)
59
60 # This module shouldn't be compiled itself, only #included into other files
61 EXCLUDED_SRCS += System/FilePath/Internal.hs
62
63 ifeq "$(ghc_ge_603)" "YES"
64 ifneq "$(ghc_ge_607)" "YES"
65 # GHC 6.3+ has Cabal, but we're replacing it:
66 SRC_HC_OPTS += -ignore-package Cabal
67
68 # only GHC 6.3+ has -ignore-package
69 SRC_HC_OPTS += -ignore-package filepath
70 endif
71 endif
72
73 ifeq "$(ghc_ge_607)" "YES"
74 SRC_HC_OPTS += -package directory
75 SRC_HC_OPTS += -package pretty
76 endif
77
78 # Some explicit dependencies, needed because ghc -M can't discover the
79 # true dependencies of these stub files.
80 System/Directory/Internals.$(way_)o : $(FPTOOLS_TOP)/libraries/directory/System/Directory/Internals.hs
81 Distribution/Compat/ReadP.$(way_) : $(FPTOOLS_TOP)/libraries/Cabal/Distribution/Compat/ReadP.hs
82 Distribution/GetOpt.$(way_)o : $(FPTOOLS_TOP)/libraries/Cabal/Distribution/GetOpt.hs
83 Distribution/InstalledPackageInfo.$(way_)o : $(FPTOOLS_TOP)/libraries/Cabal/Distribution/InstalledPackageInfo.hs
84 Distribution/License.$(way_)o : $(FPTOOLS_TOP)/libraries/Cabal/Distribution/License.hs
85 Distribution/Package.$(way_)o : $(FPTOOLS_TOP)/libraries/Cabal/Distribution/Package.hs
86 Distribution/ParseUtils.$(way_)o : $(FPTOOLS_TOP)/libraries/Cabal/Distribution/ParseUtils.hs
87 Distribution/Compiler.$(way_)o : $(FPTOOLS_TOP)/libraries/Cabal/Distribution/Compiler.hs
88 Distribution/Version.$(way_)o : $(FPTOOLS_TOP)/libraries/Cabal/Distribution/Version.hs
89 Language/Haskell/Extension.$(way_)o : $(FPTOOLS_TOP)/libraries/Cabal/Language/Haskell/Extension.hs
90 Trace/Hpc/Mix.$(way_)o : $(FPTOOLS_TOP)/libraries/hpc/Trace/Hpc/Mix.hs
91 Trace/Hpc/Util.$(way_)o : $(FPTOOLS_TOP)/libraries/hpc/Trace/Hpc/Util.hs
92 Trace/Hpc/Tix.$(way_)o : $(FPTOOLS_TOP)/libraries/hpc/Trace/Hpc/Tix.hs
93
94 cbits/unicode.o : $(FPTOOLS_TOP)/libraries/base/cbits/WCsubst.c $(FPTOOLS_TOP)/libraries/base/include/WCsubst.h
95
96 SRC_CC_OPTS += -I$(FPTOOLS_TOP)/libraries/base/cbits -I$(FPTOOLS_TOP)/libraries/base/include
97
98 # Make the #includes in the stubs independent of the current location
99 SRC_HC_OPTS += -I$(FPTOOLS_TOP)/libraries
100
101 SRC_HC_OPTS += -fglasgow-exts -no-recomp
102
103 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
104 Compat/Directory_HC_OPTS += -\#include shlobj.h
105 endif
106
107 # libghccompat is needed to build ghc-pkg, which is built during 'make boot',
108 # so we must build this library during 'make boot' too.
109 # Do a recursive 'make all' after generating dependencies, because this
110 # will work with 'make -j'.
111 ifneq "$(BootingFromHc)" "YES"
112 boot :: depend
113 $(MAKE) all
114 endif
115
116 # We don't ever want to build libghccompat as a shared library.
117 GhcBuildDylibs=NO
118
119 include $(TOP)/mk/target.mk