Makefile 3.63 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
TOP=../../..
include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk

# 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
13
	"$(AR)" cqs dir001/libfoo.a dir001/foo.o
14
	echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -Ldir001 -lfoo TestLink.hs
15 16 17 18 19 20

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

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

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

# 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 :
41
	echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -lstdc++
42

43
# Test 4:
44 45 46
#   package P
#      library-dirs: `pwd`/dir004
#      extra-libraries: foo
47
#   with
48 49 50 51 52 53 54 55 56 57
#    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
58 59 60
	echo 'name: test' >>$(PKG004)
	echo 'version: 1.0' >>$(PKG004)
	echo 'id: test-XXX' >>$(PKG004)
61
	echo 'key: test-XXX' >>$(PKG004)
Ian Lynagh's avatar
Ian Lynagh committed
62 63
	echo 'library-dirs: $${pkgroot}' >>$(PKG004)
	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 73 74
#   package P
#      library-dirs: `pwd`/dir005
#      extra-libraries: foo
75
#   with
76 77 78 79 80 81 82 83 84 85
#    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
86 87 88
	echo 'name: test' >>$(PKG005)
	echo 'version: 1.0' >>$(PKG005)
	echo 'id: test-XXX' >>$(PKG005)
89
	echo 'key: test-XXX' >>$(PKG005)
Ian Lynagh's avatar
Ian Lynagh committed
90 91
	echo 'library-dirs: $${pkgroot}' >>$(PKG005)
	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 101 102 103 104 105 106 107 108 109 110 111 112 113
#   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)
114
	echo "key: test-XXX" >>$(PKG006)
115 116 117
ifeq "$(WINDOWS)" "YES"
	echo "extra-libraries: stdc++-6" >>$(PKG006)
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

aljee@hyper.cx's avatar
aljee@hyper.cx committed
125 126 127
.PHONY: T3333
T3333:
	"$(TEST_HC)" -c T3333.c -o T3333.o
128
	echo "weak_test 10" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T3333.hs T3333.o
129 130 131 132 133 134 135 136

.PHONY: T14708
T14708:
	$(RM) -rf T14708scratch
	mkdir T14708scratch
	"$(TEST_HC)" -c add.c -o T14708scratch/add.o
	"$(AR)" cqs T14708scratch/libadd.a T14708scratch/add.o
	-"$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -LT14708scratch -ladd T14708.hs