Skip to content

Commit d169536

Browse files
committedDec 31, 2014
first commited
1 parent cb2efe4 commit d169536

File tree

1,140 files changed

+311768
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,140 files changed

+311768
-0
lines changed
 

‎Makefile

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# copyright (c) 2010 Espressif System
2+
#
3+
ifndef PDIR
4+
5+
endif
6+
7+
AR = xtensa-lx106-elf-ar
8+
CC = xtensa-lx106-elf-gcc
9+
NM = xtensa-lx106-elf-nm
10+
CPP = xtensa-lx106-elf-cpp
11+
OBJCOPY = xtensa-lx106-elf-objcopy
12+
#MAKE = xt-make
13+
14+
CSRCS ?= $(wildcard *.c)
15+
ASRCs ?= $(wildcard *.s)
16+
ASRCS ?= $(wildcard *.S)
17+
SUBDIRS ?= $(patsubst %/,%,$(dir $(wildcard */Makefile)))
18+
19+
20+
ODIR := .output
21+
OBJODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/obj
22+
23+
OBJS := $(CSRCS:%.c=$(OBJODIR)/%.o) \
24+
$(ASRCs:%.s=$(OBJODIR)/%.o) \
25+
$(ASRCS:%.S=$(OBJODIR)/%.o)
26+
27+
DEPS := $(CSRCS:%.c=$(OBJODIR)/%.d) \
28+
$(ASRCs:%.s=$(OBJODIR)/%.d) \
29+
$(ASRCS:%.S=$(OBJODIR)/%.d)
30+
31+
LIBODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/lib
32+
OLIBS := $(GEN_LIBS:%=$(LIBODIR)/%)
33+
34+
IMAGEODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/image
35+
OIMAGES := $(GEN_IMAGES:%=$(IMAGEODIR)/%)
36+
37+
BINODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/bin
38+
OBINS := $(GEN_BINS:%=$(BINODIR)/%)
39+
40+
CCFLAGS += \
41+
-g \
42+
-O2 \
43+
-Wpointer-arith \
44+
-Wundef \
45+
-Werror \
46+
-Wl,-EL \
47+
-fno-inline-functions \
48+
-nostdlib \
49+
-mlongcalls \
50+
-mtext-section-literals \
51+
-I /opt/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/
52+
# -Wall
53+
54+
CFLAGS = $(CCFLAGS) $(DEFINES) $(EXTRA_CCFLAGS) $(INCLUDES)
55+
DFLAGS = $(CCFLAGS) $(DDEFINES) $(EXTRA_CCFLAGS) $(INCLUDES)
56+
57+
58+
#############################################################
59+
# Functions
60+
#
61+
62+
define ShortcutRule
63+
$(1): .subdirs $(2)/$(1)
64+
endef
65+
66+
define MakeLibrary
67+
DEP_LIBS_$(1) = $$(foreach lib,$$(filter %.a,$$(COMPONENTS_$(1))),$$(dir $$(lib))$$(LIBODIR)/$$(notdir $$(lib)))
68+
DEP_OBJS_$(1) = $$(foreach obj,$$(filter %.o,$$(COMPONENTS_$(1))),$$(dir $$(obj))$$(OBJODIR)/$$(notdir $$(obj)))
69+
$$(LIBODIR)/$(1).a: $$(OBJS) $$(DEP_OBJS_$(1)) $$(DEP_LIBS_$(1)) $$(DEPENDS_$(1))
70+
@mkdir -p $$(LIBODIR)
71+
$$(if $$(filter %.a,$$?),mkdir -p $$(EXTRACT_DIR)_$(1))
72+
$$(if $$(filter %.a,$$?),cd $$(EXTRACT_DIR)_$(1); $$(foreach lib,$$(filter %.a,$$?),$$(AR) xo $$(UP_EXTRACT_DIR)/$$(lib);))
73+
$$(AR) ru $$@ $$(filter %.o,$$?) $$(if $$(filter %.a,$$?),$$(EXTRACT_DIR)_$(1)/*.o)
74+
$$(if $$(filter %.a,$$?),$$(RM) -r $$(EXTRACT_DIR)_$(1))
75+
endef
76+
77+
define MakeImage
78+
DEP_LIBS_$(1) = $$(foreach lib,$$(filter %.a,$$(COMPONENTS_$(1))),$$(dir $$(lib))$$(LIBODIR)/$$(notdir $$(lib)))
79+
DEP_OBJS_$(1) = $$(foreach obj,$$(filter %.o,$$(COMPONENTS_$(1))),$$(dir $$(obj))$$(OBJODIR)/$$(notdir $$(obj)))
80+
$$(IMAGEODIR)/$(1).out: $$(OBJS) $$(DEP_OBJS_$(1)) $$(DEP_LIBS_$(1)) $$(DEPENDS_$(1))
81+
@mkdir -p $$(IMAGEODIR)
82+
$$(CC) $$(LDFLAGS) $$(if $$(LINKFLAGS_$(1)),$$(LINKFLAGS_$(1)),$$(LINKFLAGS_DEFAULT) $$(OBJS) $$(DEP_OBJS_$(1)) $$(DEP_LIBS_$(1))) -o $$@
83+
endef
84+
85+
$(BINODIR)/%.bin: $(IMAGEODIR)/%.out
86+
@mkdir -p $(BINODIR)
87+
$(OBJCOPY) -O binary $< $@
88+
89+
#############################################################
90+
# Rules base
91+
# Should be done in top-level makefile only
92+
#
93+
94+
all: .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
95+
96+
clean:
97+
$(foreach d, $(SUBDIRS), $(MAKE) -C $(d) clean;)
98+
$(RM) -r $(ODIR)/$(TARGET)/$(FLAVOR)
99+
100+
clobber: $(SPECIAL_CLOBBER)
101+
$(foreach d, $(SUBDIRS), $(MAKE) -C $(d) clobber;)
102+
$(RM) -r $(ODIR)
103+
104+
.subdirs:
105+
@set -e; $(foreach d, $(SUBDIRS), $(MAKE) -C $(d);)
106+
107+
#.subdirs:
108+
# $(foreach d, $(SUBDIRS), $(MAKE) -C $(d))
109+
110+
ifneq ($(MAKECMDGOALS),clean)
111+
ifneq ($(MAKECMDGOALS),clobber)
112+
ifdef DEPS
113+
sinclude $(DEPS)
114+
endif
115+
endif
116+
endif
117+
118+
$(OBJODIR)/%.o: %.c
119+
@mkdir -p $(OBJODIR);
120+
$(CC) $(if $(findstring $<,$(DSRCS)),$(DFLAGS),$(CFLAGS)) $(COPTS_$(*F)) -o $@ -c $<
121+
122+
$(OBJODIR)/%.d: %.c
123+
@mkdir -p $(OBJODIR);
124+
@echo DEPEND: $(CC) -M $(CFLAGS) $<
125+
@set -e; rm -f $@; \
126+
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
127+
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
128+
rm -f $@.$$$$
129+
130+
$(OBJODIR)/%.o: %.s
131+
@mkdir -p $(OBJODIR);
132+
$(CC) $(CFLAGS) -o $@ -c $<
133+
134+
$(OBJODIR)/%.d: %.s
135+
@mkdir -p $(OBJODIR); \
136+
set -e; rm -f $@; \
137+
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
138+
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
139+
rm -f $@.$$$$
140+
141+
$(OBJODIR)/%.o: %.S
142+
@mkdir -p $(OBJODIR);
143+
$(CC) $(CFLAGS) -D__ASSEMBLER__ -o $@ -c $<
144+
145+
$(OBJODIR)/%.d: %.S
146+
@mkdir -p $(OBJODIR); \
147+
set -e; rm -f $@; \
148+
$(CC) -M $(CFLAGS) $< > $@.$$$$; \
149+
sed 's,\($*\.o\)[ :]*,$(OBJODIR)/\1 $@ : ,g' < $@.$$$$ > $@; \
150+
rm -f $@.$$$$
151+
152+
$(foreach lib,$(GEN_LIBS),$(eval $(call ShortcutRule,$(lib),$(LIBODIR))))
153+
154+
$(foreach image,$(GEN_IMAGES),$(eval $(call ShortcutRule,$(image),$(IMAGEODIR))))
155+
156+
$(foreach bin,$(GEN_BINS),$(eval $(call ShortcutRule,$(bin),$(BINODIR))))
157+
158+
$(foreach lib,$(GEN_LIBS),$(eval $(call MakeLibrary,$(basename $(lib)))))
159+
160+
$(foreach image,$(GEN_IMAGES),$(eval $(call MakeImage,$(basename $(image)))))
161+
162+
#############################################################
163+
# Recursion Magic - Don't touch this!!
164+
#
165+
# Each subtree potentially has an include directory
166+
# corresponding to the common APIs applicable to modules
167+
# rooted at that subtree. Accordingly, the INCLUDE PATH
168+
# of a module can only contain the include directories up
169+
# its parent path, and not its siblings
170+
#
171+
# Required for each makefile to inherit from the parent
172+
#
173+
174+
INCLUDES := $(INCLUDES) -I /opt/xtensa-lx106-elf/lib/gcc/xtensa-lx106-elf/4.8.2/include/ -I $(PDIR)include -I $(PDIR)include/$(TARGET)
175+
INCLUDES += -I ./ -I $(PDIR)include/lwip -I $(PDIR)include/lwip/ipv4 -I $(PDIR)include/lwip/ipv6
176+
INCLUDES += -I $(PDIR)include/espressif
177+
PDIR := ../$(PDIR)
178+
sinclude $(PDIR)Makefile
2.53 MB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.