forked from ethersex/ethersex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
419 lines (360 loc) · 12.6 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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
TARGET := ethersex
TOPDIR = .
SUBDIRS += control6
SUBDIRS += core
SUBDIRS += core/crypto
SUBDIRS += core/host
SUBDIRS += core/portio
SUBDIRS += core/tty
SUBDIRS += core/gui
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/ir/irmp
SUBDIRS += hardware/isdn
SUBDIRS += hardware/lcd
SUBDIRS += hardware/lcd/s1d15g10
SUBDIRS += hardware/lcd/ST7626
SUBDIRS += hardware/lcd/s1d13305
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 += hardware/ultrasonic
SUBDIRS += hardware/hbridge
SUBDIRS += protocols/artnet
SUBDIRS += protocols/bootp
SUBDIRS += protocols/dali
SUBDIRS += protocols/dhcp
SUBDIRS += protocols/dmx
SUBDIRS += protocols/fnordlicht
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/httplog
SUBDIRS += protocols/twitter
SUBDIRS += protocols/netstat
SUBDIRS += protocols/to1
SUBDIRS += protocols/serial_line_log
SUBDIRS += protocols/msr1
SUBDIRS += protocols/nmea
SUBDIRS += protocols/udpIO
SUBDIRS += protocols/udpstella
SUBDIRS += protocols/udpcurtain
SUBDIRS += protocols/cw
SUBDIRS += services/clock
SUBDIRS += services/cron
SUBDIRS += services/dyndns
SUBDIRS += services/dmx-storage
SUBDIRS += services/dmx-fxslot
SUBDIRS += services/echo
SUBDIRS += services/freqcount
SUBDIRS += services/pam
SUBDIRS += services/httpd
SUBDIRS += services/jabber
SUBDIRS += services/ntp
SUBDIRS += services/wol
SUBDIRS += services/motd
SUBDIRS += services/moodlight
SUBDIRS += services/stella
SUBDIRS += services/starburst
SUBDIRS += services/tftp
SUBDIRS += services/upnp
SUBDIRS += services/appsample
SUBDIRS += services/watchcat
SUBDIRS += services/vnc
SUBDIRS += services/watchasync
SUBDIRS += services/curtain
SUBDIRS += services/glcdmenu
SUBDIRS += services/lome6
SUBDIRS += services/projectors/sanyoZ700
rootbuild=t
export TOPDIR
ifneq ($(no_deps),t)
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),fullclean)
ifneq ($(MAKECMDGOALS),mrproper)
ifneq ($(MAKECMDGOALS),menuconfig)
ifneq ($(MAKECMDGOALS),indent)
include $(TOPDIR)/.config
endif # MAKECMDGOALS!=indent
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"
@$(CONFIG_SHELL) ${TOPDIR}/scripts/size $(TARGET) $(MCU)
@echo "==================================="
endif
.PHONY: all
.SILENT: all
##############################################################################
# logging to file make.log
# calls make all and redirects stdout and stderr to make.log
v:
(echo "===== logging make activity to file make.log =====";\
echo "Build started on `date`";\
${MAKE} all 2>&1) | tee make.log
##############################################################################
# print information about binary size and flash usage
size-info:
@echo "===== size info ====="
@$(CONFIG_SHELL) ${TOPDIR}/scripts/size $(TARGET) $(MCU)
##############################################################################
# target help displays a short overview over make options
help:
@echo "Configuration targets:"
@echo " menuconfig - Update current config utilising a menu based program"
@echo " (default when .config does not exist)"
@echo ""
@echo "Cleaning targets:"
@echo " clean - Remove bin and dep files"
@echo " fullclean - Same as "clean", but also remove object files"
@echo " mrproper - Same as "fullclean", but also remove all config files"
@echo ""
@echo "Information targets:"
@echo " show-config - show enabled modules"
@echo " size-info - show size information of compiled binary"
@echo ""
@echo "Other generic targets:"
@echo " all - Build everything as specified in .config"
@echo " (default if .config exists)"
@echo " v - Same as "all" but with logging to make.log enabled"
##############################################################################
# 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} > [email protected]
@echo "Copying to meta.m4"
@if [ ! -e $@ ]; then cp [email protected] $@; fi
@if ! diff [email protected] $@ >/dev/null; then cp [email protected] $@; fi
@rm -f [email protected]
$(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)
SIZEFUNCARG ?= -e printf -e scanf -e divmod
size-check: $(OBJECTS) ethersex
@for obj in $^; do \
if avr-nm $$obj | grep -q $(SIZEFUNCARG); then \
echo -n "$$obj: "; avr-nm $$obj | grep $(SIZEFUNCARG) | cut -c12- | tr '\n' ','; echo ''; \
fi; \
done
##############################################################################
# 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 -xc -DF_CPU=$(FREQ) -I$(TOPDIR) -include autoconf.h $< 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
$(CONFIG_SHELL) 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) $<
##############################################################################
### Special case for MacOS X (darwin10.0) and FreeBSD
CONFIG_SHELL := $(shell if [ x"$$OSTYPE" = x"darwin10.0" ] ; then echo /opt/local/bin/bash; \
elif [ x"$$OSTYPE" = x"FreeBSD" ]; then echo /usr/local/bin/bash; \
elif [ -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)
### Special case for MacOS X (darwin10.0)
### bash v3.2 in 10.6 does not work, use version 4.0 from macports
### (see "Voraussetzungen" in wiki)
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 "======================================"
@$(SED) -e "/^#define \<.*_SUPPORT\>/!d;s/^#define / * /;s/_SUPPORT.*//" autoconf.h
.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
##############################################################################
# reformat source code
indent: INDENTCMD=indent -nbad -sc -nut -bli0 -blf -cbi0 -cli2 -npcs -nbbo
indent:
@find . $(SUBDIRS) -maxdepth 1 -name "*.[ch]" | \
egrep -v "(ir.*_lib|core/crypto)" | \
while read f; do \
$(INDENTCMD) "$$f"; \
done
.PHONY: indent
include $(TOPDIR)/scripts/depend.mk