-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
61 lines (47 loc) · 1.42 KB
/
Makefile
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
sources := gpx2tiles.c gpx.c
odir := O
target = gpx2tiles
ofiles = $(patsubst %.c,$(odir)/%.o,$(sources))
LIBXML_CFLAGS := $(shell pkg-config --cflags libxml-2.0)
LIBXML_LIBS := $(shell pkg-config --libs libxml-2.0)
LIBGD_CFLAGS := $(shell pkg-config --cflags gdlib)
LIBGD_LIBS := $(shell pkg-config --libs gdlib)
PREFIX ?= /usr
CC := gcc
# CFLAGS :=
# CPPFLAGS :=
# LDFLAGS :=
# LDLIBS :=
PKG_CFLAGS = $(LIBGD_CFLAGS) $(LIBXML_CFLAGS)
PKG_LIBS = $(LIBGD_LIBS) $(LIBXML_LIBS)
_cflags := -Wall -ggdb -O3
_cppflags := -D_GNU_SOURCE
_ldflags := -Wall -ggdb -O3
_ldlibs := -lm -lpthread
build: $(target)
$(target): link_libs := $(LOADLIBES) $(PKG_LIBS) $(_ldlibs) $(LDLIBS)
$(target): link_flags := $(_ldflags) $(LDFLAGS) $(TARGET_ARCH)
$(target): $(ofiles)
$(CC) $(link_flags) $^ $(link_libs) $(OUTPUT_OPTION)
$(odir)/%.o: %.c
@mkdir -p '$(odir)'
$(CC) -c $(_cflags) $(_cppflags) $(PKG_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) $< $(OUTPUT_OPTION)
rebuild: clean
$(MAKE) build
depclean:
rm -f $(odir)/*.d
clean:
rm -f $(odir)/*.o $(target)
distclean: clean depclean
install:
install -d $(DESTDIR)$(PREFIX)/bin
install -m 0755 $(target) $(DESTDIR)$(PREFIX)/bin
tags:
ctags $(srcs) *.h
$(odir)/%.d: %.c
@mkdir -p '$(odir)'
$(CC) -MM -o $@ $< $(_cppflags) $(CPPFLAGS)
.PHONY: tags build rebuild depclean clean distclean install
ifneq (clean,$(findstring clean,$(MAKECMDGOALS)))
-include $(patsubst %.c,$(odir)/%.d,$(sources))
endif