forked from luhsra/multiverse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.mk
37 lines (28 loc) · 895 Bytes
/
common.mk
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
DEPDIR = .d
$(shell mkdir -p $(DEPDIR) >/dev/null)
POSTCOMPILE = mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
CFLAGS+=-MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
CXXFLAGS+=-MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
OBJECTS = $(patsubst %,%.o,$(basename $(SOURCES)))
ALLPRODUCTS += $(OBJECTS)
define BINARY_template
$(1): $$(EXTRA_DEPS) $(1).o $$($(1)_OBJS)
$$(CC) $$(LDFLAGS) -o $$@ $(1).o $$($(1)_OBJS) $$(LDLIBS)
$(1).S: $$(EXTRA_DEPS) $(1).c
$$(CC) -S -o $$@ $$(CFLAGS) $$<
ALLPRODUCTS += $(1).o $$($(1)_OBJS) $(1).S $(1) $(DEPDIR)/.d/$(1).d
endef
%.o : %.c
%.o : %.c $(DEPDIR)/%.d $(EXTRA_DEPS)
$(CC) -o $@ -c $< $(CFLAGS)
@$(POSTCOMPILE)
%.o : %.cc
%.o : %.cc $(DEPDIR)/%.d $(EXTRA_DEPS)
$(CXX) -o $@ -c $< $(CXXFLAGS)
@$(POSTCOMPILE)
$(DEPDIR)/%.d: ;
.PRECIOUS: $(DEPDIR)/%.d
clean: defaultclean
defaultclean:
rm -f $(ALLPRODUCTS) core
-include $(patsubst %,$(DEPDIR)/%.d,$(basename $(SOURCES)))