Update Hadrian
[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 echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -lstdc++
42
43 # Test 4:
44 # package P
45 # library-dirs: `pwd`/dir004
46 # extra-libraries: foo
47 # with
48 # dir004/libfoo.a
49
50 LOCAL_PKGCONF004=dir004/local.package.conf
51 PKG004=dir004/pkg.conf
52
53 ghcilink004 :
54 $(RM) -rf dir004
55 mkdir dir004
56 #
57 rm -f $(PKG004)
58 echo 'name: test' >>$(PKG004)
59 echo 'version: 1.0' >>$(PKG004)
60 echo 'id: test-XXX' >>$(PKG004)
61 echo 'key: test-XXX' >>$(PKG004)
62 echo 'library-dirs: $${pkgroot}' >>$(PKG004)
63 echo 'extra-libraries: foo' >>$(PKG004)
64 '$(GHC_PKG)' init $(LOCAL_PKGCONF004)
65 '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF004) register $(PKG004) -v0
66 #
67 "$(TEST_HC)" -c f.c -o dir004/foo.o
68 "$(AR)" cqs dir004/libfoo.a dir004/foo.o
69 echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -package-db $(LOCAL_PKGCONF004) -package test TestLink.hs
70
71 # Test 5:
72 # package P
73 # library-dirs: `pwd`/dir005
74 # extra-libraries: foo
75 # with
76 # dir005/libfoo.so
77
78 LOCAL_PKGCONF005=dir005/ghcilink005.package.conf
79 PKG005=dir005/pkg.conf
80
81 ghcilink005 :
82 $(RM) -rf dir005
83 mkdir dir005
84 #
85 rm -f $(PKG005)
86 echo 'name: test' >>$(PKG005)
87 echo 'version: 1.0' >>$(PKG005)
88 echo 'id: test-XXX' >>$(PKG005)
89 echo 'key: test-XXX' >>$(PKG005)
90 echo 'library-dirs: $${pkgroot}' >>$(PKG005)
91 echo 'extra-libraries: foo' >>$(PKG005)
92 '$(GHC_PKG)' init $(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)" $(TEST_HC_OPTS_INTERACTIVE) -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 "key: test-XXX" >>$(PKG006)
115 ifeq "$(WINDOWS)" "YES"
116 echo "extra-libraries: stdc++-6" >>$(PKG006)
117 else
118 echo "extra-libraries: stdc++" >>$(PKG006)
119 endif
120 '$(GHC_PKG)' init $(LOCAL_PKGCONF006)
121 '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF006) register $(PKG006) -v0
122 #
123 echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -package-db $(LOCAL_PKGCONF006) -package test
124
125 .PHONY: T3333
126 T3333:
127 "$(TEST_HC)" -c T3333.c -o T3333.o
128 echo "weak_test 10" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T3333.hs T3333.o