Fold base.git into ghc.git (re #8545)
[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 echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -lstdc++
44
45 # Test 4:
46 # package P
47 # library-dirs: `pwd`/dir004
48 # extra-libraries: foo
49 # with
50 # dir004/libfoo.a
51
52 LOCAL_PKGCONF004=dir004/local.package.conf
53 PKG004=dir004/pkg.conf
54
55 ghcilink004 :
56 $(RM) -rf dir004
57 mkdir dir004
58 #
59 rm -f $(PKG004)
60 echo 'name: test' >>$(PKG004)
61 echo 'version: 1.0' >>$(PKG004)
62 echo 'id: test-XXX' >>$(PKG004)
63 echo 'library-dirs: $${pkgroot}' >>$(PKG004)
64 echo 'extra-libraries: foo' >>$(PKG004)
65 echo '[]' >$(LOCAL_PKGCONF004)
66 '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF004) register $(PKG004) -v0
67 #
68 "$(TEST_HC)" -c f.c -o dir004/foo.o
69 "$(AR)" cqs dir004/libfoo.a dir004/foo.o
70 echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF004) -package test TestLink.hs
71
72 # Test 5:
73 # package P
74 # library-dirs: `pwd`/dir005
75 # extra-libraries: foo
76 # with
77 # dir005/libfoo.so
78
79 LOCAL_PKGCONF005=dir005/ghcilink005.package.conf
80 PKG005=dir005/pkg.conf
81
82 ghcilink005 :
83 $(RM) -rf dir005
84 mkdir dir005
85 #
86 rm -f $(PKG005)
87 echo 'name: test' >>$(PKG005)
88 echo 'version: 1.0' >>$(PKG005)
89 echo 'id: test-XXX' >>$(PKG005)
90 echo 'library-dirs: $${pkgroot}' >>$(PKG005)
91 echo 'extra-libraries: foo' >>$(PKG005)
92 echo '[]' >$(LOCAL_PKGCONF005)
93 '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF005) register $(PKG005) -v0
94 #
95 "$(TEST_HC)" -c -dynamic f.c -o dir005/foo.o
96 "$(TEST_HC)" -no-auto-link-packages -shared -o dir005/$(call DLL,foo) dir005/foo.o
97 echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF005) -package test TestLink.hs
98
99 # Test 6:
100 # package P
101 # extra-libraries: stdc++
102
103 LOCAL_PKGCONF006=dir006/ghcilink006.package.conf
104 PKG006=dir006/pkg.conf
105
106 ghcilink006 :
107 $(RM) -rf dir006
108 mkdir dir006
109 #
110 rm -f $(PKG006)
111 echo "name: test" >>$(PKG006)
112 echo "version: 1.0" >>$(PKG006)
113 echo "id: test-XXX" >>$(PKG006)
114 echo "extra-libraries: stdc++" >>$(PKG006)
115 echo "[]" >$(LOCAL_PKGCONF006)
116 '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF006) register $(PKG006) -v0
117 #
118 echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF006) -package test
119
120 .PHONY: T3333
121 T3333:
122 "$(TEST_HC)" -c T3333.c -o T3333.o
123 echo "weak_test 10" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 T3333.hs T3333.o