Makefile 3.62 KB
Newer Older
1 2 3 4
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk

5
LOCAL_GHC_PKG = '$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF)
6 7 8 9 10 11 12 13 14

# Test 1: ghci -Ldir -lfoo
#   with dir/libfoo.a

.PHONY: ghcilink001
ghcilink001 :
	$(RM) -rf dir001
	mkdir dir001
	"$(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 19 20 21 22

# Test 2: ghci -Ldir -lfoo
#   with dir/libfoo.so

ifeq "$(WINDOWS)" "YES"
DLL = $1.dll
23 24
else ifeq "$(DARWIN)" "YES"
DLL = lib$1.dylib
25 26 27 28 29 30 31 32 33
else
DLL = lib$1.so
endif

.PHONY: ghcilink002
ghcilink002 :
	$(RM) -rf dir002
	mkdir dir002
	"$(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 38 39 40 41 42

# Test 3: ghci -lstdc++
#    where libstdc++.so is normally found in a directory private to gcc,
#    so only gcc can find it (see #5289)

.PHONY: ghcilink003
ghcilink003 :
43 44 45
ifeq "$(WINDOWS)" "YES"
	echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -lstdc++-6
else
46
	echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -lstdc++
47
endif
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

# Test 4: 
#   package P
#      library-dirs: `pwd`/dir004
#      extra-libraries: foo
#   with 
#    dir004/libfoo.a

LOCAL_PKGCONF004=dir004/local.package.conf
PKG004=dir004/pkg.conf

ghcilink004 :
	$(RM) -rf dir004
	mkdir dir004
	#
	rm -f $(PKG004)
Ian Lynagh's avatar
Ian Lynagh committed
64 65 66
	echo 'name: test' >>$(PKG004)
	echo 'version: 1.0' >>$(PKG004)
	echo 'id: test-XXX' >>$(PKG004)
67
	echo 'key: test-1.0' >>$(PKG004)
Ian Lynagh's avatar
Ian Lynagh committed
68 69
	echo 'library-dirs: $${pkgroot}' >>$(PKG004)
	echo 'extra-libraries: foo' >>$(PKG004)
70
	'$(GHC_PKG)' init $(LOCAL_PKGCONF004)
71
	'$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF004) register $(PKG004) -v0
72 73
	#
	"$(TEST_HC)" -c f.c -o dir004/foo.o
74
	"$(AR)" cqs dir004/libfoo.a dir004/foo.o
75
	echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF004) -package test TestLink.hs
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91

# Test 5: 
#   package P
#      library-dirs: `pwd`/dir005
#      extra-libraries: foo
#   with 
#    dir005/libfoo.so

LOCAL_PKGCONF005=dir005/ghcilink005.package.conf
PKG005=dir005/pkg.conf

ghcilink005 :
	$(RM) -rf dir005
	mkdir dir005
	#
	rm -f $(PKG005)
Ian Lynagh's avatar
Ian Lynagh committed
92 93 94
	echo 'name: test' >>$(PKG005)
	echo 'version: 1.0' >>$(PKG005)
	echo 'id: test-XXX' >>$(PKG005)
95
	echo 'key: test-1.0' >>$(PKG005)
Ian Lynagh's avatar
Ian Lynagh committed
96 97
	echo 'library-dirs: $${pkgroot}' >>$(PKG005)
	echo 'extra-libraries: foo' >>$(PKG005)
98
	'$(GHC_PKG)' init $(LOCAL_PKGCONF005)
99
	'$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF005) register $(PKG005) -v0
100 101
	#
	"$(TEST_HC)" -c -dynamic f.c -o dir005/foo.o
102
	"$(TEST_HC)" -no-auto-link-packages -shared -o dir005/$(call DLL,foo) dir005/foo.o
103
	echo "test" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF005) -package test TestLink.hs
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119

# Test 6: 
#   package P
#      extra-libraries: stdc++

LOCAL_PKGCONF006=dir006/ghcilink006.package.conf
PKG006=dir006/pkg.conf

ghcilink006 :
	$(RM) -rf dir006
	mkdir dir006
	#
	rm -f $(PKG006)
	echo "name: test" >>$(PKG006)
	echo "version: 1.0" >>$(PKG006)
	echo "id: test-XXX" >>$(PKG006)
120
	echo "key: test-1.0" >>$(PKG006)
121 122 123
ifeq "$(WINDOWS)" "YES"
	echo "extra-libraries: stdc++-6" >>$(PKG006)
else
124
	echo "extra-libraries: stdc++" >>$(PKG006)
125
endif
126
	'$(GHC_PKG)' init $(LOCAL_PKGCONF006)
127
	'$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF006) register $(PKG006) -v0
128
	#
129
	echo ":q" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 -package-db $(LOCAL_PKGCONF006) -package test
130

aljee@hyper.cx's avatar
aljee@hyper.cx committed
131 132 133 134
.PHONY: T3333
T3333:
	"$(TEST_HC)" -c T3333.c -o T3333.o
	echo "weak_test 10" | "$(TEST_HC)" --interactive -ignore-dot-ghci -v0 T3333.hs T3333.o