forked from Aikku93/ulc-codec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (77 loc) · 2.64 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
.phony: common
.phony: encodetool
.phony: decodetool
.phony: clean
#----------------------------#
# Directories
#----------------------------#
OBJDIR := build
INCDIR := include
COMMON_SRCDIR := fourier libulc
ENCODETOOL_SRCDIR := tools
DECODETOOL_SRCDIR := tools
#----------------------------#
# Cross-compilation, compile flags
#----------------------------#
# Alternatively, try "-march=native" for ARCHFLAGS
ARCHCROSS :=
ARCHFLAGS := -msse -msse2 -mavx -mavx2 -mfma
CCFLAGS := $(ARCHFLAGS) -fno-math-errno -ffast-math -O2 -Wall -Wextra $(foreach dir, $(INCDIR), -I$(dir))
LDFLAGS := -static -s -lm
#----------------------------#
# Tools
#----------------------------#
CC := $(ARCHCROSS)gcc
LD := $(ARCHCROSS)gcc
#----------------------------#
# Files
#----------------------------#
COMMON_SRC := $(foreach dir, $(COMMON_SRCDIR), $(wildcard $(dir)/*.c))
ENCODETOOL_SRC := $(filter-out $(ENCODETOOL_SRCDIR)/ulcdecodetool.c, $(wildcard $(ENCODETOOL_SRCDIR)/*.c))
DECODETOOL_SRC := $(filter-out $(DECODETOOL_SRCDIR)/ulcencodetool.c, $(wildcard $(DECODETOOL_SRCDIR)/*.c))
COMMON_OBJ := $(addprefix $(OBJDIR)/, $(notdir $(COMMON_SRC:.c=.o)))
ENCODETOOL_OBJ := $(addprefix $(OBJDIR)/, $(notdir $(ENCODETOOL_SRC:.c=.o)))
DECODETOOL_OBJ := $(addprefix $(OBJDIR)/, $(notdir $(DECODETOOL_SRC:.c=.o)))
ENCODETOOL_EXE := ulcencodetool
DECODETOOL_EXE := ulcdecodetool
DFILES := $(wildcard $(OBJDIR)/*.d)
VPATH := $(COMMON_SRCDIR) $(ENCODETOOL_SRCDIR) $(DECODETOOL_SRCDIR)
#----------------------------#
# General rules
#----------------------------#
$(OBJDIR)/%.o : %.c
@echo $(notdir $<)
@$(CC) $(CCFLAGS) -c -o $@ $< -MMD -MP -MF $(OBJDIR)/$*.d
#----------------------------#
# make all
#----------------------------#
all : common encodetool decodetool
$(OBJDIR) :; mkdir -p $@
#----------------------------#
# make common
#----------------------------#
common : $(COMMON_OBJ)
$(COMMON_OBJ) : $(COMMON_SRC) | $(OBJDIR)
#----------------------------#
# make encodetool
#----------------------------#
encodetool : $(ENCODETOOL_EXE)
$(ENCODETOOL_OBJ) : $(ENCODETOOL_SRC) | $(OBJDIR)
$(ENCODETOOL_EXE) : $(COMMON_OBJ) $(ENCODETOOL_OBJ)
$(LD) $^ $(LDFLAGS) -o $@
#----------------------------#
# make decodetool
#----------------------------#
decodetool : $(DECODETOOL_EXE)
$(DECODETOOL_OBJ) : $(DECODETOOL_SRC) | $(OBJDIR)
$(DECODETOOL_EXE) : $(COMMON_OBJ) $(DECODETOOL_OBJ)
$(LD) $^ $(LDFLAGS) -o $@
#----------------------------#
# make clean
#----------------------------#
clean :; rm -rf $(OBJDIR) $(ENCODETOOL_EXE) $(DECODETOOL_EXE)
#----------------------------#
# Dependencies
#----------------------------#
include $(wildcard $(DFILES))
#----------------------------#