-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathold.makefile
89 lines (70 loc) · 1.79 KB
/
old.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
CXX := g++
CXXFLAGS := -Wall -I . -g
# CXXGLAGS += -std=c++11 -stdlib=libstdc++
TARGET := flang
LIBS := jack
ifeq ($(CONFIG), yaml)
LIBS += yaml-cpp
endif
ifeq ($(CONFIG), xml)
LIBS += tinyxml2
endif
SRCDIR := src
OBJDIR := objs
TARGETDIR := build
SRCEXT := cpp
DEPEXT := d
OBJEXT := o
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
SOURCES := $(OBJECTS:%_config.$(SRCEXT)=)
ifeq ($(CONFIG), yaml)
A := $(shell echo $(SOURCES))
SOURCES += yaml_config.$(SRCEXT)
endif
OBJECTS := $(SOURCES:$(SRCDIR)/%.$(SRCEXT)=$(OBJDIR)/%.$(OBJEXT))
.PHONY: all
.PHONY: dirs
.PHONY: clean
.PHONY: cleaner
.PHONY: help
.PHONY: complete
all: $(TARGET)
@echo 'Done!'
@echo
@echo 'Built sources: '$(SOURCES)
@echo 'Built objects: '$(OBJECTS)
help:
@echo 'run make with no target to make all...'
@echo
@echo 'Make $(TARGET):'
@echo ' dirs: generate directory tree'
@echo ' clean: rm ./$(OBJDIR)/'
@echo ' cleaner: rm ./$(OBJDIR)/ and ./$(TARGETDIR)/'
@echo ' $(TARGET): built $(TARGET) (generates dir tree automatically)'
@echo ' complete: generate .clang_complete'
complete:
echo '$(CXXFLAGS) $(LIBS:%=-l%)' > .clang_complete
dirs:
mkdir -p $(TARGETDIR)
mkdir -p $(OBJDIR)
clean:
rm -rf $(OBJDIR)
cleaner: clean
rm -rf $(TARGETDIR)
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
# Link
$(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) -o $(TARGETDIR)/$(TARGET) $^ $(LIBS:%=-l%)
# Compile
$(OBJDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT) dirs
@echo 'Compiling obj "$@"'
$(CXX) $(CXXFLAGS) -c -o $@ $<
@echo 'Generating dep file: "$(OBJDIR)/$*.$(DEPEXT)"'
$(CXX) $(CXXFLAGS) -MM $< | \
tr -d '\\\n' | \
sed 's|.*:|$@:|' | \
awk -F: '{ \
print $$0; \
split($$2,a," "); \
for (i in a) print(a[i]":"); \
}' > $(OBJDIR)/$*.$(DEPEXT)