Makefile 829 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. INCLUDE_PATH ?= ./include
  2. INCLUDE_FASMG ?= ${INCLUDE_PATH}/fasmg
  3. INCLUDE_COMMON ?= ${INCLUDE_PATH}/common
  4. INCLUDE := ${INCLUDE_FASMG};${INCLUDE_COMMON}
  5. FANCY_SYSCALL ?= | sort -nk 3 | column -t
  6. SYSCALL_INC ?= ${INCLUDE_COMMON}/syscall.inc
  7. rwildcard = $(foreach d,$(wildcard $1/*),$(call rwildcard,$d,$2) \
  8. $(filter $(subst *,%,$2),$d))
  9. FASMG ?= fasmg
  10. .PHONY: all
  11. all: pd
  12. ${SYSCALL_INC}:
  13. mkdir -p '$(dir $@)'
  14. { echo '; vim: ft=fasm:' \
  15. ; echo 'if ~ definite syscall' \
  16. ; echo 'namespace syscall' \
  17. ; echo '#include <sys/syscall.h>' \
  18. | cpp -dM \
  19. | sed -n 's/^#define\s\(SYS_[^ ]\+\) \([0-9]\+\)$$/\1 equ \2/p' \
  20. ${FANCY_SYSCALL} \
  21. ; echo 'end namespace' \
  22. ; echo 'end if' \
  23. ; } > $@
  24. export INCLUDE
  25. %: %.asm $(call rwildcard,./include,*.inc)
  26. ${FASMG} $< $@
  27. chmod +x $@
  28. .PHONY: clean
  29. clean:
  30. rm -f pd