fixed the autotools setup

* fixed compile on all Unixes
  * added unit-tests
  * added cmake to build natively on win32
  * fixed the "make dist" setup to include all os-dirs
This commit is contained in:
Jan Kneschke 2009-08-09 15:35:24 +02:00
parent f88489dc73
commit d65177559d
16 changed files with 309 additions and 10 deletions

35
CMakeLists.txt Normal file
View File

@ -0,0 +1,35 @@
PROJECT(sigar C)
cmake_minimum_required(VERSION 2.6)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckTypeSize)
INCLUDE(CTest)
INCLUDE(InstallRequiredSystemLibraries)
ENABLE_TESTING()
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "6")
SET(CPACK_PACKAGE_VERSION_PATCH "2")
SET(CPACK_PACKAGE_VENDOR "Hyperic")
## SET(CPACK_*) before the INCLUDE(CPack)
INCLUDE(CPack)
IF(WIN32)
## make sure we only use the smallest set of
## headers on win32. Otherwise we get clashes
## between winsock2.h and winsock.h
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
# force the correct version for the redist manifest
ADD_DEFINITIONS(-D_BIND_TO_CURRENT_MFC_VERSION=1 -D_BIND_TO_CURRENT_CRT_VERSION=1)
# turn off security warnings for system calls
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(WIN32)
ADD_SUBDIRECTORY(src build-src)
ADD_SUBDIRECTORY(tests build-tests)
ADD_SUBDIRECTORY(include build-include)

10
include/CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
INSTALL(FILES sigar.h
sigar_fileinfo.h
sigar_format.h
sigar_getline.h
sigar_log.h
sigar_private.h
sigar_ptql.h
sigar_util.h
DESTINATION include/
)

12
include/Makefile.am Normal file
View File

@ -0,0 +1,12 @@
include_HEADERS = \
sigar.h \
sigar_fileinfo.h \
sigar_format.h \
sigar_getline.h \
sigar_log.h \
sigar_private.h \
sigar_ptql.h \
sigar_util.h
EXTRA_DIST=\
CMakeLists.txt

92
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,92 @@
## sigar has some base files + a set of platform specific files
MESSAGE(STATUS "CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}")
INCLUDE_DIRECTORIES(../include/)
## linux
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
SET(SIGAR_SRC os/linux/linux_sigar.c)
INCLUDE_DIRECTORIES(os/linux/)
ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
## macosx, freebsd
IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
SET(SIGAR_SRC os/darwin/darwin_sigar.c)
INCLUDE_DIRECTORIES(os/darwin/)
IF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
INCLUDE_DIRECTORIES(/Developer/Headers/FlatCarbon/)
ADD_DEFINITIONS(-DDARWIN)
SET(SIGAR_LINK_FLAGS "-framework CoreServices -framework IOKit")
ELSE(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
## freebsd needs libkvm
SET(SIGAR_LINK_FLAGS "-lkvm")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin)")
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Darwin|FreeBSD)")
## solaris
IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
SET(SIGAR_SRC
os/solaris/solaris_sigar.c
os/solaris/get_mib2.c
os/solaris/kstats.c
os/solaris/procfs.c
)
INCLUDE_DIRECTORIES(os/solaris/)
ADD_DEFINITIONS(-DSOLARIS)
SET(SIGAR_LINK_FLAGS -lkstat -ldl -lnsl -lsocket -lresolv)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)" )
## solaris
IF (CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
SET(SIGAR_SRC
os/hpux/hpux_sigar.c
os/hpux/dlpi.c
)
INCLUDE_DIRECTORIES(os/hpux/)
ADD_DEFINITIONS(-DSIGAR_HPUX)
SET(SIGAR_LINK_FLAGS -lnm)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(hpux)" )
## aix
IF (CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
SET(SIGAR_SRC os/aix/aix_sigar.c)
INCLUDE_DIRECTORIES(os/aix/)
SET(SIGAR_LINK_FLAGS -lodm -lcfg)
ENDIF(CMAKE_SYSTEM_NAME MATCHES "(AIX)" )
IF(WIN32)
ADD_DEFINITIONS(-DSIGAR_SHARED)
SET(SIGAR_SRC os/win32/peb.c os/win32/win32_sigar.c)
INCLUDE_DIRECTORIES(os/win32)
ENDIF(WIN32)
SET(SIGAR_SRC ${SIGAR_SRC}
sigar.c
sigar_cache.c
sigar_fileinfo.c
sigar_format.c
sigar_getline.c
sigar_ptql.c
sigar_signal.c
sigar_util.c
)
ADD_LIBRARY(sigar SHARED ${SIGAR_SRC})
IF(WIN32)
TARGET_LINK_LIBRARIES(sigar ws2_32 netapi32 version)
ENDIF(WIN32)
IF(SIGAR_LINK_FLAGS)
SET_TARGET_PROPERTIES(sigar PROPERTIES LINK_FLAGS "${SIGAR_LINK_FLAGS}")
ENDIF(SIGAR_LINK_FLAGS)
INSTALL(TARGETS sigar
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

View File

@ -1,7 +1,18 @@
INCLUDES = @INCLUDES@
SIGAR_OS_SRCS = aix_sigar.c
SIGAR_OS_HDRS = sigar_os.h
if OS_AIX
noinst_LTLIBRARIES = libsigar_os.la
libsigar_os_la_SOURCES = aix_sigar.c
libsigar_os_la_SOURCES = ${SIGAR_OS_SRCS}
noinst_HEADERS = ${SIGAR_OS_HDRS}
else
EXTRA_DIST=\
${SIGAR_OS_SRCS} \
${SIGAR_OS_HDRS}
endif
noinst_HEADERS = sigar_os.h

View File

@ -1,7 +1,18 @@
INCLUDES = @INCLUDES@
SIGAR_OS_SRCS=\
darwin_sigar.c
SIGAR_OS_HDRS=\
sigar_os.h
if OS_MACOSX
noinst_LTLIBRARIES = libsigar_os.la
libsigar_os_la_SOURCES = darwin_sigar.c
libsigar_os_la_SOURCES = ${SIGAR_OS_SRCS}
noinst_HEADERS = sigar_os.h
noinst_HEADERS = ${SIGAR_OS_HDRS}
else
EXTRA_DIST=\
${SIGAR_OS_SRCS} \
${SIGAR_OS_HDRS}
endif

View File

@ -0,0 +1,2 @@
EXTRA_DIST=\
README

View File

@ -1,7 +1,17 @@
INCLUDES = @INCLUDES@
SIGAR_OS_SRCS = hpux_sigar.c dlpi.c
SIGAR_OS_HDRS = sigar_os.h
if OS_HPUX
noinst_LTLIBRARIES = libsigar_os.la
libsigar_os_la_SOURCES = hpux_sigar.c dlpi.c
libsigar_os_la_SOURCES = ${SIGAR_OS_SRCS}
noinst_HEADERS = sigar_os.h
noinst_HEADERS = ${SIGAR_OS_HDRS}
else
EXTRA_DIST=\
${SIGAR_OS_SRCS} \
${SIGAR_OS_HDRS}
endif

View File

@ -1,7 +1,18 @@
INCLUDES = @INCLUDES@
SIGAR_OS_SRCS = linux_sigar.c
SIGAR_OS_HDRS = sigar_os.h
if OS_LINUX
noinst_LTLIBRARIES = libsigar_os.la
libsigar_os_la_SOURCES = linux_sigar.c
libsigar_os_la_SOURCES = ${SIGAR_OS_SRCS}
noinst_HEADERS = ${SIGAR_OS_HDRS}
else
EXTRA_DIST=\
${SIGAR_OS_SRCS} \
${SIGAR_OS_HDRS}
endif
noinst_HEADERS = sigar_os.h

View File

@ -0,0 +1,5 @@
EXTRA_DIST=\
Makefile.nw \
netware_sigar.c \
sigar.def.in \
sigar_os.h

3
src/os/osf1/Makefile.am Normal file
View File

@ -0,0 +1,3 @@
EXTRA_DIST=\
osf1_sigar.c \
sigar_os.h

View File

@ -1,7 +1,18 @@
INCLUDES = @INCLUDES@
SIGAR_OS_SRCS = solaris_sigar.c get_mib2.c kstats.c procfs.c
SIGAR_OS_HDRS = sigar_os.h get_mib2.h hmekstat.h
if OS_SOLARIS
noinst_LTLIBRARIES = libsigar_os.la
libsigar_os_la_SOURCES = solaris_sigar.c get_mib2.c kstats.c procfs.c
libsigar_os_la_SOURCES = ${SIGAR_OS_SRCS}
noinst_HEADERS = ${SIGAR_OS_HDRS}
else
EXTRA_DIST=\
${SIGAR_OS_SRCS} \
${SIGAR_OS_HDRS}
endif
noinst_HEADERS = sigar_os.h

3
src/os/stub/Makefile.am Normal file
View File

@ -0,0 +1,3 @@
EXTRA_DIST=\
sigar_os.h \
stub_sigar.c

8
src/os/win32/Makefile.am Normal file
View File

@ -0,0 +1,8 @@
EXTRA_DIST=\
build-cpu.bat \
counter_names.txt \
peb.c \
sigar.rc.in \
sigar_os.h \
sigar_pdh.h \
win32_sigar.c

View File

@ -0,0 +1,22 @@
#include "sigar.h"
static sigar_version_t sigar_version = {
__DATE__,
"@SCM_REVISION@",
"@PACKAGE_STRING@",
"@build@",
"@build_os@",
"@build_cpu@",
"SIGAR-@PACKAGE_VERSION@, "
"SCM revision @SCM_REVISION@, "
"built "__DATE__" as @build_cpu@",
@VERSION_MAJOR@,
@VERSION_MINOR@,
@VERSION_MAINT@,
@VERSION_BUILD@
};
SIGAR_DECLARE(sigar_version_t *) sigar_version_get(void)
{
return &sigar_version;
}

53
winbuild.bat Normal file
View File

@ -0,0 +1,53 @@
@rem $%BEGINLICENSE%$
@rem $%ENDLICENSE%$
@echo "Run this from a shell started with the Visual Studio Build environment set!"
@IF DEFINED GENERATOR (GOTO GENERAL_CONF)
@rem Sane default is VS2005, but maybe not what we really want...
@SET GENERATOR="Visual Studio 8 2005"
@GOTO GENERAL_CONF
:GENERAL_CONF
@echo Using %GENERATOR%
@rem MSVC 8 2005 doesn't seem to have devenv.com
@SET VS_CMD="%VS90COMNTOOLS%\..\IDE\VCExpress.exe"
@rem clear the cache if neccesary to let cmake recheck everything
@rem del CMakeCache.txt
:CMAKE
@rem make sure that /D NDEBUG isn't set as it disables all the assert()ions in the testcase
cmake -G %GENERATOR% -DBUILD_NUMBER=%BUILD_NUMBER% -DCMAKE_INSTALL_PREFIX=%INST_PREFIX% -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="/MD /Zi /O2 /Ob1" .
@IF NOT %GENERATOR%=="NMake Makefiles" (GOTO VS08BUILD)
nmake
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
cp build-src/sigar.dll build-tests/
nmake test
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
nmake install
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
@GOTO CLEANUP
:VS08BUILD
%VS_CMD% mysql-proxy.sln /Clean
%VS_CMD% mysql-proxy.sln /Build Release
%VS_CMD% mysql-proxy.sln /Build Release /project RUN_TESTS
%VS_CMD% mysql-proxy.sln /Build Release /project PACKAGE
%VS_CMD% mysql-proxy.sln /Build Release /project INSTALL
@GOTO CLEANUP
@rem if you use VS8 to build then VS80COMNTOOLS should be set
@rem "%VS80COMNTOOLS%\..\IDE\devenv.com" mysql-proxy.sln /Clean
@rem "%VS80COMNTOOLS%\..\IDE\devenv.com" mysql-proxy.sln /Build
@rem "%VS80COMNTOOLS%\..\IDE\devenv.com" mysql-proxy.sln /Build Debug /project RUN_TESTS
@rem "%VS80COMNTOOLS%\..\IDE\devenv.com" mysql-proxy.sln /Build Debug /project PACKAGE
@rem "%VS80COMNTOOLS%\..\IDE\devenv.com" mysql-proxy.sln /Build Debug /project INSTALL
:CLEANUP
:END