Merge branch 'master' of http://darcs.haskell.org/testsuite
[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-conf -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)" -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-conf -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-conf $(LOCAL_PKGCONF004) -package test TestLink.hs
71
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 'library-dirs: $${pkgroot}' >>$(PKG005)
92 echo 'extra-libraries: foo' >>$(PKG005)
93 echo '[]' >$(LOCAL_PKGCONF005)
94 '$(GHC_PKG)' --no-user-package-conf -f $(LOCAL_PKGCONF005) register $(PKG005) -v0
95 #
96 "$(TEST_HC)" -c -dynamic f.c -o dir005/foo.o
97 "$(TEST_HC)" -shared -o dir005/$(call DLL,foo) dir005/foo.o
98 echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-conf $(LOCAL_PKGCONF005) -package test TestLink.hs
99
100 # Test 6:
101 # package P
102 # extra-libraries: stdc++
103
104 LOCAL_PKGCONF006=dir006/ghcilink006.package.conf
105 PKG006=dir006/pkg.conf
106
107 ghcilink006 :
108 $(RM) -rf dir006
109 mkdir dir006
110 #
111 rm -f $(PKG006)
112 echo "name: test" >>$(PKG006)
113 echo "version: 1.0" >>$(PKG006)
114 echo "id: test-XXX" >>$(PKG006)
115 echo "extra-libraries: stdc++" >>$(PKG006)
116 echo "[]" >$(LOCAL_PKGCONF006)
117 '$(GHC_PKG)' --no-user-package-conf -f $(LOCAL_PKGCONF006) register $(PKG006) -v0
118 #
119 echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-conf $(LOCAL_PKGCONF006) -package test
120