Skip to content

Instantly share code, notes, and snippets.

@t-mat
Created July 29, 2014 17:40
Show Gist options
  • Save t-mat/fe34c0c041409a95e4d0 to your computer and use it in GitHub Desktop.
Save t-mat/fe34c0c041409a95e4d0 to your computer and use it in GitHub Desktop.
LZ4 Makefile test
## Old
##
## LIBVER_MAJOR=`sed -n '/LZ4_VERSION_MAJOR/s/.*\s\+\([0-9]\+\).*/\1/p' < lz4.h`
## LIBVER_MINOR=`sed -n '/LZ4_VERSION_MINOR/s/.*\s\+\([0-9]\+\).*/\1/p' < lz4.h`
## LIBVER_PATCH=`sed -n '/LZ4_VERSION_RELEASE/s/.*\s\+\([0-9]\+\).*/\1/p' < lz4.h`
## New
##
## (1) Need 'define ' to match only one line.
## (2) Use ' ' instead of '\s' for the compatibility. (Perhaps '[:blank:]' is better)
## (3) Use 'XX*' instead of 'X+' for the compatibility.
##
LIBVER_MAJOR=`sed -n '/define LZ4_VERSION_MAJOR/s/.* \([0-9][0-9]*\).*/\1/p' < lz4.h`
LIBVER_MINOR=`sed -n '/define LZ4_VERSION_MINOR/s/.* \([0-9][0-9]*\).*/\1/p' < lz4.h`
LIBVER_PATCH=`sed -n '/define LZ4_VERSION_RELEASE/s/.* \([0-9][0-9]*\).*/\1/p' < lz4.h`
LIBVER=$(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)
default:
@echo $(LIBVER)
@t-mat
Copy link
Author

t-mat commented Jul 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment