autoconfization
authorLennart Poettering <lennart@poettering.net>
Tue, 1 Jul 2008 18:34:18 +0000 (20:34 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 1 Jul 2008 18:34:18 +0000 (20:34 +0200)
.gitignore
Makefile [deleted file]
Makefile.am [new file with mode: 0644]
atasmart.c
atasmart.h
bootstrap.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
libatasmart.pc.in [new file with mode: 0644]

index 05900f6..3d05845 100644 (file)
@@ -1,10 +1,26 @@
 skdump
 sktest
-gnome-disk-health
-gnome-disk-health.c
-gnome-disk-health.h
-gnome-disk-health.ui
-smartkitd
-smartkitd.c
-smartkitd.h
+.deps/
+.libs/
+Makefile.in
+aclocal.m4
 *.o
+*.lo
+*.cache
+compile
+config.guess
+config.h
+config.h.in
+config.log
+config.rpath
+config.status
+config.sub
+configure
+depcomp
+install-sh
+*.la
+libatasmart.pc
+libtool
+ltmain.sh
+missing
+stamp-*
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 396c5bf..0000000
--- a/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-CFLAGS=-pipe -Wall -W -O0 -g -I.
-LIBS=
-
-all: skdump sktest
-
-skdump: atasmart.o skdump.o
-       $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
-
-sktest: atasmart.o sktest.o
-       $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
-
-clean:
-       rm -f skdump sktest *.o
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..b79f7fa
--- /dev/null
@@ -0,0 +1,48 @@
+# This file is part of libatasmart.
+#
+# Copyright 2008 Lennart Poettering
+#
+# libatasmart is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# libatasmart is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with libatasmart. If not, If not, see
+# <http://www.gnu.org/licenses/>.
+
+EXTRA_DIST = bootstrap.sh LGPL README
+SUBDIRS =
+
+MAINTAINERCLEANFILES =
+noinst_DATA =
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libatasmart.pc
+
+bin_PROGRAMS = \
+       skdump \
+       sktest
+
+lib_LTLIBRARIES = \
+       libatasmart.la
+
+skdump_SOURCES = \
+       skdump.c
+skdump_LDADD = \
+       libatasmart.la
+
+sktest_SOURCE = \
+       sktest.c
+sktest_LDADD = \
+       libatasmart.la
+
+libatasmart_la_SOURCES = \
+       atasmart.c atasmart.h
+libatasmart_la_LDFLAGS = \
+       -version-info 0:0:0
index a244fdf..dd5f323 100644 (file)
@@ -24,8 +24,6 @@
 #include <config.h>
 #endif
 
-#define _GNU_SOURCE
-
 #include <arpa/inet.h>
 #include <stdlib.h>
 #include <alloca.h>
@@ -1043,7 +1041,7 @@ static char *print_value(char *s, size_t len, const SkSmartAttributeParsedData *
         s[len-1] = 0;
 
         return s;
-};
+}
 
 #define HIGHLIGHT "\x1B[1m"
 #define ENDHIGHLIGHT "\x1B[0m"
index 25b0f13..96b8294 100644 (file)
 
 typedef int SkBool;
 
-#ifndef TRUE
-#define TRUE 1
+#ifndef FALSE
+#define FALSE   (0)
 #endif
 
-#ifndef FALSE
-#define FALSE (!TRUE)
+#ifndef TRUE
+#define TRUE    (!FALSE)
 #endif
 
 /* ATA SMART test type (ATA8 7.52.5.2) */
