-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
194 lines (156 loc) · 4.54 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
BUILD := build
ifneq ($(BUILD),$(notdir $(CURDIR)))
TARGET ?= cielbox
SOURCES += applet lib lib/zlib lib/zlib/contrib lib/zopfli lib/libdeflate lib/miniz lib/popt .
INCLUDES +=
DATA += data
#--- set toolchain name
ifneq ($(CLANG),)
export CC := $(PREFIX)clang
#export CXX := $(PREFIX)clang++ -stdlib=libc++
export CXX := $(PREFIX)clang++
else ifneq ($(OPEN64),)
export CC := $(PREFIX)opencc
export CXX := $(PREFIX)openCC
else ifneq ($(ICC),)
export CC := $(PREFIX)icc
export CXX := $(PREFIX)icpc
else ifneq ($(ICX),)
export CC := $(PREFIX)icx
export CXX := $(PREFIX)icpx
else
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
endif
#export AS := $(PREFIX)as
#export AR := $(PREFIX)ar
#export OBJCOPY := $(PREFIX)objcopy
export STRIP := $(PREFIX)strip
#--- set path
### relative path from build
#LIBS +=
export LIBS
LIBDIRS :=
export LIBDIRS
export INCLUDE += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS += $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
#--- flags
#ARCH :=
CFLAGS := -Wall -Wno-parentheses \
-Wno-sign-compare -Wno-unused-parameter -Wno-unused-value \
-O2 -fomit-frame-pointer -ffast-math \
-DNO_VIZ -DHAVE_INTERNAL -D_LIBCPP_NO_EXCEPTIONS \
$(ARCH)
ifeq ($(WIN32),)
#enable Z7_ST in non-Win32
CFLAGS += -DZ7_ST
endif
ifneq ($(CRYPTOPP),)
SOURCES += lib/cryptopp
CFLAGS += -DCRYPTOPP=1
LIBS += -lcryptopp
endif
#-DNO_VIZ for zlib.
CFLAGS += $(INCLUDE)
CXXFLAGS := $(CFLAGS) -fno-exceptions
#lovely hack...
#bah -Wno-pointer-sign must be stripped for iPodLinux
#-std=c99 breaks fileno() on Linux...
CFLAGS += -std=gnu99
CFLAGS += -Wno-pointer-sign -Wno-unused-result
ASFLAGS := $(ARCH)
LDFLAGS = $(ARCH) $(LDF) -O2
#-Wl,-Map,$(notdir $*.map)
ifneq ($(USTL),)
#you need to give libustl path. It must be linked statically.
CXXFLAGS += -DUSTL
LIBS += -lsupc++
ifneq ($(WIN32),)
LDFLAGS += -static-libgcc
endif
else
CXXFLAGS += -fno-rtti
ifneq ($(WIN32),)
LDFLAGS += -static-libgcc -static-libstdc++
endif
endif
ifneq ($(NOZLIBNG),)
CFLAGS += -DNOZLIBNG
else
SOURCES += lib/zlib-ng lib/zlib-ng/arch/arm
endif
ifneq ($(ZLIBNG_X86),)
### some very old gcc does not have immintrin.h; need to add flag...
SOURCES += lib/zlib-ng/arch/x86
CFLAGS += -DX86_CPUID -DX86_QUICK_STRATEGY
endif
ifneq ($(NOIGZIP),)
CFLAGS += -DNOIGZIP
CXXFLAGS += -DNOIGZIP
else
LIBS += ../lib/isa-l/bin/isa-l.a
endif
export CFLAGS
export CXXFLAGS
export LDFLAGS
export BIN := $(CURDIR)/$(TARGET)$(SUFF)
export DEPSDIR := $(CURDIR)/$(BUILD)
#export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
# $(foreach dir,$(DATA),$(CURDIR)/$(dir))
export VPATH := $(CURDIR)
CFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.c))
CPPFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.cpp))
SFILES := $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.s))
#BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
ifeq ($(strip $(CPPFILES)),)
export LD := $(CC)
else
ifneq ($(USTL),)
#Oh dear: undefined reference to std::__throw_out_of_range_fmt
#No proper fix yet...
#export LD := $(CXX)
export LD := $(CC)
else
#gcc doesn't understand -static-libstdc++...
export LD := $(CXX)
endif
endif
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
.PHONY: $(BUILD) clean
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@[ "$(NOIGZIP)" != "" ] || make CC=$(PREFIX)gcc CFLAGS_="$(subst -flto,,$(CFLAGS))" CFLAGS_aarch64="-fno-stack-check -DHWCAP_SVE=4194304" -C lib/isa-l -f Makefile.unx lib programs/igzip
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile -j4
clean:
@#echo clean ...
@make -C lib/isa-l -f Makefile.unx clean
@rm -fr $(BUILD)
#---------------------------------------------------------------------------------
else
#%.a:
# @#echo $(notdir $@)
# @rm -f $@
# @$(AR) -rc $@ $^
lib/cryptopp/%.o: RTTI:=-frtti -fexceptions
%.o: %.cpp
@#echo $(notdir $<)
@[ -d $@ ] || mkdir -p $(dir $@)
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(RTTI) -c $< -o $@ $(ERROR_FILTER)
%.o: %.c
@#echo $(notdir $<)
@[ -d $@ ] || mkdir -p $(dir $@)
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -c $< -o $@ $(ERROR_FILTER)
%.o: %.s
@#echo $(notdir $<)
@[ -d $@ ] || mkdir -p $(dir $@)
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ $(ERROR_FILTER)
DEPENDS := $(OFILES:.o=.d)
$(BIN): $(OFILES)
@#echo linking $(notdir $@)
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
@if ! echo "$(LDFLAGS)" | grep -- -shared; then $(STRIP) $@; fi
-include $(DEPENDS)
endif