--- src/Makefile
+++ src/Makefile
@@ -604,25 +604,6 @@
 endif
 #######################################################################################################
 #                                                                                                     #
-# additional include directories                                                                      #
-#                                                                                                     #
-#######################################################################################################
-ifeq "$(strip $(DECODER_CONFIG_LIBNETTLE))" "y"
-override CFLAGS += -I./include -DNETTLE
-override LDFLAGS += -L.
-endif
-#######################################################################################################
-#                                                                                                     #
-# additional libraries for linker calls                                                               #
-#                                                                                                     #
-#######################################################################################################
-ifeq "$(strip $(DECODER_CONFIG_LIBNETTLE))" "y"
-LDLIBS = -lnettle
-else
-LDLIBS = -lcrypto
-endif
-#######################################################################################################
-#                                                                                                     #
 # target binary name                                                                                  #
 #                                                                                                     #
 #######################################################################################################
@@ -671,6 +652,26 @@
 endif
 #######################################################################################################
 #                                                                                                     #
+# crypto library related flags                                                                        #
+#                                                                                                     #
+#######################################################################################################
+ifdef CRYPTOLIB_DIR
+override CPPFLAGS += -I$(CRYPTOLIB_DIR)/include
+override LDFLAGS  += -L$(CRYPTOLIB_DIR)/lib
+endif
+
+ifeq "$(strip $(DECODER_CONFIG_LIBNETTLE))" "y"
+override CPPFLAGS += -DNETTLE
+LDLIBS = -lnettle
+ifndef CRYPTOLIB_DIR
+override CPPFLAGS += -Iinclude
+override LDFLAGS  += -L.
+endif
+else
+LDLIBS = -lcrypto
+endif
+#######################################################################################################
+#                                                                                                     #
 # show values on debug                                                                                #
 #                                                                                                     #
 #######################################################################################################
