summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2017-01-12 14:44:58 -0600
committerDavid Teigland <teigland@redhat.com>2017-02-07 10:38:30 -0600
commit23913241961e851a1d639b0ab3418622e1f9ed45 (patch)
treeb8bb9d751a42c205faf0ac38a5a44626331466c6
parente8230719eea1062c1f32b975450f5eb9f219482e (diff)
downloadlvm2-23913241961e851a1d639b0ab3418622e1f9ed45.tar.gz
Makefile: clean up create-command parts
-rw-r--r--tools/Makefile.in36
1 files changed, 31 insertions, 5 deletions
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 887bc697a..85251b909 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -1,3 +1,4 @@
+
#
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
@@ -140,6 +141,8 @@ all: device-mapper
CFLAGS_lvm.o += $(EXTRA_EXEC_CFLAGS)
CFLAGS_lvmcmdline.o += $(VALGRIND_CFLAGS)
+INCLUDES += -I$(top_builddir)/tools
+
lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $(OBJECTS) lvm.o \
$(LVMLIBS) $(READLINE_LIBS) $(LIBS) -rdynamic
@@ -173,12 +176,35 @@ liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION): liblvm2cmd.$(LIB_SUFFIX)
$(CC) -E -P $(srcdir)/cmdnames.h 2> /dev/null | \
egrep -v '^ *(|#.*|config|devtypes|dumpconfig|formats|fullreport|help|lastlog|lvpoll|pvdata|segtypes|systemid|tags|version) *$$' > .commands
-ccmd: create-commands.c
- $(CC) create-commands.c -o ccmd
+ccmd: $(srcdir)/create-commands.c
+ $(CC) $(srcdir)/create-commands.c -o ccmd
+
+.DELETE_ON_ERROR:
+
+command-lines.h: $(srcdir)/command-lines.in ccmd
+ $(top_builddir)/tools/ccmd --output struct $(srcdir)/command-lines.in > $@
+
+command-lines-count.h: $(srcdir)/command-lines.in ccmd
+ $(top_builddir)/tools/ccmd --output count $(srcdir)/command-lines.in > $@
+
+# move properly to configure
+WC = /usr/bin/wc
+GREP = /bin/grep
+SORT = /bin/sort
+CUT = /bin/cut
+SED = /bin/sed
+
+# FIXME Add licence text from template file
+command-lines-count-new.h: $(srcdir)/command-lines.in ccmd Makefile
+ set -o pipefail && \
+ (echo -n "#define COMMAND_COUNT " && \
+ $(GREP) '^ID:' $(srcdir)/command-lines.in | $(WC) -l && \
+ echo -e "enum {\n\tno_CMD," && \
+ $(GREP) '^ID:' $(srcdir)/command-lines.in | $(CUT) -d\ -f2 | $(SORT) -u | $(SED) 's/\(.*\)/\t&_CMD,/' && \
+ echo -e "\tCOMMAND_ID_COUNT,\n};" \
+ ) > $@
-command-lines.h: ccmd
- ./ccmd --output struct command-lines.in > command-lines.h
- ./ccmd --output count command-lines.in > command-lines-count.h
+$(SOURCES:%.c=%.d): command-lines.h command-lines-count.h
ifneq ("$(CFLOW_CMD)", "")
CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))