High-level changes:
[xuni.git] / Makefile
blob89010b725c3f8a077f252964536874cac01f42f0
1 # Makefile for xuni, Linux version
3 TARGET = ./xuni
4 GDB = gdb
6 SRC = src
7 SRC_TARGETS = all depend clean wc
9 DOC = doc
10 DIST = dist
12 SUBDIRS = $(DOC) $(DIST)
14 # Default target: all
15 .PHONY: all
16 all:
18 # Targets relating to executables
19 .PHONY: run runa debug profile viewprofile
20 run: all
21 $(TARGET)
22 runa: all
23 $(TARGET) $(ARGS)
24 debug: all
25 $(GDB) $(TARGET)
26 profile:
27 $(MAKE) -C $(SRC) clean all \
28 '$(shell grep -E "CFLAGS\s?=" $(SRC)/Makefile) -pg'
29 $(TARGET)
30 tempfile --directory . --prefix prof- --suffix .out > profile.name
31 gprof $(TARGET) > $(shell cat profile.name)
32 cp $(TARGET) $(TARGET)_profile
33 $(MAKE) -C $(SRC) clean
34 cp $(TARGET)_profile $(TARGET)
35 cat profile.name
36 viewprofile:
37 # kprof is started in a new terminal due to its excessive output
38 gnome-terminal -x kprof -f $(shell cat profile.name)
40 # Targets from and relating to src/
41 .PHONY: $(SRC)
42 $(SRC_TARGETS):
43 $(MAKE) -C $(SRC) $@
45 # Targets from and relating to other subdirectories
46 .PHONY: $(SUBDIRS)
47 $(SUBDIRS):
48 $(MAKE) -C $@
50 # Linux-only targets
51 .PHONY: memcheck permissions
52 memcheck: $(TARGET)
53 valgrind --leak-check=full --show-reachable=yes -v $(TARGET) 2>&1\
54 | tee valgrind.output | less
56 dummy:
57 # permissions
58 #for file in $(shell find); do \
59 # if [ -f "$$file" ]; then \
60 # if [ -n "$$(file $$file | grep executable)" ]; then \
61 # echo "chmod 755 $$file"; \
62 # else \
63 # echo "chmod 644 $$file"; \
64 # fi; \
65 # elif [ -d "$$file" ]; then \
66 # echo "chmod 755 $$file"; \
67 # else \
68 # echo "Ignoring $$file"; \
69 # fi; \
70 #done
71 permissions:
72 chmod 644 $(shell find -type f)
73 chmod 755 $(shell find -type d) $(TARGET) $(TARGET).exe