123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- CC=gcc
- NASM=nasm
- LD=ld
-
- ifeq ($(DEBUG), 1)
- CFLAGS=-ggdb -fPIC -Wall -DDEBUG -Wsign-compare
- LDFLAGS=-g
- NASMCFLAGS=-g -f elf64
- #PYTHON=python3dm
- PYTHON=python3-dbg
- else
- CFLAGS=-fPIC -Wall -Werror -DNDEBUG
- LDFLAGS=-s
- NASMCFLAGS=-f elf64
- PYTHON=python3
- endif
-
- PYTHON_CONFIG=$(PYTHON)-config
- PYTHON_CFLAGS=`$(PYTHON_CONFIG) --includes` `$(PYTHON_CONFIG) --cflags`
- PYTHON_LDFLAGS=-shared -fPIC `$(PYTHON_CONFIG) --libs` `$(PYTHON_CONFIG) --ldflags|cut -d' ' -f1,2`
-
- C_SOURCES=$(wildcard *.c)
- C_OBJS=$(patsubst %.c,%.o,$(C_SOURCES))
- HEADERS=$(wildcard *.h)
- ASM_SOURCES=$(wildcard *.asm)
- ASM_OBJS=$(patsubst %.asm,%.o,$(ASM_SOURCES))
- OBJS=$(ASM_OBJS) $(C_OBJS)
- LIB=pyrpn.so
-
- CFLAGS_COV=$(CFLAGS) --coverage
- LDFLAGS_COV=$(LDFLAGS)
- C_OBJS_COV=$(patsubst %.c,%_cov.o,$(C_SOURCES))
- C_GCNO=$(patsubst %.o,%.gcno,$(C_OBJS_COV))
- C_GCDA=$(patsubst %.o,%.gcda,$(C_OBJS_COV))
- OBJS_COV=$(ASM_OBJS) $(C_OBJS_COV)
- LIB_COV=tests/pyrpn.so
-
- all: .deps pyrpn.so
-
- $(C_OBJS): %.o: %.c $(HEADERS)
- $(CC) $(PYTHON_CFLAGS) $(CFLAGS) -c -o $@ $<
-
- $(ASM_OBJS): %.o: %.asm $(HEADERS)
- $(NASM) $(NASMCFLAGS) -o $@ $<
-
- $(LIB): $(OBJS)
- $(LD) $(LDFLAGS) $(PYTHON_LDFLAGS) -o $@ $^
-
-
- $(C_OBJS_COV): %_cov.o: %.c $(HEADERS)
- $(CC) $(PYTHON_CFLAGS) $(CFLAGS_COV) -c -o $@ $<
-
- $(LIB_COV): $(OBJS_COV)
- gcc $(LDFLAGS_COV) $(PYTHON_LDFLAGS) -o $@ $^ --coverage -lgcov
-
-
- # Doxygen documentation
- doc: doc/.doxygen.stamp
-
- Doxyfile: Doxyfile.mk
- echo "PROJECT_NUMBER = `cat VERSION`_rev:`git rev-parse --short HEAD`" > $@
- cat $< >> $@
-
- doc/.doxygen.stamp: $(wildcard *.c) $(wildcard *.h) Doxyfile
- touch doc/.doxygen.stamp
- doxygen 1>/dev/null
- echo "Documentation in file://`pwd`/doc/html/index.html"
-
- # Dependencies checking
- .deps: check_deps.sh
- sh check_deps.sh "$(CC)" "$(LD)" "$(NASM)" "$(PYTHON)" "$(PYTHON_CONFIG)" && touch .deps
-
- .PHONY: clean distclean checks runtest unittest benchmark
-
- checks: runtest unittest
-
- benchmark: $(LIB)
- PYTHONPATH=`pwd` $(PYTHON) tests/benchmark.py -c 0x500 -i 0x2000 -s 0x50; \
- PYTHONPATH=`pwd` $(PYTHON) tests/benchmark.py -c 0x500 -i 0x2000 -s 0xa0; \
- PYTHONPATH=`pwd` $(PYTHON) tests/benchmark.py -c 0x500 -i 0x2000 -s 0x100; \
- PYTHONPATH=`pwd` $(PYTHON) tests/benchmark.py -c 0x500 -i 0x5000 -s 0x50; \
- PYTHONPATH=`pwd` $(PYTHON) tests/benchmark.py -c 0x500 -i 0x5000 -s 0xa0; \
- PYTHONPATH=`pwd` $(PYTHON) tests/benchmark.py -c 0x500 -i 0x5000 -s 0x100; \
-
-
- unittest: $(LIB_COV)
- cd tests;\
- $(PYTHON) -m unittest -v -f
-
- lcov.info: unittest runtest
- lcov --no-external --base-directory ./ --capture --directory ./ --output-file $@
-
- lcov_html: lcov.info
- genhtml $< --output-directory $@
-
- coverage: lcov_html
-
-
- runtest:
- make -C tests
-
- clean:
- -rm -fv $(OBJS) $(LIB) test;\
- rm -fRv doc/.doxygen.stamp doc/* Doxyfile;\
- rm -fRv $(OBJS_COV) $(C_GCNO) $(C_GCDA) $(LIB_COV) lcov_html lcov.info;\
- make -C tests clean
-
- distclean: clean
- -rm -vf .deps;\
- rm -Rvf tests/__pycache__;
|