-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (51 loc) · 3.15 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
# The MIT License (MIT)
# Copyright (c) 2017 nabijaczleweli
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
include configMakefile
LDAR := $(PIC) $(foreach l,zstd whereami-cpp inih,-L$(BLDDIR)$(l)) $(foreach dll,zstd whereami++ inih,-l$(dll))
INCAR := $(foreach l,$(foreach l,whereami-cpp,$(l)/include) totalcmd-wcx-api jsonpp inih,-isystemext/$(l)) $(foreach l,zstd,-isystem$(BLDDIR)$(l)/include)
VERAR := $(foreach l,TOTALCMD_ZSTD WHEREAMI_CPP JSONPP INIH,-D$(l)_VERSION='$($(l)_VERSION)')
SOURCES := $(sort $(wildcard src/*.cpp src/**/*.cpp src/**/**/*.cpp src/**/**/**/*.cpp))
.PHONY : all clean zstd whereami-cpp inih wcx
all : zstd whereami-cpp inih wcx
clean :
rm -rf $(OUTDIR)
wcx : $(OUTDIR)totalcmd-zstd$(WCX)
zstd : $(BLDDIR)zstd/libzstd$(ARCH) $(BLDDIR)zstd/include/zstd/zstd.h
whereami-cpp : $(BLDDIR)whereami-cpp/libwhereami++$(ARCH)
inih : $(BLDDIR)inih/libinih$(ARCH)
$(OUTDIR)totalcmd-zstd$(WCX) : $(subst $(SRCDIR),$(OBJDIR),$(subst .cpp,$(OBJ),$(SOURCES)))
$(CXX) $(CXXAR) -shared -o$@ $^ $(PIC) $(LDAR)
$(BLDDIR)zstd/libzstd$(ARCH) : $(subst ext/zstd/lib,$(BLDDIR)zstd/obj,$(subst .c,$(OBJ),$(wildcard ext/zstd/lib/common/*.c ext/zstd/lib/compress/*.c ext/zstd/lib/decompress/*.c)))
@mkdir -p $(dir $@)
$(AR) crs $@ $^
$(BLDDIR)zstd/include/zstd/zstd.h : $(wildcard ext/zstd/lib/*.h ext/zstd/lib/common/*.h ext/zstd/lib/compress/*.h ext/zstd/lib/decompress/*.h)
@mkdir -p $(foreach incfile,$(subst ext/zstd/lib,$(BLDDIR)zstd/include/zstd,$^),$(abspath $(dir $(incfile))))
$(foreach incfile,$^,cp $(incfile) $(subst ext/zstd/lib,$(BLDDIR)zstd/include/zstd,$(incfile));)
$(BLDDIR)whereami-cpp/libwhereami++$(ARCH) : ext/whereami-cpp/Makefile
$(MAKE) -C$(dir $^) BUILD=$(abspath $(dir $@)) stlib
$(BLDDIR)inih/libinih$(ARCH) : $(BLDDIR)inih/obj/ini$(OBJ)
@mkdir -p $(dir $@)
$(AR) crs $@ $^
$(OBJDIR)%$(OBJ) : $(SRCDIR)%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXAR) $(INCAR) $(VERAR) -DZSTD_STATIC_LINKING_ONLY -c -o$@ $^
$(BLDDIR)zstd/obj/%$(OBJ) : ext/zstd/lib/%.c
@mkdir -p $(dir $@)
$(CC) $(CCAR) -Iext/zstd/lib -Iext/zstd/lib/common -c -o$@ $^
$(BLDDIR)inih/obj/%$(OBJ) : ext/inih/%.c
@mkdir -p $(dir $@)
$(CC) $(CCAR) -DINI_USE_STACK=0 -DINI_MAX_LINE=2048 -c -o$@ $^