aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure44
-rw-r--r--src/opt.c4
2 files changed, 29 insertions, 19 deletions
diff --git a/configure b/configure
index fb6f25d..7fb7f06 100755
--- a/configure
+++ b/configure
@@ -16,10 +16,8 @@ prefix='/usr/local'
-
-dbg_objects=`printf %s "$objects" | sed -e "s/^/dbg_/"`
-sources_wdir=`printf %s "$sources" | sed -e "s/^/$srcdir\//"`
-objects_wdir=`printf %s "$objects" | sed -e "s/^/$objdir\//"`
+rls_objects=`printf %s "$objects" | sed -e "s/^/$objdir\/release\//" | tr '\n' ' '`
+dbg_objects=`printf %s "$objects" | sed -e "s/^/$objdir\/debug\//" | tr '\n' ' '`
dgen='gcc'
if [ ! `2>/dev/null which gcc` ]; then
@@ -40,12 +38,9 @@ fi
printf %s\\n "CFLAGSDEBUG = $cflagsdebug"
printf %s\\n "PREFIX = $prefix"
printf %s\\n ''
- printf %s\\n "all: objdir $target"
- printf %s\\n ''
- printf %s\\n "debug: objdir dbg_$target"
+ printf %s\\n "all: $target"
printf %s\\n ''
- printf %s\\n 'objdir:'
- printf %s\\n " mkdir -p $objdir"
+ printf %s\\n "debug: dbg_$target"
printf %s\\n ''
printf %s\\n "install: all"
printf %s\\n ' mkdir -p $(DESTDIR)$(PREFIX)/bin'
@@ -53,25 +48,40 @@ fi
printf %s\\n " cp -f $target \$(DESTDIR)\$(PREFIX)/bin"
printf %s\\n " gzip < ${target}.1 > \$(DESTDIR)\$(PREFIX)/share/man/man1/${target}.1.gz"
printf %s\\n ''
- printf %s\\n "$target: `printf %s "$objects" | tr '\n' ' '`"
- printf %s\\n " \$(CC) \$(LDFLAGS) -o $target `printf %s "$objects_wdir" | tr '\n' ' '` \$(LDLIBS)"
+ printf %s\\n "$target: ${objdir}/release $rls_objects"
+ printf %s\\n " \$(CC) \$(LDFLAGS) -o $target $rls_objects \$(LDLIBS)"
+ printf %s\\n ''
+ printf %s\\n "dbg_$target: ${objdir}/debug $dbg_objects"
+ printf %s\\n " \$(CC) \$(LDFLAGS) -o dbg_$target $dbg_objects \$(LDLIBS)"
+ printf %s\\n ''
+ printf %s\\n "${objdir}/release:"
+ printf %s\\n " mkdir -p ${objdir}/release"
+ printf %s\\n ''
+ printf %s\\n "${objdir}/debug:"
+ printf %s\\n " mkdir -p ${objdir}/debug"
printf %s\\n ''
- printf %s\\n "dbg_$target: `printf %s "$dbg_objects" | tr '\n' ' '`"
- printf %s\\n " \$(CC) \$(LDFLAGS) -o $target `printf %s "$objects_wdir" | tr '\n' ' '` \$(LDLIBS)"
+ printf %s\\n 'src/version.h:'
+ printf %s\\n ' printf "%s\n%s\n\n%s%s%s\n\n%s\n" \'
+ printf %s\\n ' "#ifndef CONFCONF_VERSION_H" \'
+ printf %s\\n ' "#define CONFCONF_VERSION_H" \'
+ printf %s\\n ' "#define VERSION \"confconf " "`git rev-parse --short=8 HEAD`" "\"" \'
+ printf %s\\n ' "#endif" > src/version.h'
printf %s\\n ''
printf %s\\n "$sources" | (while IFS= read -r s; do
- $dgen $CFLAGS -MM -MT `printf %s $s | sed -e 's/\.c$/\.o/'` "$srcdir/$s"
- printf %s\\n " \$(CC) -c \$(CFLAGS) -o ${objdir}/`printf %s $s | sed -e 's/\.c$/\.o/'` ${srcdir}/$s"
+ $dgen $CFLAGS -MM -MG -MT ${objdir}/release/`printf %s $s | sed -e 's/\.c$/\.o/'` "$srcdir/$s" | sed -e "s/version.h/$srcdir\/version.h/g"
+ printf %s\\n " \$(CC) -c \$(CFLAGS) -o ${objdir}/release/`printf %s $s | sed -e 's/\.c$/\.o/'` ${srcdir}/$s"
done
)
printf %s\\n ''
printf %s\\n "$sources" | (while IFS= read -r s; do
- $dgen $CFLAGS -MM -MT dbg_`printf %s $s | sed -e 's/\.c$/\.o/'` "$srcdir/$s"
- printf %s\\n " \$(CC) -c \$(CFLAGSDEBUG) -o ${objdir}/`printf %s $s | sed -e 's/\.c$/\.o/'` ${srcdir}/$s"
+ $dgen $CFLAGS -MM -MG -MT ${objdir}/debug/`printf %s $s | sed -e 's/\.c$/\.o/'` "$srcdir/$s" | sed -e "s/version.h/$srcdir\/version.h/g"
+ printf %s\\n " \$(CC) -c \$(CFLAGSDEBUG) -o ${objdir}/debug/`printf %s $s | sed -e 's/\.c$/\.o/'` ${srcdir}/$s"
done
)
printf %s\\n ''
printf %s\\n 'clean:'
+ printf %s\\n ' rm -f src/version.h'
printf %s\\n " rm -f $target"
+ printf %s\\n " rm -f dbg_$target"
printf %s\\n " rm -rf $objdir"
} > Makefile
diff --git a/src/opt.c b/src/opt.c
index 0f70293..ac6832e 100644
--- a/src/opt.c
+++ b/src/opt.c
@@ -1,3 +1,4 @@
+#include "version.h"
#include "opt.h"
#include "../reqs/simple-opt/simple-opt.h"
@@ -21,7 +22,6 @@ static struct simple_opt options[] = {
void opt_parse(int argc, char **argv)
{
struct simple_opt_result result;
- const char version[] = "confconf develop";
result = simple_opt_parse(argc, argv, options);
@@ -42,7 +42,7 @@ void opt_parse(int argc, char **argv)
/* version */
if (options[1].was_seen) {
- puts(version);
+ puts(VERSION);
exit(EXIT_SUCCESS);
}
}