xref: /freebsd/contrib/netbsd-tests/share/mk/t_lib.sh (revision c22165b4f1f5d38b681921797a44b3ba8c13b7e0)
157718be8SEnji Cooper# Copyright 2012 Google Inc.
257718be8SEnji Cooper# All rights reserved.
357718be8SEnji Cooper#
457718be8SEnji Cooper# Redistribution and use in source and binary forms, with or without
557718be8SEnji Cooper# modification, are permitted provided that the following conditions are
657718be8SEnji Cooper# met:
757718be8SEnji Cooper#
857718be8SEnji Cooper# * Redistributions of source code must retain the above copyright
957718be8SEnji Cooper#   notice, this list of conditions and the following disclaimer.
1057718be8SEnji Cooper# * Redistributions in binary form must reproduce the above copyright
1157718be8SEnji Cooper#   notice, this list of conditions and the following disclaimer in the
1257718be8SEnji Cooper#   documentation and/or other materials provided with the distribution.
1357718be8SEnji Cooper# * Neither the name of Google Inc. nor the names of its contributors
1457718be8SEnji Cooper#   may be used to endorse or promote products derived from this software
1557718be8SEnji Cooper#   without specific prior written permission.
1657718be8SEnji Cooper#
1757718be8SEnji Cooper# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1857718be8SEnji Cooper# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1957718be8SEnji Cooper# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2057718be8SEnji Cooper# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2157718be8SEnji Cooper# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2257718be8SEnji Cooper# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2357718be8SEnji Cooper# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2457718be8SEnji Cooper# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2557718be8SEnji Cooper# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2657718be8SEnji Cooper# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2757718be8SEnji Cooper# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2857718be8SEnji Cooper
2957718be8SEnji Cooperatf_test_case defaults__build_and_install
3057718be8SEnji Cooperdefaults__build_and_install_body() {
3157718be8SEnji Cooper	create_c_module module1 first
3257718be8SEnji Cooper	create_c_module module2 second
3357718be8SEnji Cooper
34*640235e2SEnji Cooper	CC=gcc
35*640235e2SEnji Cooper	if [ ! -e /usr/bin/gcc -a -e /usr/bin/clang ]; then
36*640235e2SEnji Cooper		export HAVE_LLVM=yes
37*640235e2SEnji Cooper		CC=clang
38*640235e2SEnji Cooper	fi
39*640235e2SEnji Cooper
4057718be8SEnji Cooper	cat >Makefile <<EOF
4157718be8SEnji CooperLIB = two-modules
4257718be8SEnji CooperSRCS = module1.c module2.c
4357718be8SEnji Cooper.include <bsd.lib.mk>
4457718be8SEnji CooperEOF
4557718be8SEnji Cooper
4657718be8SEnji Cooper	atf_check -o ignore make
4757718be8SEnji Cooper	mkdir -p root/usr/lib
4857718be8SEnji Cooper	mkdir -p root/usr/libdata/lint
4957718be8SEnji Cooper	create_make_conf mk.conf owngrp DESTDIR="$(pwd)/root"
5057718be8SEnji Cooper	atf_check -o ignore make install
5157718be8SEnji Cooper
5257718be8SEnji Cooper	create_main_using_modules main.c module1.h:first module2.h:second
53*640235e2SEnji Cooper	atf_check -o ignore ${CC} -I. -Lroot/usr/lib -o main main.c -ltwo-modules
5457718be8SEnji Cooper
5557718be8SEnji Cooper	atf_check -o inline:'module1\nmodule2\n' ./main
5657718be8SEnji Cooper}
5757718be8SEnji Cooper
5857718be8SEnji Cooperatf_init_test_cases() {
5957718be8SEnji Cooper	atf_add_test_case defaults__build_and_install
6057718be8SEnji Cooper}
61