-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRules.make
69 lines (54 loc) · 1.54 KB
/
Rules.make
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
INCLUDE := -nostdinc -I$(TOPDIR)
CPP := cpp
CPPFLAGS := -M $(INCLUDE)
LD := ld
ifndef FULLLINK
LDFLAGS := -nostdlib -r
endif
CXXFLAGS := -c $(INCLUDE) -Wall -Wnon-virtual-dtor -Wno-parentheses \
-Wno-pmf-conversions -Wno-pointer-arith -Wno-unused-function \
-Wundef -fno-rtti -Wno-invalid-offsetof \
-fno-exceptions -fcheck-new -nostdlib -fno-builtin
ifeq ($(DEBUG),1)
CXXFLAGS := $(CXXFLAGS) -g -O
else
CXXFLAGS := $(CXXFLAGS) -g -fomit-frame-pointer -O
endif
AS := $(CXX) -c
ASFLAGS := $(INCLUDE) -D__ASSEMBLY__
PWD := $(shell pwd)
TARGET := $(PWD)/$(shell basename $(PWD)).target
SRCS := $(wildcard *.S *.cc)
OBJS := $(subst .S,.o,$(subst .cc,.o,$(SRCS)))
PWD := $(shell pwd)
TARGET := $(PWD)/$(shell basename $(PWD)).target
SRCS := $(wildcard *.S *.cc)
OBJS := $(patsubst %.cc,%.o,$(patsubst %.S,%.o,$(SRCS)))
SUBTARGETS := $(foreach dir,$(SUBDIRS),$(dir)/$(dir).target)
.PHONY: $(SUBDIRS) dep clean touch
$(TARGET): $(OBJS) $(SUBDIRS)
$(LD) $(LDFLAGS) $(LDFLAGS2) -o $@ $(OBJS) $(SUBTARGETS)
$(SUBDIRS):
make -C $@
%.o: %.cc
$(CXX) $(CXXFLAGS) $(CXXFLAGS2) -o $@ $<
%.o: %.S
$(AS) $(ASFLAGS) $(ASFLAGS2) -o $@ $<
dep:
@set -e
@rm -f Depend
@for i in $(SRCS); do $(CPP) $(CPPFLAGS) $$i >> Depend; done
@for i in $(SUBDIRS); do make -C $$i dep; done
clean:
@rm -f Depend *.o *.target
@for i in $(SUBDIRS); do make -C $$i clean ; done
ifdef FULLLINK
@rm -f Image
@make -C boot clean
endif
touch:
@find . -exec touch {} \;
@for i in $(SUBDIRS); do make -C $$i touch; done
ifeq (Depend,$(wildcard Depend))
include Depend
endif