Skip to content

Commit

Permalink
show version
Browse files Browse the repository at this point in the history
  • Loading branch information
endaaman committed Jul 7, 2017
1 parent 4b6e334 commit 1676726
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ m4/
missing
stamp-h?

src/version.h
tym
tym-*.tar.gz
5 changes: 2 additions & 3 deletions cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ rm -f Makefile
rm -f Makefile.in
rm -f aclocal.m4
rm -f compile
rm -f config.h
rm -f config.h.in
rm -f config.h.in~
rm -f config.log
rm -f config.status
rm -f configure
Expand All @@ -32,4 +29,6 @@ rm -rf src/.libs
rm -rf src/libtool
rm -rf src/toollib/.deps

rm -rf src/version.h

echo 'Cleaned files.'
23 changes: 19 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

m4_define([tym_major_version],[0])
m4_define([tym_minor_version],[2])
m4_define([tym_micro_version],[2])
m4_define([tym_version],[tym_major_version().tym_minor_version().tym_micro_version()])

AC_PREREQ([2.69])
AC_INIT([tym], [0.2.2])
AC_INIT([tym], [tym_version()])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_SRCDIR([src/tym.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
src/Makefile
src/version.h
])

AC_ARG_ENABLE(debug,
AS_HELP_STRING(
Expand All @@ -20,6 +29,14 @@ AS_HELP_STRING(

AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")

TYM_MAJOR_VERSION=tym_major_version()
TYM_MINOR_VERSION=tym_minor_version()
TYM_MICRO_VERSION=tym_micro_version()

AC_SUBST(TYM_MAJOR_VERSION)
AC_SUBST(TYM_MINOR_VERSION)
AC_SUBST(TYM_MICRO_VERSION)

# Checks for programs.
AC_PROG_CC

Expand All @@ -33,6 +50,4 @@ AC_PROG_CC
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES(TYM, [gtk+-3.0 vte-2.91 lua53 ])

AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
17 changes: 17 additions & 0 deletions src/tym.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,23 @@ static void start(GHashTable* c) {

int main(int argc, char* argv[])
{
bool version = false;
GOptionEntry entries[] = {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &version, "Show Version", NULL },
{ NULL }
};
GOptionContext* context = g_option_context_new("");
GError *error = NULL;
g_option_context_add_main_entries(context, entries, NULL);
if (!g_option_context_parse(context, &argc, &argv, &error)) {
g_printerr ("option parsing failed: %s\n", error->message);
return 1;
}
if (version) {
g_print ("version %s\n", TYM_VERSION);
return 0;
}

init_config_fields();
GHashTable *config = config_init();
config_load(config);
Expand Down
1 change: 1 addition & 0 deletions src/tym.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
#include <vte/vte.h>

#include "config.h"
#include "version.h"

#endif
20 changes: 20 additions & 0 deletions src/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* tym.h
*
* Copyright (c) 2017 endaaman
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/

#ifndef VERSION_H
#define VERSION_H

#define TYM_MAJOR_VERSION (@TYM_MAJOR_VERSION@)
#define TYM_MINOR_VERSION (@TYM_MINOR_VERSION@)
#define TYM_MICRO_VERSION (@TYM_MICRO_VERSION@)

#define TYM_VERSION ("@TYM_MAJOR_VERSION@.@TYM_MINOR_VERSION@.@TYM_MICRO_VERSION@")


#endif

0 comments on commit 1676726

Please sign in to comment.