Add library project file
[cuda-ada.git] / Makefile
1 CUDASDK = /usr/local/cuda
2 OBJDIR  = obj
3 LIBDIR  = lib
4 COVDIR  = $(OBJDIR)/cov
5 PERFDIR = perf
6
7 LIBRARY_PATH = $(CUDASDK)/lib:$(CUDASDK)/lib64
8
9 NUM_CPUS := $(shell getconf _NPROCESSORS_ONLN)
10 ARCH     ?= $(shell uname -m)
11
12 GMAKE_OPTS = -p -R -j$(NUM_CPUS)
13
14 MAJOR    = 0
15 MINOR    = 1
16 VERSION  = $(MAJOR).$(MINOR)
17 CUDA_ADA = libcudaada-$(VERSION)
18 TARBALL  = $(CUDA_ADA).tar.bz2
19
20 SO_LIBRARY   = libcudaada.so.$(VERSION)
21 LIBRARY_KIND = dynamic
22
23 all: build_lib
24
25 build_lib:
26         @LIBRARY_PATH=$(LIBRARY_PATH) gnatmake -p -Pcuda_lib \
27                 -XARCH=$(ARCH) -XVERSION="$(VERSION)" -XLIBRARY_KIND="$(LIBRARY_KIND)"
28
29 build_examples:
30         @LIBRARY_PATH=$(LIBRARY_PATH) gnatmake -p -Pcuda_examples -XARCH=$(ARCH)
31
32 build_tests:
33         @LIBRARY_PATH=$(LIBRARY_PATH) gnatmake $(GMAKE_OPTS) -Pcuda_tests.gpr \
34                 -XARCH=$(ARCH)
35
36 tests: build_tests
37         @LD_LIBRARY_PATH=$(LIBRARY_PATH) $(OBJDIR)/test_runner
38
39 doc:
40         $(MAKE) -C doc
41
42 cov:
43         @rm -f $(COVDIR)/*.gcda
44         @LIBRARY_PATH=$(LIBRARY_PATH) gnatmake $(GMAKE_OPTS) -Pcuda_tests.gpr \
45                 -XBUILD="coverage"
46         @LD_LIBRARY_PATH=$(LIBRARY_PATH) $(COVDIR)/test_runner || true
47         @lcov -c -d $(COVDIR) -o $(COVDIR)/cov.info
48         @lcov -e $(COVDIR)/cov.info "$(PWD)/src/*.adb" -o $(COVDIR)/cov.info
49         @genhtml --no-branch-coverage $(COVDIR)/cov.info -o $(COVDIR)
50
51 perf: $(OBJDIR)/perf_c $(OBJDIR)/perf_c_drv
52         @LIBRARY_PATH=$(LIBRARY_PATH) gnatmake $(GMAKE_OPTS) -Pcuda_perf.gpr \
53                 -XARCH=$(ARCH)
54         @LD_LIBRARY_PATH=$(LIBRARY_PATH) $(OBJDIR)/perf_cudaada $(COUNT)
55         @LD_LIBRARY_PATH=$(LIBRARY_PATH) $(OBJDIR)/perf_c $(COUNT)
56         @LD_LIBRARY_PATH=$(LIBRARY_PATH) $(OBJDIR)/perf_c_drv $(COUNT)
57
58 $(OBJDIR)/perf_c: $(PERFDIR)/perf_c.cu
59         @mkdir -p $(OBJDIR)
60         LIBRARY_PATH=$(LIBRARY_PATH) $(CUDASDK)/bin/nvcc $< -o $@
61
62 $(OBJDIR)/perf_c_drv: $(PERFDIR)/perf_c_drv.c
63         @mkdir -p $(OBJDIR)
64         LIBRARY_PATH=$(LIBRARY_PATH) $(CC) $< -o $@ -I$(CUDASDK)/include -lcuda
65
66 clean:
67         @rm -rf cache
68         @rm -rf $(OBJDIR)
69         @rm -rf $(LIBDIR)
70         $(MAKE) -C doc clean
71
72 dist:
73         @echo "Creating release tarball $(TARBALL) ... "
74         @git archive --format=tar HEAD --prefix $(CUDA_ADA)/ | bzip2 > $(TARBALL)
75
76 .PHONY: all build_examples build_lib build_tests clean dist doc perf tests