diff --git a/.gitignore b/.gitignore
index 88db9a552..086f5f962 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,7 @@ _build
 /autom4te.cache
 /config.status
 /configure
+/Makefile.config
 
 # IntelliJ files
 /scripts/.idea/
diff --git a/Makefile.config.in b/Makefile.config.in
new file mode 100644
index 000000000..cf83d751d
--- /dev/null
+++ b/Makefile.config.in
@@ -0,0 +1,15 @@
+# Copyright (c) 2015 - present Facebook, Inc.
+# All rights reserved.
+#
+# This source code is licensed under the BSD style license found in the
+# LICENSE file in the root directory of this source tree. An additional grant
+# of patent rights can be found in the PATENTS file in the same directory.
+
+ABSOLUTE_ROOT_DIR = $(shell cd $(ROOT_DIR) && pwd)
+
+INFER_DIR = $(ABSOLUTE_ROOT_DIR)/infer
+DEPENDENCIES_DIR = $(ABSOLUTE_ROOT_DIR)/dependencies
+
+LIB_DIR = $(INFER_DIR)/lib
+
+JAVA_LIB_DIR = $(LIB_DIR)/java
diff --git a/configure.ac b/configure.ac
index 8588633de..019d1c0d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -49,4 +49,5 @@ AC_ASSERT_OCAML_PKG([yojson])
 # Checks for header files.
 AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h locale.h malloc.h stddef.h stdint.h stdlib.h string.h sys/mount.h sys/param.h sys/socket.h sys/statfs.h sys/time.h unistd.h wchar.h wctype.h])
 
+AC_CONFIG_FILES([Makefile.config])
 AC_OUTPUT
diff --git a/infer/annotations/Makefile b/infer/annotations/Makefile
index 29fd89ff6..6c8691d89 100644
--- a/infer/annotations/Makefile
+++ b/infer/annotations/Makefile
@@ -1,14 +1,22 @@
+# Copyright (c) 2015 - present Facebook, Inc.
+# All rights reserved.
+#
+# This source code is licensed under the BSD style license found in the
+# LICENSE file in the root directory of this source tree. An additional grant
+# of patent rights can be found in the PATENTS file in the same directory.
+
+ROOT_DIR = ../..
+include $(ROOT_DIR)/Makefile.config
+
 CWD = $(shell pwd)
-DEPENDENCIES = $(CWD)/../../dependencies
-LIB = $(CWD)/../lib/java
-JSR_JAR = $(DEPENDENCIES)/java/jsr-305/jsr305.jar
+JSR_JAR = $(DEPENDENCIES_DIR)/java/jsr-305/jsr305.jar
 ANNOT_SOURCES = $(shell find com/facebook/infer/annotation -name "*.java")
 PROCESSOR_SOURCES = $(shell find com/facebook/infer/annotprocess -name "*.java")
 ANNOT_CLASSES = 'annot_classes'
 PROCESSOR_CLASSES = 'processor_classes'
 
 ANNOTATIONS_JAR = $(CWD)/annotations.jar
-PROCESSOR_JAR = $(LIB)/processor.jar
+PROCESSOR_JAR = $(JAVA_LIB_DIR)/processor.jar
 
 all: $(ANNOTATIONS_JAR) $(PROCESSOR_JAR)
 
diff --git a/scripts/test.sh b/scripts/test.sh
index 72b6cfea5..1870bd49a 100755
--- a/scripts/test.sh
+++ b/scripts/test.sh
@@ -40,6 +40,8 @@ fi
   && exit 1
 
 cd $SCRIPT_DIR/..
+./autogen.sh
+./configure
 make -C infer ${TARGETS_TO_COMPILE[@]}
 
 # Must clean in order to force running the tests with the latest version