Luca Barbato 11 лет назад
Родитель
Сommit
69bdc304e1
9 измененных файлов с 433 добавлено и 89 удалено
  1. 42 3
      .gitignore
  2. 0 86
      Makefile
  3. 70 0
      Makefile.am
  4. 51 0
      abi_version.sh
  5. 53 0
      configure.ac
  6. 4 0
      include/bdsm.h
  7. 0 0
      libdsm.pc.in
  8. 173 0
      m4/dolt.m4
  9. 40 0
      package_version.sh

+ 42 - 3
.gitignore

@@ -4,7 +4,46 @@ ref/*
 dsm
 *.so
 *.a
-discover
-lookup
-inverse
+dsm_discover
+dsm_lookup
+dsm_inverse
+configure
+.*/
+build/
+*.a
+*.deps
+*.la
+*.libs
+*.lo
+*.o
+*.swo
+*.swp
+*Makefile
+*Makefile.in
+.dirstamp
+.version
+aclocal.m4
+autom4te.cache
+config
+config.*
+config.h.in
+configure
+libtool
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
+stamp-h1
+compile
+depcomp
+install-sh
+ltmain.sh
+missing
+test-driver
+doltcompile
+doltlibtool
+libdsm.pc
+*.tar.gz
+*.zip
 

+ 0 - 86
Makefile

@@ -1,86 +0,0 @@
-##---------------------------------------------------------------------------
-##  __________________    _________  _____            _____  .__         ._.
-##  \______   \______ \  /   _____/ /     \          /  _  \ |__| ____   | |
-##   |    |  _/|    |  \ \_____  \ /  \ /  \        /  /_\  \|  _/ __ \  | |
-##   |    |   \|    `   \/        /    Y    \      /    |    |  \  ___/   \|
-##   |______  /_______  /_______  \____|__  / /\   \____|__  |__|\___ |   __
-##          \/        \/        \/        \/  )/           \/        \/   \/
-##
-## This file is part of libdsm. Copyright © 2014 VideoLabs SAS
-##
-## Author: Julien 'Lta' BALLET <contact@lta.io>
-##
-## This program is free software. It comes without any warranty, to the extent
-## permitted by applicable law. You can redistribute it and/or modify it under
-## the terms of the Do What The Fuck You Want To Public License, Version 2, as
-## published by Sam Hocevar. See the COPYING file for more details.
-##----------------------------------------------------------------------------
-
-
-
-CFLAGS      	= -Iinclude -I contrib -DBDSM_DEBUG=1 -D_BSD_SOURCE -std=c99 -fPIC
-LDFLAGS     	= #-levent
-CC          	= clang
-AR						= ar
-RANLIB				= ranlib
-
-LIB						= libdsm.so
-LIB_STATIC		= libdsm.a
-UTILS					= dsm discover inverse lookup
-
-LIB_SRC				= contrib/mdx/md5.c \
-			contrib/mdx/md4.c				\
-			src/hmac_md5.c					\
-			src/netbios_utils.c			\
-			src/netbios_ns.c				\
-			src/netbios_ns_entry.c	\
-			src/netbios_query.c			\
-			src/netbios_session.c		\
-			src/smb_utils.c					\
-			src/smb_message.c				\
-			src/smb_session.c				\
-			src/smb_ntlm.c					\
-			src/smb_share.c					\
-			src/smb_file.c					\
-			src/smb_trans2.c				\
-			src/context.c
-DSM_SRC				= dsm.c
-DISCOVER_SRC	= discover.c
-INVERSE_SRC		= inverse.c
-LOOKUP_SRC		= lookup.c
-
-LIB_LDFLAGS		= -shared
-
-LIB_OBJS			= $(LIB_SRC:.c=.o)
-
-all: $(LIB) $(LIB_STATIC) $(UTILS)
-
-clean:
-	rm -f $(UTILS) $(LIB) $(LIB_STATIC) *.o
-	rm -rf $(LIB_OBJS)
-
-re: clean all
-c: clean
-
-$(LIB): $(LIB_OBJS)
-	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(LIB_LDFLAGS) $(LIB_OBJS)
-$(LIB_STATIC): $(LIB_OBJS)
-	$(AR) -rcs $@ $(LIB_OBJS)
-
-
-test:
-
-dsm: $(LIB) $(DSM_SRC)
-	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DSM_SRC) $(LIB_STATIC)
-discover: $(LIB) $(DISCOVER_SRC)
-	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(DISCOVER_SRC) $(LIB_STATIC)
-inverse: $(LIB) $(INVERSE_SRC)
-	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(INVERSE_SRC) $(LIB_STATIC)
-lookup:  $(LIB) $(LOOKUP_SRC)
-	$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(LOOKUP_SRC) $(LIB_STATIC)
-
-.c.o:
-	$(CC) -c $(CFLAGS) -o $@ $<
-
-
-.PHONY: all clean re

