11.24Sjoerg#	$NetBSD: Makefile,v 1.24 2021/05/30 01:57:00 joerg Exp $
21.1Sjoerg
31.22Schristos.include <bsd.hostinit.mk>
41.1Sjoerg
51.1Sjoerg#
61.1Sjoerg# Do *not* set HOSTPROG or HOSTLIB at this point otherwise
71.1Sjoerg# it will create a loop trying to extract the object directory.
81.1Sjoerg#
91.1Sjoerg.include "Makefile.inc"
101.1Sjoerg.include "${LLVM_TOPLEVEL}/lib/Makefile.inc"
111.1Sjoerg
121.24Sjoergrealdepends realall: config/config.status need-dl need-terminfo support-modules
131.24Sjoerg
141.24Sjoergdependall: clean-modulecache
151.24Sjoerg
161.24Sjoergclean-modulecache:
171.24Sjoerg	rm -rf ${LLVM_MODULE_CACHE}
181.1Sjoerg
191.1Sjoergconfig/config.status: ${LLVM_SRCDIR}/configure
201.1Sjoerg	mkdir -p config
211.16Sjoerg	printf '#!/bin/sh\necho 2.7.3' > config/python
221.16Sjoerg	chmod 755 config/python
231.21Sjoerg	cd config && ${HOST_SH} ${CONFIG_DIR}/configure ${LLVM_CONFIGURE_ARGS} \
241.18Smatt	    --enable-optimized CC=${HOST_CC:Q} CXX=${HOST_CXX:Q} \
251.24Sjoerg	    --with-python=${.OBJDIR}/config/python && \
261.24Sjoerg	cp ${LLVM_TOPLEVEL}/include/module.modulemap include/llvm/module.modulemap
271.24Sjoerg
281.24Sjoergsupport-modules: module-test.cpp Makefile
291.24Sjoerg	if ${HOST_CXX} -stdlib=libc++ -c -fmodules -fcxx-modules -fmodules-cache-path=./module.cache \
301.24Sjoerg	   ${.CURDIR}/module-test.cpp  3> /dev/null 2>&1; then \
311.24Sjoerg		echo HOST_SUPPORTS_MODULES=yes > ${.TARGET}; \
321.24Sjoerg	else \
331.24Sjoerg		echo HOST_SUPPORTS_MODULES=no > ${.TARGET}; \
341.24Sjoerg	fi
351.4Sjoerg
361.23Sjoergneed-dl: Makefile
371.1Sjoerg	printf '#include <dlfcn.h>\nint main(void){void *p; return dladdr(p, p);}' > need-dl.c
381.1Sjoerg	if ${HOST_CC} -o need-dl.out -D_GNU_SOURCE need-dl.c > /dev/null 2>&1; then \
391.1Sjoerg		echo > ${.TARGET}; \
401.1Sjoerg	elif ${HOST_CC} -o need-dl.out -D_GNU_SOURCE need-dl.c -ldl > /dev/null 2>&1; then \
411.1Sjoerg		echo -ldl > ${.TARGET}; \
421.1Sjoerg	else \
431.1Sjoerg		echo > ${.TARGET}; \
441.1Sjoerg	fi
451.1Sjoerg
461.23Sjoergneed-terminfo: Makefile
471.23Sjoerg	printf 'int setupterm(char *, int, int *);\nint main(void){return setupterm("", 0, 0);}' > need-terminfo.c
481.17Sjoerg	for lib in tinfo terminfo ncurses curses; do \
491.17Sjoerg		if ${HOST_CC} -o need-terminfo.out need-terminfo.c -l$$lib > /dev/null 2>&1; then \
501.17Sjoerg			echo -l$$lib > ${.TARGET}; \
511.17Sjoerg			break; \
521.17Sjoerg		fi; \
531.17Sjoerg	done
541.17Sjoerg
551.17SjoergCLEANFILES+=	need-dl need-dl.c need-dl.out need-terminfo need-terminfo.c need-terminfo.out
561.1Sjoerg
571.1Sjoergcleandir: cleandir-llvm
581.1Sjoerg
591.19Sjoergcleandir-llvm: .PHONY
601.9Smatt	test ! -d config || rm -r config
611.24Sjoerg	test ! -d module-cache || rm -r module-cache
621.24Sjoerg	rm -f need-dl need-dl.tmp module-cache module-test.o
631.1Sjoerg
641.1Sjoerg.include <bsd.hostprog.mk>
65