1
1

version configury: make dist now works

Update the VERSION file scheme:

* Remove "want_repo_rev".
* Add "tarball_version".

All values are now always included (major, minor, release, greek,
repo_rev).  However, configure.ac now runs "opal_get_version.sh
... --tarball", which will return the value of tarball_version (if it
is non-empty) or the "full" version string (i.e.,
"major.minor.releasegreek").
This commit is contained in:
Jeff Squyres 2014-10-02 07:31:47 -07:00
parent 8468424f45
commit 413e775dbf
13 changed files with 101 additions and 163 deletions

View File

@ -9,7 +9,7 @@
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2006-2010 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights reserved.
# Copyright (c) 2014 Intel, Inc. All rights reserved.
# $COPYRIGHT$
@ -25,6 +25,6 @@ EXTRA_DIST = README INSTALL VERSION Doxyfile LICENSE autogen.pl README.JAVA.txt
include examples/Makefile.include
dist-hook:
env LS_COLORS= csh "$(top_srcdir)/config/distscript.csh" "$(top_srcdir)" "$(distdir)" "$(OMPI_VERSION)" "$(OMPI_SVN_R)"
env LS_COLORS= csh "$(top_srcdir)/config/distscript.csh" "$(top_srcdir)" "$(distdir)" "$(OMPI_VERSION)" "$(OMPI_REPO_REV)"
ACLOCAL_AMFLAGS = -I config

48
VERSION
View File

@ -10,45 +10,37 @@
# number string.
# major, minor, and release are generally combined in the form
# <major>.<minor>.<release>. If release is zero, then it is omitted.
# <major>.<minor>.<release>.
major=1
minor=9
release=0
# greek is used for alpha or beta release tags. If it is non-empty,
# it will be appended to the version number. It does not have to be
# numeric. Common examples include a1 (alpha release 1),
# b1 (beta release 1), sc2005 (Super Computing 2005 release). The
# only requirement is that it must be entirely printable ASCII
# characters and have no white space.
# greek is generally used for alpha or beta release tags. If it is
# non-empty, it will be appended to the version number. It does not
# have to be numeric. Common examples include: a1 (alpha release 1),
# b1 (beta release 1), rc2 (release candidate 2). The only
# requirement is that it must be entirely printable ASCII characters
# and have no white space.
greek=a1
# If want_repo_rev=1, then the repo revision number will be included
# in the overall Open MPI version number in some form.
# If repo_rev is empty, then the repository version number will be
# obtained during "make dist" via the "git describe --tags --always"
# command, or with the date (if "git describe" fails) in the form of
# "date<date>".
want_repo_rev=1
repo_rev=
# If repo_rev=-1, then the repository version number will be obtained
# dynamically at run time, either:
#
# 1) via the "svnversion" command (if this is a Subversion checkout)
# in the form "r<svn_r>", or
# 2) via the "hg -v -R tip" command (if this is a Mercurial clone)
# in the form of "hg<hash>", using the hash tag at the tip
# 3) via the "git log -1" command (if this is a Git clone) in the form
# of "git<hash>", using the hash tag at the HEAD
# 4) with the date (if none of the above work) in the form of
# "date<date>".
#
# Alternatively, if repo_rev is not -1, the value of repo_rev_r will
# be directly appended to the version string. This happens during
# "make dist", for example: if the distribution tarball is being made
# from an SVN checkout, if repo_rev=-1, then its value is replaced
# with the output of "svnversion".
# If tarball_version is not empty, it is used as the version string in
# the tarball filename, regardless of all other versions listed in
# this file. For example, if tarball_version is empty, the tarball
# filename will be of the form
# openmpi-<major>.<minor>.<release><greek>.tar.*. However, if
# tarball_version is not empty, the tarball filename will be of the
# form openmpi-<tarball_version>.tar.*.
repo_rev=-1
tarball_version=gitclone
# The date when this release was created

View File

@ -33,12 +33,12 @@ elif ("$OMPI_VERSION" == "") then
endif
# we can catch some hard (but possible) to do mistakes by looking at
# our tree's revision number, but only if we are in the source tree.
# our repo's revision, but only if we are in the source tree.
# Otherwise, use what configure told us, at the cost of allowing one
# or two corner cases in (but otherwise VPATH builds won't work)
set repo_rev=$OMPI_REPO_REV
if (-d .svn) then
set repo_rev="r`svnversion .`"
if (-d .git) then
set repo_rev="`config/opal_get_version.sh VERSION --repo-rev`"
endif
set start=`date`
@ -66,22 +66,14 @@ if (! -d "$distdir") then
endif
#
# See if we need to update the version file with the current SVN
# revision number. Do this *before* entering the distribution tree to
# solve a whole host of problems with VPATH (since srcdir may be
# relative or absolute)
# Update VERSION:repo_rev with the best value we have.
#
set cur_repo_rev="`grep '^repo_rev' ${distdir}/VERSION | cut -d= -f2`"
if ("$cur_repo_rev" == "-1") then
sed -e 's/^repo_rev=.*/repo_rev='$repo_rev'/' "${distdir}/VERSION" > "${distdir}/version.new"
cp -f "${distdir}/version.new" "${distdir}/VERSION"
rm -f "${distdir}/version.new"
# need to reset the timestamp to not annoy AM dependencies
touch -r "${srcdir}/VERSION" "${distdir}/VERSION"
echo "*** Updated VERSION file with repo rev number"
else
echo "*** Did NOT update VERSION file with repo rev number"
endif
sed -e 's/^repo_rev=.*/repo_rev='$repo_rev'/' "${distdir}/VERSION" > "${distdir}/version.new"
cp -f "${distdir}/version.new" "${distdir}/VERSION"
rm -f "${distdir}/version.new"
# need to reset the timestamp to not annoy AM dependencies
touch -r "${srcdir}/VERSION" "${distdir}/VERSION"
echo "*** Updated VERSION file with repo rev number"
#########################################################
# VERY IMPORTANT: Now go into the new distribution tree #

View File

@ -6,16 +6,16 @@ dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2008-2014 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl
dnl Additional copyrights may follow
dnl
dnl
dnl $HEADER$
dnl
@ -27,20 +27,17 @@ dnl
# -----------------------------------------------
# parse version_file for version information, setting
# the following shell variables:
#
#
# prefix_VERSION
# prefix_BASE_VERSION
# prefix_MAJOR_VERSION
# prefix_MINOR_VERSION
# prefix_RELEASE_VERSION
# prefix_GREEK_VERSION
# prefix_WANT_REPO_REV
# prefix_REPO_REV
# prefix_TARBALL_VERSION
# prefix_RELEASE_DATE
m4_define([OPAL_GET_VERSION],[
: ${opal_ver_need_repo_rev=1}
: ${svnversion_result=-1}
dnl quote eval to suppress macro expansion with non-GNU m4
if test -f "$1"; then
srcdir=`dirname $1`
@ -51,8 +48,8 @@ m4_define([OPAL_GET_VERSION],[
s/^minor/$2_MINOR_VERSION/
s/^release/$2_RELEASE_VERSION/
s/^greek/$2_GREEK_VERSION/
s/^want_repo_rev/$2_WANT_REPO_REV/
s/^repo_rev/$2_REPO_REV/
s/^tarball_version/$2_TARBALL_VERSION/
s/^date/$2_RELEASE_DATE/
t print
b
@ -62,57 +59,33 @@ m4_define([OPAL_GET_VERSION],[
$2_VERSION="$$2_MAJOR_VERSION.$$2_MINOR_VERSION.$$2_RELEASE_VERSION"
$2_VERSION="${$2_VERSION}${$2_GREEK_VERSION}"
$2_BASE_VERSION=$$2_VERSION
if test $$2_WANT_REPO_REV -eq 1 && test $opal_ver_need_repo_rev -eq 1 ; then
if test "$svnversion_result" != "-1" ; then
$2_REPO_REV=$svnversion_result
fi
if test "$$2_REPO_REV" = "-1" ; then
m4_ifdef([AC_MSG_CHECKING],
[AC_MSG_CHECKING([for repo version])])
d=`date '+%m-%d-%Y'`
if test -d "$srcdir/.svn" ; then
$2_REPO_REV=r`svnversion "$srcdir"`
if test $? != 0; then
# The following is too long for Fortran
# $2_REPO_REV="unknown svn version (svnversion not found); $d"
$2_REPO_REV="? (no svnversion); $d"
fi
elif test -d "$srcdir/.hg" ; then
# Check to see if we can find the hg command
# remember that $? reflects the status of the
# *last* command in a pipe change, so if "hg ..
# cut ..." runs and "hg" is not found, $? will
# reflect the status of "cut", not hg not being
# found. So test for hg specifically first.
hg --version > /dev/null 2>&1
if test $? = 0; then
$2_REPO_REV=hg`hg -v -R "$srcdir" tip | grep ^changeset: | head -n 1 | cut -d: -f3`
else
# The following is too long for Fortran
# $2_REPO_REV="unknown hg version (hg not found); $d"
$2_REPO_REV="? (no hg); $d"
fi
elif test -d "$srcdir/.git" ; then
# By the same logic as above, check to see if we
# can find the "git" command.
git --version > /dev/null 2>&1
if test $? = 0; then
$2_REPO_REV=git`git log --pretty=format:'%h' -1`
else
# The following is too long for Fortran
# $2_REPO_REV="unknown hg version (hg not found); $d"
$2_REPO_REV="? (no git); $d"
fi
fi
if test "$2_REPO_REV" = ""; then
$2_REPO_REV="date$d"
fi
m4_ifdef([AC_MSG_RESULT],
[AC_MSG_RESULT([done])])
fi
$2_VERSION="${$2_VERSION}${$2_REPO_REV}"
if test "$$2_TARBALL_VERSION" = ""; then
$2_TARBALL_VERSION=$$2_VERSION
fi
m4_ifdef([AC_MSG_CHECKING],
[AC_MSG_CHECKING([for repo version])])
# If repo_rev was not set in the VERSION file, then get it now
if test "$$2_REPO_REV" = ""; then
# See if we can find the "git" command.
git_happy=0
git --version > /dev/null 2>&1
if test $? -eq 0; then
git_happy=1
fi
# If we're in a git repo and we found the git command, use
# git describe to get the repo rev
if test -d "$srcdir/.git" && test $git_happy -eq 1; then
$2_REPO_REV=`git describe --tags --always`
else
$2_REPO_REV="date`date '+%Y-%m-%d'`"
fi
fi
m4_ifdef([AC_MSG_RESULT],
[AC_MSG_RESULT([$$2_REPO_REV])])
fi
])

View File

@ -14,7 +14,7 @@ m4_divert_push([SCRIPT])dnl
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2008-2014 Cisco Systems, Inc. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
@ -66,14 +66,14 @@ case "$option" in
--repo-rev)
echo $OPAL_REPO_REV
;;
--base)
echo $OPAL_BASE_VERSION
--tarball)
echo $OPAL_TARBALL_VERSION
;;
--release-date)
echo $OPAL_RELEASE_DATE
;;
--all)
echo ${OPAL_VERSION} ${OPAL_MAJOR_VERSION} ${OPAL_MINOR_VERSION} ${OPAL_RELEASE_VERSION} ${OPAL_GREEK_VERSION} ${OPAL_REPO_REV}
echo ${OPAL_VERSION} : ${OPAL_MAJOR_VERSION} : ${OPAL_MINOR_VERSION} : ${OPAL_RELEASE_VERSION} : ${OPAL_GREEK_VERSION} : ${OPAL_REPO_REV} : ${OPAL_TARBALL_VERSION}
;;
-h|--help)
cat <<EOF
@ -86,9 +86,9 @@ $0 <srcfile> [<option>]
--minor - Minor version number
--release - Release version number
--greek - Greek (alpha, beta, etc) version number
--repo-rev - Repository version number
--repo-rev - Repository version
--tarball - Show tarball filename version string
--all - Show all version numbers, separated by :
--base - Show base version number (no repo number)
--release-date - Show the release date
--help - This message
EOF

View File

@ -6,19 +6,19 @@ dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2008-2012 Cisco Systems, Inc. All rights reserved.
dnl Copyright (c) 2008-2014 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl
dnl Additional copyrights may follow
dnl
dnl
dnl $HEADER$
dnl
# OPAL_SAVE_VERSION(project_short, project-long,
# OPAL_SAVE_VERSION(project_short, project-long,
# version_file, header_file])
# ----------------------------------------------
# creates version information for project from version_file, using
@ -31,8 +31,8 @@ AC_DEFUN([OPAL_SAVE_VERSION], [
AC_SUBST($1[_MINOR_VERSION])
AC_SUBST($1[_RELEASE_VERSION])
AC_SUBST($1[_GREEK_VERSION])
AC_SUBST($1[_WANT_REPO_REV])
AC_SUBST($1[_REPO_REV])
AC_SUBST($1[_TARBALL_VERSION])
AC_SUBST($1[_VERSION])
AC_SUBST($1[_RELEASE_DATE])
@ -40,7 +40,7 @@ AC_DEFUN([OPAL_SAVE_VERSION], [
AC_MSG_RESULT([$]$1[_VERSION])
AC_MSG_CHECKING([$2 release date])
AC_MSG_RESULT([$]$1[_RELEASE_DATE])
AC_MSG_CHECKING([$2 Subversion repository version])
AC_MSG_CHECKING([$2 repository version])
AC_MSG_RESULT([$]$1[_REPO_REV])
AC_DEFINE_UNQUOTED($1[_MAJOR_VERSION], [$]$1[_MAJOR_VERSION],
@ -51,14 +51,14 @@ AC_DEFUN([OPAL_SAVE_VERSION], [
[Release release number of ]$2)
AC_DEFINE_UNQUOTED($1[_GREEK_VERSION], ["$]$1[_GREEK_VERSION"],
[Greek - alpha, beta, etc - release number of ]$2)
AC_DEFINE_UNQUOTED($1[_REPO_REV], ["$]$1[_REPO_REV"],
[The repository version ]$2)
AC_DEFINE_UNQUOTED($1[_TARBALL_VERSION], ["$]$1[_TARBALL_VERSION"],
[Tarball filename version string of ]$2)
AC_DEFINE_UNQUOTED($1[_VERSION], ["$]$1[_RELEASE_VERSION"],
[Complete release number of ]$2)
AC_DEFINE_UNQUOTED($1[_RELEASE_DATE], ["$]$1[_RELEASE_DATE"],
[Release date of ]$2)
AC_DEFINE_UNQUOTED($1[_WANT_REPO_REV], [$]$1[_WANT_REPO_REV],
[Whether we want to include the repository version or not ]$2)
AC_DEFINE_UNQUOTED($1[_REPO_REV], ["$]$1[_REPO_REV"],
[The repository version ]$2)
AC_CONFIG_FILES([$4])
])dnl

View File

@ -36,8 +36,7 @@
# Load in everything found by autogen.pl
m4_include([config/autogen_found_items.m4])
# Load the version code. Because this is also used directly as a
# shell script, no ac_defun
# Load the version number code
m4_include([config/opal_get_version.m4])
AC_LANG([C])
@ -49,7 +48,7 @@ AC_LANG([C])
# was set during autogen.pl.
AC_INIT([project_name_long],
[m4_normalize(esyscmd([config/opal_get_version.sh VERSION --base]))],
[m4_normalize(esyscmd([config/opal_get_version.sh VERSION --tarball]))],
[http://www.open-mpi.org/community/help/], [project_name_short])
AC_PREREQ(2.60)
AC_CONFIG_AUX_DIR(config)
@ -180,21 +179,6 @@ m4_ifdef([project_ompi],
m4_ifdef([project_oshmem],
[AC_CONFIG_HEADER([oshmem/include/shmem.h])])
# override/fixup the version numbers set by AC_INIT, since on
# developer builds, there's no good way to know what the version is
# before running configure :(. We only use the base version number
# (i.e., no git hash) for the version set in AC_INIT. This will
# always match reality because we add the VERSION file (the only way
# to change the major.minor.release{greek}) into the configure
# dependencies. PACKAGE_VERSION the AC_DEFINE doesn't change once set
# the first time -- AC_INIT's input (so it doesn't have an r number in
# it). PACKAGE_VERSION the AC_SUBST can be rewritten along the way,
# and we'd like it to have the r number in it so that it shows up in
# the tarball name, so it is set to the full version here.
PACKAGE_VERSION="$OPAL_VERSION"
PACKAGE_STRING="${PACKAGE_NAME} ${PACKAGE_VERSION}"
VERSION="${PACKAGE_VERSION}"
opal_show_subtitle "Initialization, setup"
OMPI_TOP_BUILDDIR="`pwd`"

View File

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -104,8 +105,7 @@ int MPI_Get_library_version(char *version, int *resultlen)
}
/* Repository revision */
if (OMPI_WANT_REPO_REV &&
NULL != OMPI_REPO_REV && strlen(OMPI_REPO_REV) > 0) {
if (NULL != OMPI_REPO_REV && strlen(OMPI_REPO_REV) > 0) {
snprintf(ptr, len_left, ", repo rev: %s", OMPI_REPO_REV);
ptr = tmp + strlen(tmp);
len_left = MPI_MAX_LIBRARY_VERSION_STRING - strlen(tmp);

View File

@ -10,7 +10,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2007-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2011-2012 University of Houston. All rights reserved.
* Copyright (c) 2010-2013 Los Alamos National Security, LLC.
* All rights reserved.
@ -120,7 +120,7 @@ void ompi_info_show_ompi_version(const char *scope)
OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
OMPI_RELEASE_VERSION,
OMPI_GREEK_VERSION,
OMPI_WANT_REPO_REV, OMPI_REPO_REV);
OMPI_REPO_REV);
opal_info_out("Open MPI", tmp, tmp2);
free(tmp);
free(tmp2);
@ -141,7 +141,7 @@ void ompi_info_show_ompi_version(const char *scope)
tmp2 = opal_info_make_version_str(scope,
MPI_VERSION, MPI_SUBVERSION,
0, "", 0, "");
0, "", "");
opal_info_out("MPI API", "mpi-api:version:full", tmp2);
free(tmp2);

View File

@ -999,15 +999,15 @@ void opal_info_show_mca_version(const mca_base_component_t* component,
mca_version = opal_info_make_version_str(scope, component->mca_major_version,
component->mca_minor_version,
component->mca_release_version, "",
false, "");
"");
api_version = opal_info_make_version_str(scope, component->mca_type_major_version,
component->mca_type_minor_version,
component->mca_type_release_version, "",
false, "");
"");
component_version = opal_info_make_version_str(scope, component->mca_component_major_version,
component->mca_component_minor_version,
component->mca_component_release_version,
"", false, "");
"", "");
if (opal_info_pretty) {
asprintf(&message, "MCA %s", component->mca_type_name);
printed = false;
@ -1090,8 +1090,8 @@ void opal_info_show_mca_version(const mca_base_component_t* component,
char *opal_info_make_version_str(const char *scope,
int major, int minor, int release,
const char *greek,
bool want_repo_rev, const char *repo)
const char *greek,
const char *repo)
{
char *str = NULL, *tmp;
char temp[BUFSIZ];
@ -1106,11 +1106,6 @@ char *opal_info_make_version_str(const char *scope,
free(str);
str = tmp;
}
if (want_repo_rev && NULL != repo) {
asprintf(&tmp, "%s%s", str, repo);
free(str);
str = tmp;
}
} else if (0 == strcmp(scope, opal_info_ver_major)) {
snprintf(temp, BUFSIZ - 1, "%d", major);
} else if (0 == strcmp(scope, opal_info_ver_minor)) {
@ -1139,7 +1134,7 @@ void opal_info_show_opal_version(const char *scope)
OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
OPAL_GREEK_VERSION,
OPAL_WANT_REPO_REV, OPAL_REPO_REV);
OPAL_REPO_REV);
opal_info_out("OPAL", tmp, tmp2);
free(tmp);
free(tmp2);

View File

@ -1,6 +1,7 @@
/*
* Copyright (c) 2012-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -89,8 +90,8 @@ OPAL_DECLSPEC void opal_info_show_component_version(opal_pointer_array_t *mca_ty
OPAL_DECLSPEC char *opal_info_make_version_str(const char *scope,
int major, int minor, int release,
const char *greek,
bool want_repo, const char *repo);
const char *greek,
const char *repo);
OPAL_DECLSPEC void opal_info_show_opal_version(const char *scope);

View File

@ -10,7 +10,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2010-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2011-2012 University of Houston. All rights reserved.
@ -97,7 +97,7 @@ void orte_info_show_orte_version(const char *scope)
ORTE_MAJOR_VERSION, ORTE_MINOR_VERSION,
ORTE_RELEASE_VERSION,
ORTE_GREEK_VERSION,
ORTE_WANT_REPO_REV, ORTE_REPO_REV);
ORTE_REPO_REV);
opal_info_out("Open RTE", tmp, tmp2);
free(tmp);
free(tmp2);

View File

@ -1,6 +1,7 @@
/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -85,7 +86,7 @@ void oshmem_info_show_oshmem_version(const char *scope)
OSHMEM_MAJOR_VERSION, OSHMEM_MINOR_VERSION,
OSHMEM_RELEASE_VERSION,
OSHMEM_GREEK_VERSION,
OSHMEM_WANT_REPO_REV, OSHMEM_REPO_REV);
OSHMEM_REPO_REV);
opal_info_out("Open SHMEM", tmp, tmp2);
free(tmp);
free(tmp2);