move macro defintions behind option settings

This allows us to access HDF5 variables in the macros.
tests are using HDF5 explicitly, so link against HDF5