move Makefile to common.mk and add a LIB variable that makes it easy to use this from a subdirectory. Also fix section alignment issues in .text
This also improves sys_ip slightly.