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