1# $OpenBSD: Makefile,v 1.36 2017/07/25 12:49:29 bluhm Exp $ 2REGRESS_TARGETS = test-compile-0 test-link-0 test-install-0 \ 3 test-run-0 test-link-1 test-install-1 test-run-1 \ 4 test-link-2 test-link-3 test-link-4 \ 5 test-link-5 test-link-6 test-run-2 test-run-3 \ 6 error-1 error-2 error-3 test-alternate-0 \ 7 test-implicit-0 test-run-4 test-implicit-1 \ 8 test-help error-4 error-6 test-bond test-implicit-2 \ 9 test-Wc test-Xcompiler stupid-gdb pthread-0 pthread-1 \ 10 pthread-2 test-o-0 11 12COMPILE_TESTS = compile-mode-0 compile-mode-1 compile-mode-2 \ 13 compile-mode-3 compile-mode-4 compile-mode-5 \ 14 compile-mode-6 compile-mode-7 compile-mode-8 \ 15 compile-mode-9 compile-mode-10 compile-mode-11 \ 16 compile-mode-12 compile-mode-13 17 18FAILING_TARGETS += error-0 19REGRESS_TARGETS += version-override-0 version-override-1 error-5 \ 20 ${COMPILE_TESTS} prefer-static linkception-0 \ 21 release-0 release-1 trip-0 22FAILING_TARGETS += test-all-static 23 24REGRESS_TARGETS += ${FAILING_TARGETS} 25 26${FAILING_TARGETS}: 27 # regress target $@ is know to fail 28 @echo DISABLED 29 30compile-tests: ${COMPILE_TESTS} 31 32LIBTOOL ?= /usr/bin/libtool 33 34DEST = ${.OBJDIR}/dest/usr/local 35DEST2 = ${.OBJDIR}/dest2/usr/local 36DEST3 = ${.OBJDIR}/dest3/usr/local 37 38WEIRD = a++b.weird 39NOTWEIRD = a__b_weird 40 41test-compile-0: ${OBJLA} 42 43test-link-0: liba.la 44 45test-link-1: p1 46 47test-run-0: p1 48 ./p1 49 50test-link-2: liba0.la liba1.la 51 52test-link-3: p2 53 54test-run-2: p2 55 ./p2 56 57test-install-0: ${DEST}/lib/liba.la 58 59test-install-1: ${DEST}/bin/p1 60 61test-run-1: ${DEST}/bin/p1 62 LD_LIBRARY_PATH=${DEST}/lib ${DEST}/bin/p1 63 64test-run-3: ${DEST}/bin/p2 65 LD_LIBRARY_PATH=${DEST}/lib ${DEST}/bin/p2 66 67test-run-4: p2 68 ${LIBTOOL} --mode=execute ./p2 69 70test-help: 71 ${LIBTOOL} --help > /dev/null 72 73# affects sysutils/nut 74test-all-static: s1 75 file ${.OBJDIR}/.libs/s1 | grep 'statically linked' 76 77s1: c.lo liba.la 78 ${LIBTOOL} --mode=link ${CC} ${CFLAGS} -o s1 c.lo -la -all-static 79 80error-0: liba.la 81# this should error out (not absolute directory) 82 if ${LIBTOOL} --mode=install cp liba.la dest; then exit 1; fi 83 84test-bond: dummy3.c 85 # one single instance of -o 86 @if ${LIBTOOL} --mode=compile cc -c -o dummy3.lo -o 7 dummy3.c; then exit 1; fi 87 88dummy.c dummy2.c dummy3.c: 89 @touch $@ 90 91dummy2.lo: dummy2.c 92 ${LIBTOOL} --mode=compile --tag=disable-shared --tag=disable-static ${CC} -c -o dummy2.lo dummy2.c 93 94error-1: dummy.c 95 ${LIBTOOL} --mode=compile --tag=notatag ${CC} -c -o dummy.lo dummy.c 2>&1|fgrep -q "ignoring unknown tag" 96 97error-2: dummy.c 98 if ${LIBTOOL} --mode=compile --tag=@ ${CC} -c -o dummy.lo dummy.c; then exit 1; fi 99 100error-3: dummy.c 101 if ${LIBTOOL} --mode=foo ${CC} -c -o dummy.lo dummy.c; then exit 1; fi 102 103error-4: dummy.c 104 # libtool -mode=... is an invalid option 105 @if ${LIBTOOL} -mode=compile ${CC} -c -o dummy.lo dummy.c; then exit 1; fi 106 107error-5: libbad.la 108 fgrep -q "library_names=''" libbad.la || exit 1 109 110error-6: 111 # implicit mode detection failure: libtool foo 112 @if ${LIBTOOL} foo; then exit 1; fi 113 114prefer-static: dummy2.lo 115 if fgrep -q .libs/dummy2.o dummy2.lo; then exit 1; fi 116 117test-alternate-0: dummy.c 118 ${LIBTOOL} compile ${CC} -c -o dummy.lo dummy.c 119 ${LIBTOOL} comp ${CC} -c -o dummy.lo dummy.c 120 121test-implicit-0: dummy.c 122 ${LIBTOOL} ${CC} -c -o dummy.lo dummy.c 123 124test-implicit-1: liba.la 125 mkdir -p ${DEST2}/lib 126 ${LIBTOOL} install liba.la ${DEST2}/lib/liba.la 127 128test-implicit-2: liba.la 129 mkdir -p ${DEST3}/lib 130 ${LIBTOOL} install -c liba.la ${DEST3}/lib/liba.la 131 132version-override-0: liba9.la 133 fgrep -q "liba9.so.4.2" liba9.la 134 135version-override-1: lib${WEIRD}.la 136 fgrep -q "lib${WEIRD}.so.5.6" lib${WEIRD}.la 137 138compile-mode-0: dummy.c 139 ${LIBTOOL} --mode=compile ${CC} -c dummy.c|tee out0 140 @fgrep .libs/dummy.o out0|fgrep -q -- -fPIC 141 @fgrep -q ' dummy.o' out0 142 @if fgrep ' dummy.o' out0|fgrep -q -- -fPIC; then exit 1; fi 143 144compile-mode-1: dummy.c 145 ${LIBTOOL} --mode=compile --tag=disable-shared ${CC} -c dummy.c|tee out1 146 @if fgrep -q .libs/dummy.o out1; then exit 1; fi 147 @fgrep -q ' dummy.o' out1 148 @if fgrep ' dummy.o' out1|fgrep -q -- -fPIC; then exit 1; fi 149 150compile-mode-2: dummy.c 151 ${LIBTOOL} --mode=compile --tag=disable-static ${CC} -c dummy.c|tee out2 152 @fgrep .libs/dummy.o out2|fgrep -q -- -fPIC 153 @if fgrep -q ' dummy.o' out2; then exit 1; fi 154 155compile-mode-3: dummy.c 156 # can't disable both, will keep static 157 ${LIBTOOL} --mode=compile --tag=disable-static --tag=disable-shared ${CC} -c dummy.c|tee out3 158 @if fgrep -q .libs/dummy.o out3; then exit 1; fi 159 @fgrep -q ' dummy.o' out3 160 @if fgrep ' dummy.o' out3|fgrep -q -- -fPIC; then exit 1; fi 161 162compile-mode-4: dummy.c 163 # can't disable both, will keep static 164 ${LIBTOOL} --mode=compile --tag=disable-shared --tag=disable-static ${CC} -c dummy.c|tee out4 165 @if fgrep -q .libs/dummy.o out4; then exit 1; fi 166 @fgrep -q ' dummy.o' out4 167 @if fgrep ' dummy.o' out4|fgrep -- -fPIC; then exit 1; fi 168 169compile-mode-5: dummy.c 170 ${LIBTOOL} --mode=compile ${CC} -static -c dummy.c|tee out5 171 @if fgrep -q .libs/dummy.o out5; then exit 1; fi 172 @fgrep -q ' dummy.o' out5 173 @if fgrep ' dummy.o' out5|fgrep -- -fPIC; then exit 1; fi 174 175compile-mode-6: dummy.c 176 ${LIBTOOL} --mode=compile ${CC} -static -prefer-pic -c dummy.c|tee out6 177 @if fgrep -q .libs/dummy.o out6; then exit 1; fi 178 @fgrep ' dummy.o' out6|fgrep -q -- -fPIC 179 180compile-mode-7: dummy.c 181 ${LIBTOOL} --mode=compile ${CC} -static -fpie -c dummy.c|tee out7 182 @if fgrep -q .libs/dummy.o out7; then exit 1; fi 183 @fgrep ' dummy.o' out7|fgrep -q -- -fpie 184 @if fgrep ' dummy.o' out7|fgrep -- -fpie|fgrep -q -- -fPIC; then exit 1; fi 185 186compile-mode-8: dummy.c 187 ${LIBTOOL} --mode=compile ${CC} -static -prefer-pic -fpie -c dummy.c|tee out8 188 @if fgrep -q .libs/dummy.o out8; then exit 1; fi 189 @fgrep ' dummy.o' out8|fgrep -q -- -fPIC 190 @if fgrep ' dummy.o' out8|fgrep -- -fPIC|fgrep -q -- -fpie; then exit 1; fi 191 192compile-mode-9: dummy.c 193 ${LIBTOOL} --mode=compile ${CC} -shared -c dummy.c|tee out9 194 @fgrep -q .libs/dummy.o out9 195 196compile-mode-10: dummy.c 197 ${LIBTOOL} --mode=compile ${CC} -shared -prefer-non-pic -c dummy.c|tee out10 198 @fgrep .libs/dummy.o out10|fgrep -q -- -fPIC 199 200compile-mode-11: dummy.c 201 # -shared + -static -> static 202 ${LIBTOOL} --mode=compile ${CC} -shared -static -c dummy.c|tee out11 203 @if fgrep -q .libs/dummy.o out11; then exit 1; fi 204 @fgrep -q ' dummy.o' out11 205 @if fgrep ' dummy.o' out11|fgrep -q -- -fPIC; then exit 1; fi 206 207compile-mode-12: dummy.c 208 # -shared + -static -> static 209 ${LIBTOOL} --mode=compile ${CC} -shared -static -prefer-pic -c dummy.c|tee out12 210 @if fgrep -q .libs/dummy.o out12; then exit 1; fi 211 @fgrep ' dummy.o' out12|fgrep -q -- -fPIC 212 213compile-mode-13: dummy.c 214 # -static + -shared -> configuration error 215 if ${LIBTOOL} --mode=compile ${CC} -static -shared -c dummy.c; then exit 1; fi 216 217test-Wc: 218 ${LIBTOOL} --mode=compile ${CC} -c -Wc,-DA,-DB ${.CURDIR}/d.c 219 220test-Xcompiler: 221 ${LIBTOOL} --mode=compile ${CC} -c -Xcompiler -DA -Xcompiler -DB ${.CURDIR}/d.c 222 223stupid-gdb: 224 @${LIBTOOL} --config|fgrep -q 'objdir=.libs' 225 226linkception-0: e.lo 227 # check that linking with libX11 works, which is funny to do 228 # since -lX11 brings in -lxcb, BUT -lxcb wants some other stuff 229 # afterwards ! 230 ${LIBTOOL} --mode=link ${CC} -o e -L/usr/X11R6/lib e.lo -lX11 231 232test-link-4: e.lo 233 @if ${LIBTOOL} --mode=link ${CC} -o e -L /usr/X11R6/lib e.lo -lX11; then exit 1; fi 234 235# check that -x c works with libraries linking 236test-link-5: liba4.la 237 238# but not with programs !!! 239test-link-6: e.lo 240 @if ${LIBTOOL} --mode=link ${CC} -o e -x c e.lo 2>/dev/null; then exit 1; fi 241 242test-o-0: e.lo 243 @if ${LIBTOOL} --mode=link ${CC} -oe e.lo; then exit 1; fi 244 245pthread-0: e.lo liba2.la 246 @${LIBTOOL} --mode=link ${CC} -o e e.lo -la2|tee out.13 247 @fgrep -q -- -pthread out.13 248 249pthread-1: e.lo liba2.la 250 @${LIBTOOL} --mode=link ${CC} -pthread -o e e.lo -la2|tee out.14 251 @fgrep -q -- -pthread out.14 252 @if grep -q -- "-pthread.*-pthread" out.14; then exit 1; fi 253 254pthread-2: e.lo 255 ${LIBTOOL} --mode=link ${CC} -o e -pthread -pthread e.lo |tee out.15 256 @fgrep -q -- -pthread out.15 257 @if grep -q -- "-pthread.*-pthread" out.15; then exit 1; fi 258 259release-0: liba3.la 260 test -f .libs/liba3-0.so.0.0 || exit 1 261 262release-1: ${DEST}/lib/liba3.la 263 @test -h ${DEST}/lib/liba3.so.0.0 264 @test `readlink ${DEST}/lib/liba3.so.0.0` = liba3-0.so.0.0 265 266trip-0: dummy.c a.lo b.lo 267 rm -f .libs/libtrip.so.10.5 268 mkdir -p lib1 269 ${CC} -shared -o lib1/libtrip.so.10.5 dummy.c 270 ${CC} -shared -o lib1/libtrip.so.10.10 dummy.c 271 ${LIBTOOL} --mode=link ${CC} -o libbogus.la -Llib1 ${SOPTS} a.lo b.lo -ltrip 272 if test -e .libs/libtrip.so.10.5; then exit 1; fi 273 274#weird-shit-1: a.lo 275# ${LIBTOOL} --mode=link ${CC} -rpath /usr/local/lib --export-symbols a.def -o liba2.la a.lo 276# 277${DEST}/bin/p1: ${DEST}/lib/liba.la 278${DEST}/bin/p2: ${DEST}/lib/liba0.la ${DEST}/lib/liba1.la 279 280# basic framework to build/link stuff 281SOPTS = -version-info 0:0:0 -rpath /usr/local/lib 282 283LIBS = a a0 a1 a2 a3 a4 bad a9 ${WEIRD} 284PRGS = p1 p2 285 286OBJ_a = a.lo b.lo 287a_OPTS = ${SOPTS} 288 289OBJ_a0 = a.lo 290a0_OPTS = ${SOPTS} 291 292OBJ_a1 = b.lo 293a1_OPTS = ${SOPTS} -la0 294 295OBJ_a2 = a.lo b.lo 296a2_OPTS = ${OPTS} -pthread 297 298OBJ_a3 = a.lo b.lo 299a3_OPTS = ${a_OPTS} -release 0 300 301OBJ_a4 = a.lo b.lo 302a4_OPTS = -x c ${a_OPTS} 303 304# libbad has a bogus rpath option 305OBJ_bad = a.lo b.lo 306bad_OPTS = --version-info 0:0:0 --rpath /usr/local/lib 307 308OBJ_a9 = ${OBJ_a} 309a9_OPTS = ${a_OPTS} 310LIBS_ENV = liba9_ltversion=4.2 311 312OBJ_${WEIRD} = ${OBJ_a} 313${WEIRD}_OPTS = ${a_OPTS} 314LIBS_ENV += lib${NOTWEIRD}_ltversion=5.6 315 316OBJ_p1 = c.lo liba.la 317LINK_p1 = c.lo -la 318 319OBJ_p2 = c.lo liba0.la liba1.la 320LINK_p2 = c.lo -la1 321 322 323# stuff to compile/link/install everything 324.SUFFIXES: .lo 325 326.c.lo: 327 ${LIBTOOL} --mode=compile ${CC} -c ${CFLAGS} ${.CURDIR}/$*.c 328 329.for p in ${PRGS} 330$p: ${OBJ_$p} 331 ${LIBTOOL} --mode=link ${CC} ${CFLAGS} -o $@ ${LINK_$p} 332.endfor 333 334.for t in ${PRGS} 335${DEST}/bin/$t: $t 336 mkdir -p ${DEST}/bin 337 ${LIBTOOL} --mode=install cp $t ${DEST}/bin/$t 338.endfor 339 340.for t in ${LIBS} 341${DEST}/lib/lib$t.la: lib$t.la 342 mkdir -p ${DEST}/lib 343 ${LIBTOOL} --mode=install cp lib$t.la ${DEST}/lib/lib$t.la 344.endfor 345 346.for l in ${LIBS} 347lib$l.la: ${OBJ_$l} 348 ${LIBS_ENV} ${LIBTOOL} --mode=link ${CC} ${CFLAGS} -o $@ ${$l_OPTS} ${OBJ_$l} 349.endfor 350 351CLEANFILES += ${PRGS} s1 e dummy*.c *.d *.o *.lo *.la .libs/* lib1/* out* 352CLEANFILES += ${DEST}/bin/* ${DEST}/lib/* ${DEST2}/lib/* ${DEST3}/lib/* 353 354.PHONY: ${REGRESS_TARGETS} regress compile-tests 355 356.include <bsd.regress.mk> 357