summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghci/linking/Makefile
blob: bfbcf243504639ea0afd6c603724cf04b4594fc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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
	"$(AR)" cqs dir001/libfoo.a dir001/foo.o
	echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -Ldir001 -lfoo TestLink.hs

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

ifeq "$(WINDOWS)" "YES"
DLL = $1.dll
else ifeq "$(DARWIN)" "YES"
DLL = lib$1.dylib
else
DLL = lib$1.so
endif

.PHONY: ghcilink002
ghcilink002 :
	$(RM) -rf dir002
	mkdir dir002
	"$(TEST_HC)" -c -dynamic f.c -o dir002/foo.o
	"$(TEST_HC)" -no-auto-link-packages -shared -v0 -o dir002/$(call DLL,foo) dir002/foo.o
	echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -Ldir002 -lfoo TestLink.hs

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

# 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)
	echo 'name: test' >>$(PKG004)
	echo 'version: 1.0' >>$(PKG004)
	echo 'id: test-XXX' >>$(PKG004)
	echo 'key: test-XXX' >>$(PKG004)
	echo 'library-dirs: $${pkgroot}' >>$(PKG004)
	echo 'extra-libraries: foo' >>$(PKG004)
	'$(GHC_PKG)' init $(LOCAL_PKGCONF004)
	'$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF004) register $(PKG004) -v0
	#
	"$(TEST_HC)" -c f.c -o dir004/foo.o
	"$(AR)" cqs dir004/libfoo.a dir004/foo.o
	echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -package-db $(LOCAL_PKGCONF004) -package test TestLink.hs

# 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)
	echo 'name: test' >>$(PKG005)
	echo 'version: 1.0' >>$(PKG005)
	echo 'id: test-XXX' >>$(PKG005)
	echo 'key: test-XXX' >>$(PKG005)
	echo 'library-dirs: $${pkgroot}' >>$(PKG005)
	echo 'extra-libraries: foo' >>$(PKG005)
	'$(GHC_PKG)' init $(LOCAL_PKGCONF005)
	'$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF005) register $(PKG005) -v0
	#
	"$(TEST_HC)" -c -dynamic f.c -o dir005/foo.o
	"$(TEST_HC)" -no-auto-link-packages -shared -o dir005/$(call DLL,foo) dir005/foo.o
	echo "test" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -package-db $(LOCAL_PKGCONF005) -package test TestLink.hs

# 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)
	echo "key: test-XXX" >>$(PKG006)
ifeq "$(WINDOWS)" "YES"
	echo "extra-libraries: stdc++-6" >>$(PKG006)
else
	echo "extra-libraries: stdc++" >>$(PKG006)
endif
	'$(GHC_PKG)' init $(LOCAL_PKGCONF006)
	'$(GHC_PKG)' --no-user-package-db -f $(LOCAL_PKGCONF006) register $(PKG006) -v0
	#
	echo ":q" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) -package-db $(LOCAL_PKGCONF006) -package test

.PHONY: T3333
T3333:
	"$(TEST_HC)" -c T3333.c -o T3333.o
	echo "weak_test 10" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) T3333.hs T3333.o

.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

.PHONY: T15729
T15729:
	"$(TEST_HC)" -fPIC -c T15729.c -o bss.o
	echo "main" | "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) bss.o T15729.hs