File tree Expand file tree Collapse file tree 6 files changed +393
-2
lines changed
Expand file tree Collapse file tree 6 files changed +393
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ install3: build3
4040# sudo apt-get install automake
4141# make cpp
4242# cd build && sudo make install
43+ #
44+ # libgtest-dev is needed for UT
45+ #
46+ # sudo sh -c 'echo cape-universaln > /sys/devices/platform/bone_capemgr/slots'
47+ # sudo sh -c 'echo pwm > /sys/devices/platform/ocp/ocp\:P9_16_pinmux/state'
48+ # sudo sh -c 'echo pwm > /sys/devices/platform/ocp/ocp\:P8_19_pinmux/state'
4349# ###############################################################################
4450configure : configure.ac
4551 rm -f configure && \
@@ -51,6 +57,10 @@ build/Makefile: configure
5157 ../configure
5258
5359cpp : build/Makefile
60+ cd build && \
61+ $(MAKE ) build
62+
63+ cpp-check : cpp
5464 cd build && \
5565 $(MAKE ) check
5666
Original file line number Diff line number Diff line change @@ -9,12 +9,17 @@ AC_CONFIG_MACRO_DIR([m4])
99AC_CONFIG_HEADERS ( [ config.h] )
1010AC_CONFIG_FILES ( [ Makefile source/Makefile] )
1111
12- AM_INIT_AUTOMAKE ( [ 1.9 dist-bzip2 dist-zip foreign subdir-objects] )
12+ AM_INIT_AUTOMAKE ( [ 1.9 dist-bzip2 dist-zip foreign subdir-objects -Wall] )
13+ AM_PROG_AR
14+
15+ LT_INIT
1316
1417AC_PROG_CC
1518AC_PROG_CXX
1619AC_LANG ( [ C] )
1720AC_LANG ( [ C++] )
18- AC_PROG_LIBTOOL
21+
22+ CHECK_GTEST
23+ CHECK_KERNEL_RELEASE
1924
2025AC_OUTPUT
Original file line number Diff line number Diff line change 1+ AC_DEFUN ( [ CHECK_GTEST] ,
2+ [
3+ AC_MSG_CHECKING ( [ for google test] )
4+
5+ AC_LANG_PUSH ( [ C++] )
6+ AC_CHECK_HEADER ( [ gtest/gtest.h] ,[ gtest_found=yes] )
7+ AC_LANG_POP
8+
9+ #if test "x$gtest_found" = "xyes"; then
10+ # GTEST_CPPFLAGS=
11+ # AC_SUBST ( GTEST_CPPFLAGS )
12+ #fi
13+
14+ AC_SUBST ( HAVE_GTEST )
15+ AM_CONDITIONAL([ HAVE_GTEST] , [ test "x$gtest_found" = "xyes"] )
16+ ] )
Original file line number Diff line number Diff line change 1+ AC_DEFUN ( [ CHECK_KERNEL_RELEASE] ,
2+ [
3+ AC_MSG_CHECKING ( [ if kernel release >= 4.1] )
4+
5+ kernel_ge_41=$(python -c 'import platform; print("yes" if platform.release() >= "4.1.0" else "no")')
6+
7+ if test "x$kernel_ge_41" = "xyes"; then
8+ CPPFLAGS="$CPPFLAGS -DBBBVERSION41"
9+ AC_SUBST ( CPPFLAGS )
10+ AC_MSG_RESULT ( yes )
11+ else
12+ AC_MSG_RESULT ( no )
13+ fi
14+ ] )
Original file line number Diff line number Diff line change @@ -101,3 +101,28 @@ test_cpp_abi_new_SOURCES = test/cpp/abi.cpp
101101test_cpp_abi_new_CXXFLAGS = $(AM_CXXFLAGS ) -pthread -D_GLIBCXX_USE_CXX11_ABI=1
102102test_cpp_abi_new_LDADD = libadafruit-bbio1.la
103103test_cpp_abi_new_LDFLAGS = $(AM_LDFLAGS ) -lpthread -static
104+
105+ if HAVE_GTEST
106+
107+ check_PROGRAMS += test/cpp/unittest
108+
109+ gtest/src/gtest-all.cc : /usr/src/gtest/src
110+ mkdir -p gtest && cp -Rvf $< gtest
111+
112+ gtest/src/gtest_main.cc : gtest/src/gtest-all.cc
113+
114+ BUILT_SOURCES = \
115+ gtest/src/gtest-all.cc \
116+ gtest/src/gtest_main.cc
117+
118+ test_cpp_unittest_SOURCES = \
119+ test/cpp/pwm.cpp \
120+ gtest/src/gtest-all.cc \
121+ gtest/src/gtest_main.cc
122+
123+ test_cpp_unittest_CPPFLAGS = $(AM_CPPFLAGS ) $(GTEST_CPPFLAGS ) -isystem gtest
124+ test_cpp_unittest_CXXFLAGS = $(AM_CXXFLAGS ) -pthread -D_GLIBCXX_USE_CXX11_ABI=1
125+ test_cpp_unittest_LDADD = libadafruit-bbio1.la
126+ test_cpp_unittest_LDFLAGS = $(AM_LDFLAGS ) -lpthread -static
127+
128+ endif # HAVE_GTEST
You can’t perform that action at this time.
0 commit comments