+ 70 - 0
Makefile.am

@@ -0,0 +1,70 @@
+ACLOCAL_AMFLAGS = -I m4
+
+DISTCLEANFILES = @DOLT_CLEANFILES@
+
+EXTRA_DIST =
+
+CFLAGS = -Icontrib -Iinclude
+
+bdsmdir = $(includedir)/bdsm
+
+bdsm_HEADERS = \
+    include/bdsm.h			\
+    include/bdsm/context.h		\
+    include/bdsm/netbios_defs.h		\
+    include/bdsm/netbios_query.h	\
+    include/bdsm/netbios_utils.h	\
+    include/bdsm/smb_file.h		\
+    include/bdsm/smb_ntlm.h		\
+    include/bdsm/smb_session.h		\
+    include/bdsm/smb_trans2.h		\
+    include/bdsm/hmac_md5.h		\
+    include/bdsm/netbios_ns.h		\
+    include/bdsm/netbios_session.h	\
+    include/bdsm/smb_defs.h		\
+    include/bdsm/smb_message.h		\
+    include/bdsm/smb_packets.h		\
+    include/bdsm/smb_share.h		\
+    include/bdsm/smb_utils.h
+
+lib_LTLIBRARIES = libdsm.la
+
+libdsm_la_SOURCES = \
+    contrib/mdx/md5.c		\
+    contrib/mdx/md4.c		\
+    src/hmac_md5.c		\
+    src/netbios_utils.c		\
+    src/netbios_ns.c		\
+    src/netbios_ns_entry.c	\
+    src/netbios_query.c		\
+    src/netbios_session.c	\
+    src/smb_utils.c		\
+    src/smb_message.c		\
+    src/smb_session.c		\
+    src/smb_ntlm.c		\
+    src/smb_share.c		\
+    src/smb_file.c		\
+    src/smb_trans2.c		\
+    src/context.c
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libdsm.pc
+
+libdsm_la_LDFLAGS = -version-info @BDSM_LIBTOOL_VERSION@
+
+
+bin_PROGRAMS =
+
+if PROGRAMS
+bin_PROGRAMS += dsm dsm_discover dsm_inverse dsm_lookup
+endif
+
+dsm_SOURCES = dsm.c
+
+dsm_discover_SOURCES = discover.c
+
+dsm_inverse_SOURCES = inverse.c
+
+dsm_lookup_SOURCES = lookup.c
+
+LDADD = libdsm.la

+ 51 - 0
abi_version.sh

@@ -0,0 +1,51 @@
+#!/bin/sh
+# Copyright (c) 2013 Luca Barbato
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom
+# the Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+version="include/bdsm.h"
+PREFIX="BDSM"
+
+if [ ! -f $version ]; then
+    echo "abi_version.sh: error: $version does not exist" 1>&2
+    exit 1
+fi
+
+CURRENT=`egrep "^#define +${PREFIX}_VERSION_CURRENT +[0-9]+$" $version`
+REVISION=`egrep "^#define +${PREFIX}_VERSION_REVISION +[0-9]+$" $version`
+AGE=`egrep "^#define +${PREFIX}_VERSION_AGE +[0-9]+$" $version`
+
+if [ -z "$CURRENT" -o -z "$REVISION" -o -z "$AGE" ]; then
+    echo "abi_version.sh: error: could not extract version from $version" 1>&2
+    exit 1
+fi
+
+CURRENT=`echo $CURRENT | awk '{ print $3 }'`
+REVISION=`echo $REVISION | awk '{ print $3 }'`
+AGE=`echo $AGE | awk '{ print $3 }'`
+
+case $1 in
+    -libtool)
+        printf '%s' "$CURRENT:$REVISION:$AGE"
+    ;;
+    *)
+        printf '%s' "$CURRENT.$REVISION.$AGE"
+    ;;
+esac
+

+ 53 - 0
configure.ac

@@ -0,0 +1,53 @@
+AC_PREREQ([2.53])
+
+AC_INIT([libdsm], [m4_esyscmd([./package_version.sh])],
+   [], [libdsm], [])
+AC_CONFIG_SRCDIR([include/bdsm.h])
+AM_INIT_AUTOMAKE([1.6 foreign subdir-objects tar-ustar dist-zip])
+m4_ifdef([AM_SILENT_RULES], [
+    AM_SILENT_RULES([yes])
+])
+
+AC_CANONICAL_HOST
+
+BDSM_ABI_VERSION=m4_esyscmd([./abi_version.sh])
+BDSM_PACKAGE_VERSION=m4_esyscmd([./package_version.sh])
+BDSM_LIBTOOL_VERSION=m4_esyscmd([./abi_version.sh -libtool])
+
+AC_SUBST(BDSM_ABI_VERSION)
+AC_SUBST(BDSM_PACKAGE_VERSION)
+AC_SUBST(BDSM_LIBTOOL_VERSION)
+
+AC_MSG_NOTICE([dsm package version: $BDSM_PACKAGE_VERSION])
+AC_MSG_NOTICE([dsm ABI version: $BDSM_ABI_VERSION])
+
+AC_PROG_CC_C99
+AM_PROG_CC_C_O
+
+
+AC_ARG_ENABLE([programs],
+    AS_HELP_STRING([--enable-programs], [Build additional programs [default=yes]])
+)
+
+AC_ARG_ENABLE([debug],
+    AS_HELP_STRING([--enable-debug], [Additional debugging features [default=yes]])
+)
+
+AS_IF([test x"$enable_debug" != x"no"], [
+    AC_DEFINE([BDSM_DEBUG], [1])
+], [
+    AC_DEFINE([BDSM_DEBUG], [0])
+])
+
+AM_CONDITIONAL([PROGRAMS], [test x"$enable_programs" != x"no"])
+
+LT_INIT
+
+DOLT
+
+AC_CONFIG_MACRO_DIR([m4])
+
+AC_OUTPUT([
+Makefile
+libdsm.pc
+])

+ 4 - 0
include/bdsm.h

@@ -19,6 +19,10 @@
 #ifndef __BDSM_H_
 #define __BDSM_H_
 
+#define BDSM_VERSION_CURRENT  0
+#define BDSM_VERSION_REVISION 0
+#define BDSM_VERSION_AGE      0
+
 #include "bdsm/context.h"
 #include "bdsm/netbios_utils.h"
 #include "bdsm/netbios_session.h"

+ 0 - 0
libdsm.pc.in


+ 173 - 0
m4/dolt.m4

@@ -0,0 +1,173 @@
+dnl dolt, a replacement for libtool
+dnl Copyright © 2007-2010 Josh Triplett <josh@joshtriplett.org>
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.
+dnl
+dnl To use dolt, invoke the DOLT macro immediately after the libtool macros.
+dnl Optionally, copy this file into acinclude.m4, to avoid the need to have it
+dnl installed when running autoconf on your project.
+
+AC_DEFUN([DOLT], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+# dolt, a replacement for libtool
+# Josh Triplett <josh@freedesktop.org>
+AC_PATH_PROG([DOLT_BASH], [bash])
+AC_MSG_CHECKING([if dolt supports this host])
+dolt_supported=yes
+AS_IF([test x$DOLT_BASH = x], [dolt_supported=no])
+AS_IF([test x$GCC != xyes], [dolt_supported=no])
+
+AS_CASE([$host],
+    [*-*-linux*|*-*-freebsd*], [pic_options='-fPIC'],
+    [*-apple-darwin*],         [pic_options='-fno-common'],
+    [*mingw*|*nacl*],          [pic_options='']
+    [*],                       [dolt_supported=no]
+)
+AS_IF([test x$dolt_supported = xno], [
+    AC_MSG_RESULT([no, falling back to libtool])
+    LTCOMPILE='$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)'
+    LTCXXCOMPILE='$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)'
+    m4_pattern_allow([AM_V_lt])
+], [
+    AC_MSG_RESULT([yes, replacing libtool])
+
+dnl Start writing out doltcompile.
+    cat <<__DOLTCOMPILE__EOF__ >doltcompile
+#!$DOLT_BASH
+__DOLTCOMPILE__EOF__
+    cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+args=("$[]@")
+for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
+    if test x"${args@<:@$arg@:>@}" = x-o ; then
+        objarg=$((arg+1))
+        break
+    fi
+done
+if test x$objarg = x ; then
+    echo 'Error: no -o on compiler command line' 1>&2
+    exit 1
+fi
+lo="${args@<:@$objarg@:>@}"
+obj="${lo%.lo}"
+if test x"$lo" = x"$obj" ; then
+    echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
+    exit 1
+fi
+objbase="${obj##*/}"
+__DOLTCOMPILE__EOF__
+
+dnl Write out shared compilation code.
+    if test x$enable_shared = xyes; then
+        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+libobjdir="${obj%$objbase}.libs"
+if test ! -d "$libobjdir" ; then
+    mkdir_out="$(mkdir "$libobjdir" 2>&1)"
+    mkdir_ret=$?
+    if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
+	echo "$mkdir_out" 1>&2
+        exit $mkdir_ret
+    fi
+fi
+pic_object="$libobjdir/$objbase.o"
+args@<:@$objarg@:>@="$pic_object"
+__DOLTCOMPILE__EOF__
+    cat <<__DOLTCOMPILE__EOF__ >>doltcompile
+"\${args@<:@@@:>@}" $pic_options -DPIC || exit \$?
+__DOLTCOMPILE__EOF__
+    fi
+
+dnl Write out static compilation code.
+dnl Avoid duplicate compiler output if also building shared objects.
+    if test x$enable_static = xyes; then
+        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+non_pic_object="$obj.o"
+args@<:@$objarg@:>@="$non_pic_object"
+__DOLTCOMPILE__EOF__
+        if test x$enable_shared = xyes; then
+            cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+"${args@<:@@@:>@}" >/dev/null 2>&1 || exit $?
+__DOLTCOMPILE__EOF__
+        else
+            cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+"${args@<:@@@:>@}" || exit $?
+__DOLTCOMPILE__EOF__
+        fi
+    fi
+
+dnl Write out the code to write the .lo file.
+dnl The second line of the .lo file must match "^# Generated by .*libtool"
+    cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+{
+echo "# $lo - a libtool object file"
+echo "# Generated by doltcompile, not libtool"
+__DOLTCOMPILE__EOF__
+
+    if test x$enable_shared = xyes; then
+        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+echo "pic_object='.libs/${objbase}.o'"
+__DOLTCOMPILE__EOF__
+    else
+        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+echo pic_object=none
+__DOLTCOMPILE__EOF__
+    fi
+
+    if test x$enable_static = xyes; then
+        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+echo "non_pic_object='${objbase}.o'"
+__DOLTCOMPILE__EOF__
+    else
+        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+echo non_pic_object=none
+__DOLTCOMPILE__EOF__
+    fi
+
+    cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
+} > "$lo"
+__DOLTCOMPILE__EOF__
+
+dnl Done writing out doltcompile; substitute it for libtool compilation.
+    chmod +x doltcompile
+    LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
+    LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
+
+dnl automake ignores LTCOMPILE and LTCXXCOMPILE when it has separate CFLAGS for
+dnl a target, so write out a libtool wrapper to handle that case.
+dnl Note that doltlibtool does not handle inferred tags or option arguments
+dnl without '=', because automake does not use them.
+    cat <<__DOLTLIBTOOL__EOF__ > doltlibtool
+#!$DOLT_BASH
+__DOLTLIBTOOL__EOF__
+    cat <<'__DOLTLIBTOOL__EOF__' >>doltlibtool
+top_builddir_slash="${0%%doltlibtool}"
+: ${top_builddir_slash:=./}
+args=()
+modeok=false
+tagok=false
+for arg in "$[]@"; do
+    case "$arg" in
+        --mode=compile) modeok=true ;;
+        --tag=CC|--tag=CXX) tagok=true ;;
+        --silent|--quiet) ;;
+        *) args@<:@${#args[@]}@:>@="$arg" ;;
+    esac
+done
+if $modeok && $tagok ; then
+    . ${top_builddir_slash}doltcompile "${args@<:@@@:>@}"
+else
+    exec ${top_builddir_slash}libtool "$[]@"
+fi
+__DOLTLIBTOOL__EOF__
+
+dnl Done writing out doltlibtool; substitute it for libtool.
+    chmod +x doltlibtool
+    LIBTOOL='$(top_builddir)/doltlibtool'
+
+DOLT_CLEANFILES="doltlibtool doltcompile"
+AC_SUBST(DOLT_CLEANFILES)
+])
+AC_SUBST(LTCOMPILE)
+AC_SUBST(LTCXXCOMPILE)
+# end dolt
+])

+ 40 - 0
package_version.sh

@@ -0,0 +1,40 @@
+#!/bin/sh
+# Copyright (c) 2013 Luca Barbato
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom
+# the Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+# IN THE SOFTWARE.
+
+if [ -d .git ]; then
+    #  Retrieve the version from the last git tag.
+    VER=`git describe --always | sed -e "s:v::"`
+    if [ x"`git diff-index --name-only HEAD`" != x ]; then
+        #  If the sources have been changed locally, add -dirty to the version.
+        VER="${VER}-dirty"
+    fi
+elif [ -f .version ]; then
+    #  If git is not available (e.g. when building from source package)
+    #  we can extract the package version from .version file.
+    VER=`< .version`
+else
+    #  The package version cannot be retrieved.
+    VER="Unknown"
+fi
+
+printf '%s' "$VER"
+
+