/
Makefile.old
82 lines (64 loc) · 2.31 KB
/
Makefile.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
VERSION := $(shell cat version)
CC ?= gcc
BUILDDIR ?= build
PREFIX ?= /usr/local
ifneq ($(shell uname -s),Darwin)
LDFLAGS += -Wl,--as-needed
endif
PACKAGES := gtk+-3.0 portaudio-2.0 fftw3f
CFLAGS += -Wall -ffast-math -DVERSION='"$(VERSION)"' `pkg-config --cflags $(PACKAGES)`
LDFLAGS += -lm -lpthread `pkg-config --libs $(PACKAGES)`
SRCDIR := src
CFILES := $(wildcard $(SRCDIR)/*.c)
HFILES := $(wildcard $(SRCDIR)/*.h)
ifeq ($(OS),Windows_NT)
LDFLAGS += -mwindows
DEBUG_LDFLAGS := -mconsole
EXT := .exe
RESFILE := $(BUILDDIR)/tg-timer.res
else
DEBUG_FLAGS :=
EXT :=
RESFILE :=
endif
all: $(BUILDDIR)/tg$(EXT)
.PHONY: all
debug: $(BUILDDIR)/tg-dbg$(EXT)
.PHONY: debug
profile: $(BUILDDIR)/tg-prf$(EXT)
.PHONY: profile
test: $(BUILDDIR)/tg-dbg$(EXT)
$(BUILDDIR)/tg-dbg test
.PHONY: test
valgrind: $(BUILDDIR)/tg-vlg$(EXT)
valgrind --leak-check=full -v --num-callers=99 --suppressions=.valgrind.supp $(BUILDDIR)/tg-vlg$(EXT)
.PHONY: debug
$(BUILDDIR)/tg-timer.res: icons/tg-timer.rc icons/tg-timer.ico
windres icons/tg-timer.rc -O coff -o $(BUILDDIR)/tg-timer.res
define TARGET
$(BUILDDIR)/$(1)_%.o: $(SRCDIR)/%.c $(HFILES)
$(CC) -c $(CFLAGS) -DPROGRAM_NAME='"$(1)"' $(2) $$< -o $$@
$(BUILDDIR)/$(1)$(EXT): $(patsubst $(SRCDIR)/%.c,$(BUILDDIR)/$(1)_%.o,$(CFILES)) $(RESFILE)
$(CC) -o $(BUILDDIR)/$(1)$(EXT) $$^ $(LDFLAGS) $(3)
ifeq ($(4),strip)
strip $(BUILDDIR)/$(1)$(EXT)
endif
endef
$(eval $(call TARGET,tg,-O3,,strip))
$(eval $(call TARGET,tg-dbg,-O3 -ggdb -DDEBUG,$(DEBUG_LDFLAGS),))
$(eval $(call TARGET,tg-prf,-O3 -pg,,))
$(eval $(call TARGET,tg-vlg,-O1 -g,,))
ICONSIZES := $(foreach SIZE, $(shell cat icons/sizes), $(SIZE)x$(SIZE))
$(ICONSIZES): %: icons/%/tg-timer.png icons/%/tg-document.png
install -D -m 0644 icons/$@/tg-timer.png $(PREFIX)/share/icons/hicolor/$@/apps/tg-timer.png
install -D -m 0644 icons/$@/tg-document.png $(PREFIX)/share/icons/hicolor/$@/mimetypes/application-x-tg-timer-data.png
.PHONY: $(ICONSIZES)
install: all $(ICONSIZES)
install -D -m 0755 $(BUILDDIR)/tg$(EXT) $(PREFIX)/bin/tg-timer$(EXT)
install -D -m 0644 icons/tg-timer.desktop $(PREFIX)/share/applications/tg-timer.desktop
install -D -m 0644 icons/tg-timer.xml $(PREFIX)/share/mime/packages/tg-timer.xml
install -D -m 0644 docs/tg-timer.1.gz $(PREFIX)/share/man/man1/tg-timer.1.gz
.PHONY: install
clean:
rm -rf $(BUILDDIR)/*
.PHONY: clean