Error early when you register with too old a version of Cabal.
[ghc.git] / testsuite / tests / ghci / linking / Makefile
1 TOP=../../..
2 include $(TOP)/mk/boilerplate.mk
3 include $(TOP)/mk/test.mk
4
5 LOCAL_GHC_PKG = '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF)
6
7 # Test 1: ghci -Ldir -lfoo
8 # with dir/libfoo.a
9
10 .PHONY: ghcilink001
11 ghcilink001 :
12 $(RM) -rf dir001
13 mkdir dir001
14 "$(TEST_HC)" -c f.c -o dir001/foo.o
15 "$(AR)" cqs dir001/libfoo.a dir001/foo.o
16 echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -Ldir001 -lfoo TestLink.hs
17
18 # Test 2: ghci -Ldir -lfoo
19 # with dir/libfoo.so
20
21 ifeq "$(WINDOWS)" "YES"
22 DLL = $1.dll
23 else ifeq "$(DARWIN)" "YES"
24 DLL = lib$1.dylib
25 else
26 DLL = lib$1.so
27 endif
28
29 .PHONY: ghcilink002
30 ghcilink002 :
31 $(RM) -rf dir002
32 mkdir dir002
33 "$(TEST_HC)" -c -dynamic f.c -o dir002/foo.o
34 "$(TEST_HC)" -no-auto-link-packages -shared -v0 -o dir002/$(call DLL,foo) dir002/foo.o
35 echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -Ldir002 -lfoo TestLink.hs
36
37 # Test 3: ghci -lstdc++
38 # where libstdc++.so is normally found in a directory private to gcc,
39 # so only gcc can find it (see #5289)
40
41 .PHONY: ghcilink003
42 ghcilink003 :
43 ifeq "$(WINDOWS)" "YES"
44 echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -lstdc++-6
45 else
46 echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -lstdc++
47 endif
48
49 # Test 4:
50 # package P
51 # library-dirs: `pwd`/dir004
52 # extra-libraries: foo
53 # with
54 # dir004/libfoo.a
55
56 LOCAL_PKGCONF004=dir004/local.package.conf
57 PKG004=dir004/pkg.conf
58
59 ghcilink004 :
60 $(RM) -rf dir004
61 mkdir dir004
62 #
63 rm -f $(PKG004)
64 echo 'name: test' >>$(PKG004)
65 echo 'version: 1.0' >>$(PKG004)
66 echo 'id: test-XXX' >>$(PKG004)
67 echo 'key: test-XXX' >>$(PKG004)
68 echo 'library-dirs: $${pkgroot}' >>$(PKG004)
69 echo 'extra-libraries: foo' >>$(PKG004)
70 '$(GHC_PKG)' init $(LOCAL_PKGCONF004)
71 '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF004) register $(PKG004) -v0
72 #
73 "$(TEST_HC)" -c f.c -o dir004/foo.o
74 "$(AR)" cqs dir004/libfoo.a dir004/foo.o
75 echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF004) -package test TestLink.hs
76
77 # Test 5:
78 # package P
79 # library-dirs: `pwd`/dir005
80 # extra-libraries: foo
81 # with
82 # dir005/libfoo.so
83
84 LOCAL_PKGCONF005=dir005/ghcilink005.package.conf
85 PKG005=dir005/pkg.conf
86
87 ghcilink005 :
88 $(RM) -rf dir005
89 mkdir dir005
90 #
91 rm -f $(PKG005)
92 echo 'name: test' >>$(PKG005)
93 echo 'version: 1.0' >>$(PKG005)
94 echo 'id: test-XXX' >>$(PKG005)
95 echo 'key: test-XXX' >>$(PKG005)
96 echo 'library-dirs: $${pkgroot}' >>$(PKG005)
97 echo 'extra-libraries: foo' >>$(PKG005)
98 '$(GHC_PKG)' init $(LOCAL_PKGCONF005)
99 '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF005) register $(PKG005) -v0
100 #
101 "$(TEST_HC)" -c -dynamic f.c -o dir005/foo.o
102 "$(TEST_HC)" -no-auto-link-packages -shared -o dir005/$(call DLL,foo) dir005/foo.o
103 echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF005) -package test TestLink.hs
104
105 # Test 6:
106 # package P
107 # extra-libraries: stdc++
108
109 LOCAL_PKGCONF006=dir006/ghcilink006.package.conf
110 PKG006=dir006/pkg.conf
111
112 ghcilink006 :
113 $(RM) -rf dir006
114 mkdir dir006
115 #
116 rm -f $(PKG006)
117 echo "name: test" >>$(PKG006)
118 echo "version: 1.0" >>$(PKG006)
119 echo "id: test-XXX" >>$(PKG006)
120 echo "key: test-XXX" >>$(PKG006)
121 ifeq "$(WINDOWS)" "YES"
122 echo "extra-libraries: stdc++-6" >>$(PKG006)
123 else
124 echo "extra-libraries: stdc++" >>$(PKG006)
125 endif
126 '$(GHC_PKG)' init $(LOCAL_PKGCONF006)
127 '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF006) register $(PKG006) -v0
128 #
129 echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF006) -package test
130
131 .PHONY: T3333
132 T3333:
133 "$(TEST_HC)" -c T3333.c -o T3333.o
134 echo "weak_test 10" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 T3333.hs T3333.o