-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGNUmakefile
44 lines (40 loc) · 1.51 KB
/
GNUmakefile
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
this_makefile_dir := $(dir $(lastword $(MAKEFILE_LIST)))
mkfiles := $(wildcard $(this_makefile_dir)*/*/GNUmakefile)
VPATH := $(patsubst $(this_makefile_dir)%,%,$(sort $(dir $(mkfiles))))
# https://blog.melski.net/2010/11/30/makefile-hacks-print-the-value-of-any-var
# '%' is a metacharacter in Windows batch files (which GNU Make uses when
# launching processes under cmd.exe), so we escape it and later correct it.
SRCS := $(sort $(foreach \
mkfile, \
$(mkfiles), \
$(shell \
echo 'print-%%:;@echo $$*=$$($$*)' \
| tr -d "'" \
| tr -s "%" \
| $(MAKE) -C $(dir $(mkfile)) -f - -f $(notdir $(mkfile)) print-SRCS \
| grep SRCS= \
| cut -d= -f2- \
) \
))
BOOST_LIBS = system
LIBS = cryptopp hunspell-1.7 ssl crypto
LIBS += $(if $(IS_WINDOWS_PLATFORM),crypt32 ws2_32)
# The implicit rule for linking is used only if the target name is the same as
# that of any constituent .o file. We abide by this here and later create a hard
# link to our final desired name.
TEMP_TARGET := $(notdir $(basename $(firstword $(filter test_%.cpp,$(SRCS)))))
$(TEMP_TARGET) : $(SRCS:.cpp=.o)
include $(this_makefile_dir)common_settings.mk
# The "clean" recipe in common_settings.mk relies on the eventual value of
# .DEFAULT_GOAL, so we avoid overwriting it if the user ran the "clean" target.
ifeq "" "$(filter clean,$(MAKECMDGOALS))"
test : $(.DEFAULT_GOAL)
$(file >> .gitignore,$@)
rm -f $@
ln -f $(TEMP_TARGET) $@
.DEFAULT_GOAL = test
else
.PHONY clean : clean-test
clean-test :
rm -f test
endif