-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (51 loc) · 1.82 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
62
63
64
APP_SERVER_NAME = Server
APP_CLIENT_NAME = Client
GTK_FLAGS = `pkg-config --cflags --libs gtk+-3.0`
FLAGS = -lpthread
SERVER_C = ./src/server.c
CLIENT_C = ./src/application.c
USER_INTERFACE_SRC = ./src/user_interface.c
USER_INTERFACE_LIB = ./include/user_interface.h
USER_INTERFACE_OBJ = ./build/user_interface.o
CLIENT_IGNORE = $(SERVER_C) $(CLIENT_C)
CLIENT_DEPS = $(subst .c,.o, $(subst ./src/,./build/, $(filter-out $(CLIENT_IGNORE), $(wildcard ./src/*.c))))
SERVER_IGNORE = $(SERVER_C) $(CLIENT_C) $(USER_INTERFACE_SRC) ./src/client.c
SERVER_DEPS = $(subst .c,.o, $(subst ./src/,./build/, $(filter-out $(SERVER_IGNORE), $(wildcard ./src/*.c))))
GREEN =
NC =
ifeq ($(OS), Windows_NT)
APP_EXTENSION = .exe
REM_CMD = del
ECHO = ECHO
else
APP_EXTENSION =
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
REM_CMD = rm
ECHO = echo -e
GREEN=\033[0;32m
NC=\033[0m
endif
endif
all: build $(APP_CLIENT_NAME) $(APP_SERVER_NAME)
build:
@ mkdir build
@ $(ECHO) " [$(GREEN) OK $(NC)] Criado diretório para objetos"
$(APP_CLIENT_NAME): $(CLIENT_DEPS)
@ gcc $(CLIENT_C) $^ $(GTK_FLAGS) -o $@ -g
@ $(ECHO) " [$(GREEN) OK $(NC)] Executável construido: $@"
$(APP_SERVER_NAME): $(SERVER_DEPS)
@ gcc $(SERVER_C) $^ $(FLAGS) -o $@ -g
@ $(ECHO) " [$(GREEN) OK $(NC)] Executável construido: $@"
$(USER_INTERFACE_OBJ): $(USER_INTERFACE_SRC) $(USER_INTERFACE_LIB)
@ gcc -c $(GTK_FLAGS) $< -o $@
@ $(ECHO) " [$(GREEN) OK $(NC)] Compilado $< em $@"
build/%.o: ./src/%.c ./include/%.h
@ gcc -c $< -o $@
@ $(ECHO) " [$(GREEN) OK $(NC)] Compilado $< em $@"
clean:
@ $(ECHO) " Limpando workspace..."
@ $(REM_CMD) -f $(APP_CLIENT_NAME)$(APP_EXTENSION)
@ $(REM_CMD) -f $(APP_SERVER_NAME)$(APP_EXTENSION)
@ $(REM_CMD) -f build/*.o
@ $(ECHO) " [$(GREEN) OK $(NC)] Workspace limpo"