Update my email address
[clav.git] / Makefile
bloba4ba36f384119389b58d430f6ff226b5f8a661dd
1 .SUFFIXES:
2 .SUFFIXES: .o .c
4 CFLAGS ?=
5 LDFLAGS ?=
7 PKG_CONFIG ?= pkg-config
9 PCSTATIC ?=
10 ifneq (,$(findstring -static,$(LDFLAGS)))
11 PCSTATIC += --static
12 endif
14 PREFIX ?= /usr
15 BINDIR ?= $(PREFIX)/bin
16 SHAREDIR ?= $(PREFIX)/share
17 MANDIR ?= $(PREFIX)/share/man
19 CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200809L
21 # Debug
22 # CFLAGS += -fsanitize=address -g -O0 -pedantic -Wall -Wextra -Werror
23 # LDFLAGS += -fsanitize=address
25 # If you plan to use clav-mutation-find, it is highly recommended that you enable -O3
26 # CFLAGS += -O3 -Wall -Wextra -Werror
28 SDLPROG = clav-sdl
29 TEXTPROG = clav-cli
30 MUTFINDPROG = clav-mutation-find
31 BFZIIIPROG = clav-bfzIII
32 GRAPHISOPROG = clav-check-graph-isomorphism
34 default: all
36 .PHONY: all
37 all: $(SDLPROG) $(TEXTPROG) $(MUTFINDPROG) $(BFZIIIPROG) $(GRAPHISOPROG)
39 $(SDLPROG): clav.o quiver.o ui-sdl.o ui-sdl-font.o color-selection.o file-selection.o
40 $(CC) -o $@ $^ $(LDFLAGS) -lm $(shell $(PKG_CONFIG) $(PCSTATIC) --libs sdl2 SDL2_ttf)
42 $(TEXTPROG): clav.o quiver.o ui-cli.o
43 $(CC) -o $@ $^ $(LDFLAGS)
45 $(MUTFINDPROG): mutation-finder.o quiver.o
46 $(CC) -o $@ $^ $(LDFLAGS)
48 $(BFZIIIPROG): bfzIII.o quiver.o
49 $(CC) -o $@ $^ $(LDFLAGS)
51 $(GRAPHISOPROG): check-graph-iso.o quiver.o
52 $(CC) -o $@ $^ $(LDFLAGS)
54 clav.o: clav.c macros.h ui.h quiver.h
55 $(CC) $(CFLAGS) -c -o $@ $<
57 quiver.o: quiver.c macros.h ui.h quiver.h
58 $(CC) $(CFLAGS) -c -o $@ $<
60 ui-sdl.o: ui-sdl.c macros.h ui.h quiver.h color-selection.h file-selection.h ui-sdl-font.h
61 $(CC) $(CFLAGS) $(shell $(PKG_CONFIG) $(PCSTATIC) --cflags sdl2 SDL2_ttf) -c -o $@ $<
63 ui-sdl-font.o: ui-sdl-font.c
64 $(CC) $(CFLAGS) -c -o $@ $<
66 ui-cli.o: ui-cli.c macros.h quiver.h
67 $(CC) $(CFLAGS) -c -o $@ $<
69 file-selection.o: file-selection.c file-selection.h macros.h
70 $(CC) $(CFLAGS) -c -o $@ $<
72 color-selection.o: color-selection.c color-selection.h macros.h
73 $(CC) $(CFLAGS) -c -o $@ $<
75 mutation-finder.o: mutation-finder.c macros.h quiver.h
76 $(CC) $(CFLAGS) -c -o $@ $<
78 bfzIII.o: bfzIII.c macros.h quiver.h
79 $(CC) $(CFLAGS) -c -o $@ $<
81 check-graph-iso.o: check-graph-iso.c macros.h quiver.h
82 $(CC) $(CFLAGS) -c -o $@ $<
84 .PHONY: clean
85 clean:
86 rm -f *.o
87 rm -f *~
88 rm -f $(SDLPROG)
89 rm -f $(TEXTPROG)
90 rm -f $(MUTFINDPROG)
91 rm -f $(BFZIIIPROG)
92 rm -f $(GRAPHISOPROG)
94 .PHONY: install
95 install: all
96 mkdir -p $(DESTDIR)$(BINDIR)
97 cp -f $(SDLPROG) $(DESTDIR)$(BINDIR)/
98 cp -f $(TEXTPROG) $(DESTDIR)$(BINDIR)/
99 cp -f $(MUTFINDPROG) $(DESTDIR)$(BINDIR)/
100 cp -f $(BFZIIIPROG) $(DESTDIR)$(BINDIR)/
101 cp -f $(GRAPHISOPROG) $(DESTDIR)$(BINDIR)/
102 mkdir -p $(DESTDIR)$(SHAREDIR)/clav
103 cp -f data/*.txt $(DESTDIR)$(SHAREDIR)/clav/
104 mkdir -p $(DESTDIR)$(MANDIR)/man1
105 cp -f clav.1 $(DESTDIR)$(MANDIR)/man1/
106 cp -f clav-cli.1 $(DESTDIR)$(MANDIR)/man1/
107 cp -f clav-sdl.1 $(DESTDIR)$(MANDIR)/man1/
108 cp -f clav-mutation-find.1 $(DESTDIR)$(MANDIR)/man1/
110 .PHONY: uninstall
111 uninstall:
112 cd $(DESTDIR)$(BINDIR) && rm -f $(SDLPROG)
113 cd $(DESTDIR)$(BINDIR) && rm -f $(TEXTPROG)
114 cd $(DESTDIR)$(BINDIR) && rm -f $(MUTFINDPROG)
115 cd $(DESTDIR)$(BINDIR) && rm -f $(BFZIIIPROG)
116 cd $(DESTDIR)$(BINDIR) && rm -f $(GRAPHISOPROG)
117 cd $(DESTDIR)$(SHAREDIR) && rm -rf clav
118 cd $(DESTDIR)$(MANDIR)/man1 && rm -f clav.1 clav-mutation-find.1 clav-cli.1 clav-sdl.1