forked from ethersex/ethersex
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
328 lines (277 loc) · 9.34 KB
/
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
TARGET := ethersex
TOPDIR = .
SUBDIRS += control6
SUBDIRS += core
SUBDIRS += core/crypto
SUBDIRS += core/host
SUBDIRS += core/portio
SUBDIRS += core/tty
SUBDIRS += core/util
SUBDIRS += core/vfs
SUBDIRS += mcuf
SUBDIRS += hardware/adc
SUBDIRS += hardware/adc/kty
SUBDIRS += hardware/adc/ads7822
SUBDIRS += hardware/avr
SUBDIRS += hardware/dac
SUBDIRS += hardware/clock/dcf77
SUBDIRS += hardware/camera
SUBDIRS += hardware/ethernet
SUBDIRS += hardware/i2c/master
SUBDIRS += hardware/i2c/slave
SUBDIRS += hardware/input
SUBDIRS += hardware/input/ps2
SUBDIRS += hardware/input/buttons
SUBDIRS += hardware/io_expander
SUBDIRS += hardware/ir/rc5
SUBDIRS += hardware/isdn
SUBDIRS += hardware/lcd
SUBDIRS += hardware/lcd/s1d15g10
SUBDIRS += hardware/lcd/ST7626
SUBDIRS += hardware/onewire
SUBDIRS += hardware/pwm
SUBDIRS += hardware/sms
SUBDIRS += hardware/radio/fs20
SUBDIRS += hardware/radio/rfm12
SUBDIRS += hardware/sht
SUBDIRS += hardware/sram
SUBDIRS += hardware/storage/dataflash
SUBDIRS += hardware/storage/sd_reader
SUBDIRS += hardware/zacwire
SUBDIRS += protocols/artnet
SUBDIRS += protocols/bootp
SUBDIRS += protocols/dmx
SUBDIRS += protocols/mdns_sd
SUBDIRS += protocols/modbus
SUBDIRS += protocols/mysql
SUBDIRS += protocols/smtp
SUBDIRS += protocols/sms77
SUBDIRS += protocols/snmp
SUBDIRS += protocols/syslog
SUBDIRS += protocols/uip
SUBDIRS += protocols/uip/ipchair
SUBDIRS += protocols/ustream
SUBDIRS += protocols/usb
SUBDIRS += protocols/yport
SUBDIRS += protocols/zbus
SUBDIRS += protocols/dns
SUBDIRS += protocols/ecmd/
SUBDIRS += protocols/ecmd/sender
SUBDIRS += protocols/ecmd/via_i2c
SUBDIRS += protocols/ecmd/via_tcp
SUBDIRS += protocols/ecmd/via_udp
SUBDIRS += protocols/ecmd/via_usart
SUBDIRS += protocols/irc
SUBDIRS += protocols/soap
SUBDIRS += protocols/twitter
SUBDIRS += protocols/netstat
SUBDIRS += protocols/to1
SUBDIRS += protocols/msr1
SUBDIRS += protocols/nmea
SUBDIRS += protocols/udpIO
SUBDIRS += protocols/udpstella
SUBDIRS += protocols/udpcurtain
SUBDIRS += services/clock
SUBDIRS += services/cron
SUBDIRS += services/dyndns
SUBDIRS += services/echo
SUBDIRS += services/pam
SUBDIRS += services/httpd
SUBDIRS += services/jabber
SUBDIRS += services/ntp
SUBDIRS += services/wol
SUBDIRS += services/stella
SUBDIRS += services/tftp
SUBDIRS += services/upnp
SUBDIRS += services/appsample
SUBDIRS += services/watchcat
SUBDIRS += services/curtain
rootbuild=t
export TOPDIR
ifneq ($(no_deps),t)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),fullclean)
ifneq ($(MAKECMDGOALS),mrproper)
ifneq ($(MAKECMDGOALS),menuconfig)
include $(TOPDIR)/.config
endif # MAKECMDGOALS!=menuconfig
endif # MAKECMDGOALS!=fullclean
endif # MAKECMDGOALS!=mrproper
endif # MAKECMDGOALS!=clean
endif # no_deps!=t
##############################################################################
ifeq ($(ARCH_HOST),y)
all: $(TARGET)
else
all: compile-$(TARGET)
@echo "=======The ethersex project========"
@echo "Compiled for: $(MCU) at $(FREQ)Hz"
@${TOPDIR}/scripts/size $(TARGET) $(MCU)
@echo "==================================="
endif
.PHONY: all
.SILENT: all
##############################################################################
# generic fluff
include $(TOPDIR)/scripts/defaults.mk
#include $(TOPDIR)/scripts/rules.mk
SRC += ethersex.c
${UIP_SUPPORT}_SRC += network.c
include $(foreach subdir,$(SUBDIRS),$(subdir)/Makefile)
debug:
@echo SRC: ${SRC}
@echo y_SRC: ${y_SRC}
@echo y_ECMD_SRC: ${y_ECMD_SRC}
@echo y_SOAP_SRC: ${y_SOAP_SRC}
${ECMD_PARSER_SUPPORT}_SRC += ${y_ECMD_SRC}
${SOAP_SUPPORT}_SRC += ${y_SOAP_SRC}
meta.m4: ${SRC} ${y_SRC} .config
@echo "Build meta files"
sed -ne '/Ethersex META/{n;:loop p;n;/\*\//!bloop }' ${SRC} ${y_SRC} > $@
$(ECMD_PARSER_SUPPORT)_NP_SIMPLE_META_SRC = protocols/ecmd/ecmd_defs.m4 ${named_pin_simple_files}
$(SOAP_SUPPORT)_NP_SIMPLE_META_SRC = protocols/ecmd/ecmd_defs.m4 ${named_pin_simple_files}
y_META_SRC += scripts/meta_magic.m4
$(ECMD_PARSER_SUPPORT)_META_SRC += protocols/ecmd/ecmd_magic.m4
$(SOAP_SUPPORT)_META_SRC += protocols/soap/soap_magic.m4
y_META_SRC += meta.m4
$(ECMD_PARSER_SUPPORT)_META_SRC += protocols/ecmd/ecmd_defs.m4 ${named_pin_simple_files}
y_META_SRC += $(y_NP_SIMPLE_META_SRC)
meta.c: $(y_META_SRC)
@m4 `scripts/m4-defines` $^ > $@
meta.h: scripts/meta_header_magic.m4 meta.m4
@m4 `scripts/m4-defines` $^ > $@
##############################################################################
compile-$(TARGET): $(TARGET).hex $(TARGET).bin
.PHONY: compile-$(TARGET)
.SILENT: compile-$(TARGET)
OBJECTS += $(patsubst %.c,%.o,${SRC} ${y_SRC} meta.c)
OBJECTS += $(patsubst %.S,%.o,${ASRC} ${y_ASRC})
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) -lc -lm # Pixie Dust!!! (Bug in avr-binutils)
##############################################################################
# Generate ethersex.hex file
# If inlining is enabled, we need to copy from ethersex.bin to not lose
# those files. However we mustn't always copy the binary, since that way
# a bootloader cannot be built (the section start address would get lost).
ifeq ($(VFS_INLINE_SUPPORT),y)
%.hex: %.bin
$(OBJCOPY) -O ihex -I binary $(TARGET).bin $(TARGET).hex
else
%.hex: %
$(OBJCOPY) -O ihex -R .eeprom $< $@
endif
.SILENT: %.hex
##############################################################################
#
# VFS Inline Files
#
##############################################################################
ifeq ($(VFS_INLINE_SUPPORT),y)
INLINE_FILES := $(shell ls embed/* | sed '/\.tmp$$/d; /\.gz$$/d; s/\.cpp$$//; s/\.m4$$//; s/\.sh$$//;')
ifeq ($(DEBUG_INLINE_FILES),y)
.PRECIOUS = $(INLINE_FILES)
endif
else
INLINE_FILES :=
endif
embed/%: embed/%.cpp
@if ! avr-cpp -DF_CPU=$(FREQ) -I$(TOPDIR) $< 2> /dev/null > [email protected]; \
then $(RM) $@; echo "--> Don't include $@ ($<)"; \
else sed '/^$$/d; /^#[^#]/d' <[email protected] > $@; \
echo "--> Include $@ ($<)"; fi
@$(RM) [email protected]
embed/%: embed/%.m4
@if ! m4 `scripts/m4-defines` $< > $@; \
then $(RM) $@; echo "--> Don't include $@ ($<)";\
else echo "--> Include $@ ($<)"; fi
embed/%: embed/%.sh
@if ! $(CONFIG_SHELL) $< > $@; then $(RM) $@; echo "--> Don't include $@ ($<)"; \
else echo "--> Include $@ ($<)"; fi
%.bin: % $(INLINE_FILES)
$(OBJCOPY) -O binary -R .eeprom $< $@
ifeq ($(VFS_INLINE_SUPPORT),y)
@$(MAKE) -C core/vfs vfs-concat TOPDIR=../.. no_deps=t
@core/vfs/do-embed $(INLINE_FILES)
endif
##############################################################################
%.eep.hex: %
$(OBJCOPY) --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex -j .eeprom $< $@
%.lss: %
$(OBJDUMP) -h -S $< > $@
%-size: %.hex
$(SIZE) $<
##############################################################################
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
elif [ -x /bin/bash ]; then echo /bin/bash; \
elif [ -x /usr/local/bin/bash ]; then echo /usr/local/bin/bash; \
else echo sh; fi)
menuconfig:
$(MAKE) -C scripts/lxdialog all
$(CONFIG_SHELL) scripts/Menuconfig config.in
test -e .config
@$(MAKE) no_deps=t what-now-msg
what-now-msg:
@echo ""
@echo "Next, you can: "
@echo " * '$(MAKE)' to compile Ethersex"
@for subdir in $(SUBDIRS); do \
test -e "$$subdir/configure" -a -e "$$subdir/cfgpp" \
&& echo " * '$(MAKE) $$subdir/menuconfig' to" \
"further configure $$subdir"; done || true
@echo ""
.PHONY: what-now-msg
%/menuconfig:
$(SH) "$(@D)/configure"
@$(MAKE) what-now-msg
##############################################################################
clean:
$(RM) $(TARGET) $(TARGET).lss $(TARGET).bin $(TARGET).hex pinning.c
$(RM) $(OBJECTS) $(CLEAN_FILES) \
$(patsubst %.o,%.dep,${OBJECTS}) \
$(patsubst %.o,%.E,${OBJECTS}) \
$(patsubst %.o,%.s,${OBJECTS}) network.dep
$(RM) meta.c meta.h meta.m4
echo "Cleaning completed"
fullclean: clean
find $(TOPDIR)/ -type f \( -name '*.o' -o -name '*.dep' \) -print0 \
| xargs -0 $(RM)
echo "Full cleaning completed"
mrproper: fullclean
$(RM) autoconf.h .config config.mk .menuconfig.log .config.old
echo "All object files and config files are gone now"
.PHONY: clean fullclean mrproper
.SILENT: clean fullclean mrproper
##############################################################################
# MCU specific pinning code generation
#
PINNING_FILES=pinning/internals/header.m4 \
$(wildcard pinning/*/$(MCU).m4) \
$(wildcard pinning/internals/hackery_$(MCU).m4) \
$(wildcard pinning/hardware/$(HARDWARE).m4) pinning/internals/footer.m4
pinning.c: $(PINNING_FILES) autoconf.h
@m4 -I$(TOPDIR)/pinning `scripts/m4-defines` $(PINNING_FILES) > $@
##############################################################################
# configure ethersex
#
show-config: autoconf.h
@echo
@echo MCU: $(MCU) Hardware: $(HARDWARE)
@echo
@echo "These modules are currently enabled: "
@echo "======================================"
@grep -e "^#define .*_SUPPORT" autoconf.h | sed -e "s/^#define / * /" -e "s/_SUPPORT.*//"
.PHONY: show-config
autoconf.h .config:
@echo $(MAKE)\'s goal: $(MAKECMDGOALS)
ifneq ($(MAKECMDGOALS),menuconfig)
# make sure menuconfig isn't called twice, on `make menuconfig'
test -s autoconf.h -a -s .config || $(MAKE) no_deps=t menuconfig
# test the target file, test fails if it doesn't exist
# and will keep make from looping menuconfig.
test -s autoconf.h -a -s .config
# now let's restart make so the .config is (re)evaluated.
$(MAKE) $(MAKECMDGOALS)
@echo Ethersex compiled successfully, ignore make error!
@false # stop compilation
endif
include $(TOPDIR)/scripts/depend.mk