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