-
Notifications
You must be signed in to change notification settings - Fork 10
/
linux.mk
executable file
·62 lines (47 loc) · 1.76 KB
/
linux.mk
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
SHELL := /bin/bash
CC := gcc
CFLAGS := -Wall -Werror -std=c99 -pedantic -g -s -Os `pkg-config --cflags gtk+-3.0` -DOS_LINUX
LFLAGS := `pkg-config --libs gtk+-3.0` -lm -lz -s
OBJ := obj/linux/
BIN := bin/linux/
TARGET := $(BIN)ImageToMapX
SRCDIRS := src src/* src/*/* src/*/*/*
SOURCES := $(foreach DIR, $(SRCDIRS), $(wildcard $(DIR)/*.c))
OBJECTS = $(patsubst %.c, $(OBJ)%.o, $(SOURCES))
BEG = echo -e -n " \033[32m$(1)$(2)...\033[0m" ; echo -n > /tmp/.`whoami`-build-errors
END = if [[ -s /tmp/.`whoami`-build-errors ]] ; then \
echo -e -n "\r\033[1;33m$(1)$(2)\033[0m\n"; \
cat /tmp/.`whoami`-build-errors; \
else \
echo -e -n "\r \033[1;32m$(1)$(2)\033[0m\033[K\n"; \
fi
INFO = echo -e -n "\r \033[1;34m$(1)$(2)\033[0m\n"
ERRORFUNC = echo -e " \033[1;31m! Fatal error encountered.\033[0m"; \
cat /tmp/.`whoami`-build-errors; \
exit 1;
ERRORS = 2>>/tmp/.`whoami`-build-errors || { $(call ERRORFUNC) }
ERRORSS = >>/tmp/.`whoami`-build-errors || { $(call ERRORFUNC) }
BEGRM = echo -e -n " \033[31m$(1)$(2)...\033[0m" && echo -n > /tmp/.`whoami`-build-errors
ENDRM = echo -e -n "\r \033[1;31m$(1)$(2)\033[0m\033[K\n"
.PHONY: all clean init
all: init $(TARGET)
@$(call BEG, "CP", "resources")
@cp -r resources/* $(BIN)
@$(call END, "CP", "resources")
@$(call INFO, "--", "Building ImageToMap-X for Linux...Done!");
init:
@$(call INFO, "--", "Building ImageToMap-X for Linux...");
$(OBJ)%.o: %.c
@$(call BEG, "CC", "$<")
@mkdir -p $(dir $@)
@$(CC) -c $< -o $@ $(CFLAGS) $(ERRORS)
@$(call END, "CC", "$<")
$(TARGET): $(OBJECTS)
@$(call BEG, "LD", "$<")
@mkdir -p $(dir $@)
@$(CC) $(OBJECTS) -o $(TARGET) $(LFLAGS) $(ERRORS)
@$(call END, "LD", "$<")
clean:
@$(call BEGRM, "RM", "$(BIN) $(OBJ)")
@$(RM) -rf $(BIN) $(OBJ)
@$(call ENDRM, "RM", "$(BIN) $(OBJ)")