diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6f75ead96cbc10d06a0b1a9c1ffd0afcca841ef8..d05dde01c84a7c183cd123cb693397c5e672a063 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,6 +38,11 @@ configure_file(
   "cmake/config.h.in"
   "${CMAKE_CURRENT_BINARY_DIR}/config.h")
 
+# Create libaec.h with current version information
+configure_file(
+  "include/libaec.h.in"
+  "${CMAKE_CURRENT_BINARY_DIR}/include/libaec.h")
+
 add_subdirectory(src)
 if(BUILD_TESTING)
   add_subdirectory(tests)
@@ -89,6 +94,7 @@ endif()
 set(CPACK_SOURCE_IGNORE_FILES
     /.git
     /.*build.*
+    /*.cache
     .*~
     .*\#.*\#
     \..*\#.*)
diff --git a/configure.ac b/configure.ac
index bac0fed1401129f2fbfadd7592498c2e7f8cde63..e2ba962fc3f76b92ff71b19730908f24b6b4acc8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,14 @@
 AC_PREREQ([2.64])
-AC_INIT([libaec], [1.0.6], [rosenhauer@dkrz.de])
+
+m4_define([VERSION_MAJOR], [1])
+m4_define([VERSION_MINOR], [0])
+m4_define([VERSION_PATCH], [6])
+
+AC_INIT([libaec], [VERSION_MAJOR.VERSION_MINOR.VERSION_PATCH], [rosenhauer@dkrz.de])
+
+AC_SUBST(PROJECT_VERSION_MAJOR, [VERSION_MAJOR])
+AC_SUBST(PROJECT_VERSION_MINOR, [VERSION_MINOR])
+AC_SUBST(PROJECT_VERSION_PATCH, [VERSION_PATCH])
 
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_AUX_DIR([config])
@@ -30,5 +39,5 @@ AC_CHECK_DECLS(__builtin_clzll)
 
 AM_EXTRA_RECURSIVE_TARGETS([bench benc bdec])
 
-AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile])
+AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile include/libaec.h])
 AC_OUTPUT
diff --git a/include/libaec.h b/include/libaec.h.in
similarity index 95%
rename from include/libaec.h
rename to include/libaec.h.in
index b159f34ff382f875227d6773a7eda475ca3fa787..a38bc70558539a8db9e20ce8f08529bfd67c4f56 100644
--- a/include/libaec.h
+++ b/include/libaec.h.in
@@ -38,6 +38,11 @@
 #ifndef LIBAEC_H
 #define LIBAEC_H 1
 
+#define AEC_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
+#define AEC_VERSION_MINOR @PROJECT_VERSION_MINOR@
+#define AEC_VERSION_PATCH @PROJECT_VERSION_PATCH@
+#define AEC_VERSION_STR "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@"
+
 #include <stddef.h>
 
 #ifdef __cplusplus
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 29d62f2b843658200ab2c9f5e700c1b0e618b49f..31a73366c185b101149b87f0e1435ce85653ddfe 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,7 +24,7 @@ set_target_properties(aec_shared
   VERSION 0.0.12
   SOVERSION 0
   OUTPUT_NAME aec
-  PUBLIC_HEADER ../include/libaec.h)
+  PUBLIC_HEADER ${CMAKE_CURRENT_BINARY_DIR}/../include/libaec.h)
 
 # Wrapper for compatibility with szip
 add_library(sz OBJECT sz_compat.c)
diff --git a/src/Makefile.am b/src/Makefile.am
index 0ac4914e0350b2236ee3f55d2997cdd774fbd4d4..e263a22416f5e487e570687651e3e440132a6311 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,7 +9,7 @@ libsz_la_SOURCES = sz_compat.c
 libsz_la_LIBADD = libaec.la
 libsz_la_LDFLAGS = -version-info 2:1:0 -no-undefined
 
-include_HEADERS = $(top_srcdir)/include/libaec.h $(top_srcdir)/include/szlib.h
+include_HEADERS = $(top_builddir)/include/libaec.h $(top_srcdir)/include/szlib.h
 
 bin_PROGRAMS = aec
 noinst_PROGRAMS = utime
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ef122eabcc34b38fc369a70e4f5601ddb4ef7871..50b2036828345c077e7a778ccea35d736d40d5eb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,13 +10,13 @@ check_PROGRAMS = check_code_options check_buffer_sizes check_long_fs \
 check_szcomp
 
 check_code_options_SOURCES = check_code_options.c check_aec.h \
-$(top_srcdir)/include/libaec.h
+$(top_builddir)/include/libaec.h
 
 check_buffer_sizes_SOURCES = check_buffer_sizes.c check_aec.h \
-$(top_srcdir)/include/libaec.h
+$(top_builddir)/include/libaec.h
 
 check_long_fs_SOURCES = check_long_fs.c check_aec.h \
-$(top_srcdir)/include/libaec.h
+$(top_builddir)/include/libaec.h
 
 check_szcomp_SOURCES = check_szcomp.c $(top_srcdir)/include/szlib.h