Makefile 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. CC=gcc
  2. CFLAGS=-O3 -std=c99 -D_DEFAULT_SOURCE
  3. PYTHON_INC=/usr/include/python3.8
  4. PY_BIN_FILES:=$(patsubst src/%.py,bin/%.py,$(wildcard src/*.py))
  5. PY_DEV_FILES:=$(patsubst src/%.py,dev/%.py,$(wildcard src/*.py))
  6. VALGRIND_SUPPRESSION_BIN_FILES:=$(patsubst src/%.supp,bin/%.supp,$(wildcard src/*.supp))
  7. VALGRIND_SUPPRESSION_DEV_FILES:=$(patsubst src/%.supp,dev/%.supp,$(wildcard src/*.supp))
  8. all: bin_dir $(PY_BIN_FILES) bin/accelerated_functions.so $(VALGRIND_SUPPRESSION_BIN_FILES)
  9. dev: dev_dir $(PY_DEV_FILES) dev/accelerated_functions.so $(VALGRIND_SUPPRESSION_DEV_FILES)
  10. clean:
  11. @if [ -d bin ]; then rm -r bin; fi
  12. @if [ -d dev ]; then rm -r dev; fi
  13. bin/accelerated_functions.so: src/accelerated_functions.c
  14. dev/accelerated_functions.so: src/accelerated_functions.c
  15. #######
  16. bin/%.so: src/%.c
  17. $(CC) $(CFLAGS) -I $(PYTHON_INC) -shared -fPIC $^ -o $@
  18. bin/%.py: src/%.py
  19. @cp $< $@
  20. bin/%.supp: src/%.supp
  21. @cp $< $@
  22. bin_dir:
  23. @mkdir -p bin
  24. #######
  25. dev/%.so: src/%.c
  26. $(CC) $(CFLAGS) -I $(PYTHON_INC) -shared -fPIC $^ -o $@
  27. dev/%.py: src/%.py
  28. rm -f $@
  29. ln $< $@
  30. dev/%.supp: src/%.supp
  31. rm -f $@
  32. ln $< $@
  33. dev_dir:
  34. @mkdir -p dev