diff --git a/bootstrap.sh b/bootstrap.sh
new file mode 100755 (executable)
index 0000000..e227225
--- /dev/null
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+# This file is part of libatasmart.
+#
+# Copyright 2008 Lennart Poettering
+#
+# libatasmart is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# libatasmart is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with libatasmart. If not, If not, see
+# <http://www.gnu.org/licenses/>.
+
+VERSION=1.9
+
+run_versioned() {
+    local P
+    local V
+
+    V=$(echo "$2" | sed -e 's,\.,,g')
+
+    if [ -e "`which $1$V 2> /dev/null`" ] ; then
+        P="$1$V"
+    else
+       if [ -e "`which $1-$2 2> /dev/null`" ] ; then
+            P="$1-$2"
+       else
+           P="$1"
+       fi
+    fi
+
+    shift 2
+    "$P" "$@"
+}
+
+set -ex
+
+if [ "x$1" = "xam" ] ; then
+    run_versioned automake "$VERSION" -a -c --foreign
+    ./config.status
+else
+    rm -rf autom4te.cache
+    rm -f config.cache
+
+    touch config.rpath
+    test "x$LIBTOOLIZE" = "x" && LIBTOOLIZE=libtoolize
+
+    mkdir -p m4
+    "$LIBTOOLIZE" -c --force
+    run_versioned aclocal "$VERSION"
+    run_versioned autoconf 2.59 -Wall
+    run_versioned autoheader 2.59
+    run_versioned automake "$VERSION" --copy --foreign --add-missing
+
+    if test "x$NOCONFIGURE" = "x"; then
+        CFLAGS="-g -O0" ./configure --sysconfdir=/etc --localstatedir=/var "$@"
+        make clean
+    fi
+fi
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..86c0bf7
--- /dev/null
@@ -0,0 +1,136 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+# This file is part of libatasmart.
+#
+# Copyright 2008 Lennart Poettering
+#
+# libatasmart is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 2.1 of the
+# License, or (at your option) any later version.
+#
+# libatasmart is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with libatasmart. If not, If not, see
+# <http://www.gnu.org/licenses/>.
+
+AC_PREREQ(2.57)
+
+AC_INIT([libatasmart], 0.1, [mzyvongnfzneg (at) 0pointer (dot) net])
+AC_CONFIG_SRCDIR([atasmart.c])
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR(m4)
+
+AM_INIT_AUTOMAKE([foreign -Wall])
+
+AC_SUBST(PACKAGE_URL, [https://http://git.0pointer.de/?p=libatasmart.git])
+
+AC_SUBST(LIBATASMART_VERSION_INFO, [0:0:0])
+
+AC_CANONICAL_HOST
+
+if type -p stow > /dev/null && test -d /usr/local/stow ; then
+   AC_MSG_NOTICE([*** Found /usr/local/stow: default install prefix set to /usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION} ***])
+   ac_default_prefix="/usr/local/stow/${PACKAGE_NAME}-${PACKAGE_VERSION}"
+fi
+
+#### Checks for programs. ####
+
+# CC
+
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_GCC_TRADITIONAL
+AC_GNU_SOURCE
+
+# C++
+
+AC_PROG_CXX
+
+# GCC flags
+
+test_gcc_flag() {
+    AC_LANG_CONFTEST([int main(int argc, char*argv[]) {}])
+    $CC -c conftest.c $CFLAGS -o conftest.o > /dev/null 2> /dev/null
+    ret=$?
+    rm -f conftest.o
+    return $ret
+}
+
+# If using GCC specify some additional parameters
+if test "x$GCC" = "xyes" ; then
+
+    # We use gnu99 instead of c99 because many have interpreted the standard
+    # in a way that int64_t isn't defined on non-64 bit platforms.
+    DESIRED_FLAGS="-std=gnu99 -Wall -W -Wextra -pedantic -pipe -Wformat -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Winline -Wno-unused-parameter -ffast-math"
+
+    for flag in $DESIRED_FLAGS ; do
+        AC_MSG_CHECKING([whether $CC accepts $flag])
+        if test_gcc_flag $flag ; then
+           CFLAGS="$CFLAGS $flag"
+           CXXFLAGS="$CXXFLAGS $flag"
+           AC_MSG_RESULT([yes])
+        else
+           AC_MSG_RESULT([no])
+        fi
+    done
+fi
+
+#### libtool stuff ####
+
+AC_PROG_LIBTOOL
+
+#### Checks for header files. ####
+
+# ISO
+AC_HEADER_STDC
+
+# XPG4-UNIX
+AC_CHECK_HEADERS([sys/poll.h])
+
+# Other
+AC_CHECK_HEADERS([sys/ioctl.h])
+AC_CHECK_HEADERS([byteswap.h])
+
+#### Typdefs, structures, etc. ####
+
+AC_C_CONST
+AC_C_BIGENDIAN
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_CHECK_TYPES(ssize_t, , [AC_DEFINE([ssize_t], [signed long],
+    [Define ssize_t if it is not done by the standard libs.])])
+AC_TYPE_OFF_T
+AC_TYPE_SIGNAL
+AC_TYPE_UID_T
+
+#### Large File-Support (LFS) ####
+
+AC_SYS_LARGEFILE
+
+###################################
+#            Output               #
+###################################
+
+AC_CONFIG_FILES([
+Makefile
+libatasmart.pc
+])
+AC_OUTPUT
+
+echo "
+ ---{ $PACKAGE_NAME $VERSION }---
+
+    prefix:                 ${prefix}
+    sysconfdir:             ${sysconfdir}
+    localstatedir:          ${localstatedir}
+    Compiler:               ${CC}
+    CFLAGS:                 ${CFLAGS}
+    C++-Compiler:           ${CXX}
+    CXXFLAGS:               ${CXXFLAGS}
+"
diff --git a/libatasmart.pc.in b/libatasmart.pc.in
new file mode 100644 (file)
index 0000000..50e41d3
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=${prefix}
+libdir=@libdir@
+includedir=${prefix}/include
+
+Name: libatasmart
+Description: ATA S.M.A.R.T. Reading and Parsing Library
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -latasmart
+Cflags: -I${includedir}
+Requires: