Common version message for awesome and -client

At every build ("make", "make all"), if necessary, this
version message will be updated.

Note that "make awesome{,-client}" will NOT update the
version message.

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Hans Ulrich Niedermann 2008-01-25 11:49:18 +01:00 committed by Julien Danjou
parent 3d9c2e72fb
commit b457c4b4c9
5 changed files with 125 additions and 28 deletions

View File

@ -82,17 +82,18 @@ widgetgen.h: widget.h
@echo "generating widgetgen.h from widget.h"
$(top_srcdir)/build-utils/widgetgen.sh "$(top_srcdir)" > widgetgen.h
CLEANFILES += awesome-version.h
BUILT_SOURCES += awesome-version.h.stamp
awesome-version.h.stamp:
A_V = awesome-version-internal
CLEANFILES += $(A_V).h
BUILT_SOURCES += $(A_V).h.stamp
$(A_V).h.stamp:
@current_ver=`$(SHELL) $(top_srcdir)/build-utils/package-version $(top_srcdir) version-stamp`; \
{ echo '#ifndef AWESOME_VERSION_H'; \
echo "#define AWESOME_VERSION \"$${current_ver}\""; \
echo "#endif"; } > "awesome-version.h.new"
@if test -f "awesome-version.h" \
&& cmp "awesome-version.h.new" "awesome-version.h"; then :; \
else cat "awesome-version.h.new" > "awesome-version.h"; fi; \
rm -f "awesome-version.h.new"
{ echo '#ifndef AWESOME_VERSION_INTERNAL_H'; \
echo "#define AWESOME_VERSION_INTERNAL \"$${current_ver}\""; \
echo "#endif"; } > "$(A_V).h.new"
@if test -f "$(A_V).h" \
&& cmp "$(A_V).h.new" "$(A_V).h"; then :; \
else cat "$(A_V).h.new" > "$(A_V).h"; fi; \
rm -f "$(A_V).h.new"
if USING_GCC
# If you are using gcc, and want to deactivate this default set of
@ -108,6 +109,7 @@ AM_CPPFLAGS = $(XFT_CFLAGS) $(X_CFLAGS) $(CAIRO_CFLAGS) $(CONFUSE_CFLAGS) $(XRAN
bin_PROGRAMS += awesome
awesome_SOURCES = \
client.c client.h \
common/awesome-version.c common/awesome-version.h \
focus.c focus.h \
common/draw.c common/draw.h \
event.c event.h \
@ -132,9 +134,9 @@ awesome_SOURCES += $(WIDGETS)
awesome_LDADD = $(XFT_LIBS) $(X_LIBS) $(CAIRO_LIBS) $(CONFUSE_LIBS) $(XRANDR_LIBS) $(XINERAMA_LIBS)
bin_PROGRAMS += awesome-client
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = awesome-client$(EXEEXT)
awesome_client_SOURCES = \
awesome-client.c awesome-client.h \
common/awesome-version.c common/awesome-version.h \
common/awclient.c \
common/util.c common/util.h

View File

@ -27,6 +27,7 @@
#include <sys/un.h>
#include "awesome-client.h"
#include "common/awesome-version.h"
#include "common/util.h"
/* GNU/Hurd workaround */
@ -65,13 +66,43 @@ send_msg(char *msg, ssize_t msg_len)
return ret_value;
}
/** Print help and exit(2) with given exit_code.
*/
static void __attribute__ ((noreturn))
exit_help(int exit_code)
{
FILE *outfile = (exit_code == EXIT_SUCCESS) ? stdout : stderr;
fprintf(outfile, "Usage: awesome-client [--version|--help]\n"
"In normal operation, give no parameters and issue commands "
"on standard input.\n");
exit(exit_code);
}
int
main(void)
main(int argc, char *argv[])
{
char buf[1024], *msg;
int ret_value = EXIT_SUCCESS;
ssize_t len, msg_len = 1;
if (argc < 2)
{
/* no args to parse, nothing to do */
}
else if (argc == 2)
{
if(!a_strcmp("-v", argv[1]) || !a_strcmp("--version", argv[1]))
eprint_version("awesome-client");
else if(!a_strcmp("-h", argv[1]) || !a_strcmp("--help", argv[1]))
exit_help(EXIT_SUCCESS);
}
else
{
exit_help(EXIT_SUCCESS);
}
msg = p_new(char, 1);
while(fgets(buf, sizeof(buf), stdin))
{

View File

@ -38,7 +38,7 @@
#include <X11/extensions/shape.h>
#include <X11/extensions/Xrandr.h>
#include "awesome-version.h"
#include "common/awesome-version.h"
#include "awesome.h"
#include "event.h"
#include "layout.h"
@ -219,21 +219,7 @@ main(int argc, char *argv[])
{
args_ok = 0;
if(!a_strcmp("-v", argv[1]) || !a_strcmp("--version", argv[1]))
{
printf("awesome version " AWESOME_VERSION " (" AWESOME_RELEASE ")\ncompiled");
#if defined(__DATE__) && defined(__TIME__)
printf(" at " __DATE__ " " __TIME__);
#endif
printf(" for %s", AWESOME_COMPILE_MACHINE);
#if defined(__GNUC__) \
&& defined(__GNUC_MINOR__) \
&& defined(__GNUC_PATCHLEVEL__)
printf(" by gcc version %d.%d.%d",
__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#endif
printf(" (%s@%s)\n", AWESOME_COMPILE_BY, AWESOME_COMPILE_HOSTNAME);
return EXIT_SUCCESS;
}
eprint_version("awesome");
else if(!a_strcmp("-h", argv[1]) || !a_strcmp("--help", argv[1]))
exit_help(EXIT_SUCCESS);
else if(!a_strcmp("-c", argv[1]))

51
common/awesome-version.c Normal file
View File

@ -0,0 +1,51 @@
/* awesome-version.c - version message utility functions
*
* Copyright © 2008 Julien Danjou <julien@danjou.info>
* Copyright © 2008 Hans Ulrich Niedermann <hun@n-dimensional.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include "common/awesome-version.h"
#include "awesome-version-internal.h"
/** \brief Print version message and quit program.
*/
void
eprint_version(const char *const executable)
{
printf("%s (awesome) " AWESOME_VERSION_INTERNAL
" (" AWESOME_RELEASE ")\n"
"compiled",
executable);
#if defined(__DATE__) && defined(__TIME__)
printf(" at " __DATE__ " " __TIME__);
#endif
printf(" for %s", AWESOME_COMPILE_MACHINE);
#if defined(__GNUC__) \
&& defined(__GNUC_MINOR__) \
&& defined(__GNUC_PATCHLEVEL__)
printf(" by gcc version %d.%d.%d",
__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#endif
printf(" (%s@%s)\n", AWESOME_COMPILE_BY, AWESOME_COMPILE_HOSTNAME);
exit(EXIT_SUCCESS);
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

27
common/awesome-version.h Normal file
View File

@ -0,0 +1,27 @@
/* awesome-version.c - version message utility functions
*
* Copyright © 2008 Hans Ulrich Niedermann <hun@n-dimensional.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef AWESOME_VERSION_H
#define AWESOME_VERSION_H
void
eprint_version(const char *const executable)
__attribute__ ((noreturn));
#endif