aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 1713bffac9b8f46f6c71d79024968cf53f7c5931 (plain) (blame)
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
SOURCE_DIR  = src/
INSTALL_DIR ?= /usr/local/

BINARY  = messenger-cli
SOURCES = messenger_cli.c\
          application.c\
          chat.c\
          util.c\
          ui/account_create_dialog.c\
          ui/accounts.c\
          ui/chat_open_dialog.c\
          ui/chats.c\
          ui/lobby_enter_dialog.c\
          ui/members.c\
          ui/messages.c
HEADERS = application.h\
          chat.h\
          util.h\
          ui/account_create_dialog.h\
          ui/accounts.h\
          ui/chat.h\
          ui/chat_open_dialog.h\
          ui/chats.h\
          ui/lobby_enter_dialog.h\
          ui/members.h\
          ui/messages.h\
          ui/text_input.h

LIBRARIES = gnunetchat gnunetutil ncurses

GNU_CC ?= gcc
GNU_LD ?= gcc
GNU_RM ?= rm

CFLAGS  += -pedantic -Wall -Wextra -ggdb3 -Wno-overlength-strings
LDFLAGS += 

DEBUGFLAGS   = -O0 -D _DEBUG
RELEASEFLAGS = -O2 -D NDEBUG

SOURCE_FILES  = $(addprefix $(SOURCE_DIR), $(SOURCES))
OBJECT_FILES  = $(SOURCE_FILES:%.c=%.o)
HEADER_FILES  = $(addprefix $(SOURCE_DIR), $(HEADERS))
LIBRARY_FLAGS = $(addprefix -l, $(LIBRARIES))

all: $(BINARY)

debug: CFLAGS += $(DEBUGFLAGS)
debug: $(BINARY)

release: CFLAGS += $(RELEASEFLAGS)
release: $(BINARY)

%.o: %.c
	$(GNU_CC) $(CFLAGS) -c $< -o $@ $(LIBRARY_FLAGS)

$(BINARY): $(OBJECT_FILES)
	$(GNU_LD) $(LDFLAGS) $^ -o $@ $(LIBRARY_FLAGS)

.PHONY: install

install:
	install -m 755 $(BINARY) $(addprefix $(INSTALL_DIR), bin/)

.PHONY: uninstall

uninstall:
	$(GNU_RM) -f $(addsuffix $(BINARY), $(addprefix $(INSTALL_DIR), bin/))

.PHONY: clean

clean:
	$(GNU_RM) -f $(BINARY)
	$(GNU_RM) -f $(OBJECT_FILES)