redid swap_endian() to allow arbitrary type
updated Makefile to use more variables