https://bitbucket.org/hudson/magic-lantern
Raw File
Tip revision: 3ccb305b4de972c735ec70319e2c5f005c3647d9 authored by a1ex on 28 January 2015, 16:47:58 UTC
Close branch restore-after-format
Tip revision: 3ccb305
Makefile.src
#
# Magic Lantern Core source files and rules
#

all:: autoexec.bin

clean::
	$(call rm_files, *.o *.d autoexec autoexec.bin magiclantern magiclantern.bin)

CFLAGS += \
	-DCONFIG_MAGICLANTERN=1 \
	-DCONFIG_$(subst .,_,$(MODEL))=1 \
	-DRESTARTSTART=$(RESTARTSTART) \
	-DROMBASEADDR=$(ROMBASEADDR) \
	-DVERSION=\"$(VERSION)\" \
	-DCAMERA_MODEL=\"$(MODEL)\" \
	-DCONFIG_DEBUGMSG=$(CONFIG_DEBUGMSG) \
	-DCONFIG_FW_VERSION=$(FW_VERSION) \
	-DCURRENT_CAMERA_SIGNATURE=SIG_$(MODEL)_$(FW_VERSION)

ifeq ($(ML_BOOT_HACK_OBJ), n)
ML_BOOT_HACK_OBJ =
else ifndef ML_BOOT_HACK_OBJ
ML_BOOT_HACK_OBJ = boot-hack.o
endif

ifeq ($(ML_PICSTYLE_AUTO), n)
ML_PICSTYLE_OBJ = picstyle-noauto.o
else
ML_PICSTYLE_OBJ = picstyle.o
endif

ifeq ($(ML_BITRATE_OBJ), n)
ML_BITRATE_OBJ =
else ifndef ML_BITRATE_OBJ
ML_BITRATE_OBJ = bitrate.o
endif

ifeq ($(ML_AUDIO_OBJ), n)
ML_AUDIO_OBJ =
else ifndef ML_AUDIO_OBJ
ML_AUDIO_OBJ = audio-ak.o
endif

ifeq ($(ML_ZEBRA_OBJ), n)
ML_ZEBRA_OBJ =
else ifndef ML_ZEBRA_OBJ
ML_ZEBRA_OBJ = zebra.o \
			   vectorscope.o
endif

ifeq ($(ML_BOOTFLAGS_OBJ), n)
ML_BOOTFLAGS_OBJ =
else ifndef ML_BOOTFLAGS_OBJ
ML_BOOTFLAGS_OBJ = bootflags.o
endif

ifeq ($(ML_AF_PATTERNS_OBJ), n)
ML_AF_PATTERNS_OBJ = 
else ifndef ML_AF_PATTERNS_OBJ
ML_AF_PATTERNS_OBJ = af_patterns.o
endif

ifeq ($(ML_ENTRY_OBJ), n)
ML_ENTRY_OBJ =
else ifndef ML_ENTRY_OBJ
ML_ENTRY_OBJ = entry.o
endif

ifeq ($(ML_SRC_PROFILE),minimal)
ML_OBJS-y = \
	magiclantern.lds \
	$(ML_ENTRY_OBJ) \
	minimal.o \
	$(PLATFORM_DIR)/stubs.o

else ifeq ($(ML_SRC_PROFILE),installer)
ML_INSTALLER_OBJS = \
	magiclantern.lds \
	$(ML_ENTRY_OBJ) \
	$(PLATFORM_DIR)/stubs.o \
	installer.o \
	version.o \
	fio-ml.o \
	ico.o \
	bmp.o \
	rbf_font.o \
	stdio.o \
	dialog_test.o \
	bootflags.o \
	mem.o \
	util.o \

ML_OBJS-y += $(ML_INSTALLER_OBJS)

CFLAGS += -DCONFIG_INSTALLER

else ifeq ($(ML_SRC_PROFILE),generic)

ML_OBJS-y += \
	magiclantern.lds \
	$(ML_ENTRY_OBJ) \
	$(PLATFORM_DIR)/stubs.o \
	version.o

ML_SRC_OBJS = \
	$(ML_BOOT_HACK_OBJ) \
	fio-ml.o \
	mem.o \
	ico.o \
	edmac.o \
	menu.o \
	debug.o \
	rand.o \
	posix.o \
	util.o \
	imath.o \
	electronic_level.o \
	cfn.o \
	gui.o \
	$(ML_PICSTYLE_OBJ) \
	exmem.o \
	bmp.o \
	rbf_font.o \
	config.o \
	stdio.o \
	$(ML_BITRATE_OBJ) \
	lcdsensor.o \
	tweaks.o \
	tweaks-eyefi.o \
	lens.o \
	property.o \
	propvalues.o \
	gui-common.o \
	chdk-gui_draw.o \
	movtweaks.o \
	menuhelp.o \
	menuindex.o \
	$(ML_AF_PATTERNS_OBJ) \
	focus.o \
	notify_box.o \
	$(ML_BOOTFLAGS_OBJ) \
	dialog_test.o \
	vram.o \
	greenscreen.o \
	fps-engio.o \
	shoot.o \
	hdr.o \
	lv-img-engio.o \
	state-object.o \
	tasks.o \
	vsync-lite.o \
	tskmon.o \
	battery.o \
	imgconv.o \
	histogram.o \
	falsecolor.o \
	$(ML_AUDIO_OBJ) \
	$(ML_ZEBRA_OBJ) \
	beep.o \
	crop-mode-hack.o \
	ph_info_disp.o \
	flexinfo.o \
	screenshot.o \
	fileprefix.o \
	lvinfo.o \
	builtin-enforcing.o \
	ml-cbr.o 

ML_OBJS-y += $(ML_SRC_OBJS)

include $(TOP_DIR)/src/Makefile.src.config

else ifndef ML_OBJS-y
$(error ML_OBJS-y is not defined)
endif

ifneq ($(ML_SRC_PROFILE),minimal)
ML_OBJS-y += $(ML_SRC_EXTRA_OBJS)
endif

ifdef ML_SRC_EXCLUDE_OBJS
ML_OBJS-y := $(filter-out $(ML_SRC_EXCLUDE_OBJS), $(ML_OBJS-y))
endif

include $(TOP_DIR)/Makefile.filerules

# Magic Lantern rules

magiclantern: $(ML_OBJS-y) $(ML_LIBC)
	$(call build,LD,$(LD) \
		-o $@ \
		-N \
		$(LFLAGS) \
		-T \
		$^ \
        -Map=location.map \
	)

reboot.o: $(SRC_DIR)/reboot.c $(PLATFORM_DIR)/version.bin magiclantern.bin

ifndef ML_SRC_REBOOT_OBJ
ML_SRC_REBOOT_OBJ = reboot.o
endif

clean::
	$(call rm_files, magiclantern.bin autoexec autoexec.map location.map)

autoexec: $(ML_SRC_REBOOT_OBJ)
	$(call build,LD,$(LD) \
		-o $@ \
		-e _start \
		-Ttext $(AUTOEXEC_BASE) \
		$^ \
		--cref \
		-Map=autoexec.map \
	); \
	$(READELF) -l magiclantern | $(GREP) -C 2 MemSiz

autoexec-fir: $(ML_SRC_REBOOT_OBJ)
	$(call build,LD,$(LD) \
		-o $@ \
		-e _start \
		-Ttext $(FIR_BASE) \
		$^ \
		--cref \
		-Map=autoexec.map \
	);

clean::
	$(call rm_files, autoexec-fir autoexec-fir.bin)

magiclantern.lds: $(SRC_DIR)/magiclantern.lds.S
	$(call build,CPP,$(CPP) $(CFLAGS) $< | $(GREP) -v '^#' > $@)

clean::
	$(call rm_files, magiclantern.lds)

$(TOP_DIR)/tcc/libtccx.o: FORCE
	+$(MAKE) -C $(TOP_DIR)/tcc

# Extract the stdio files that we need
DIET_OBJ = \
	strrchr.o \
	strncpy.o \
	strlen.o \
	strncmp.o \
	strcpy.o \
	strcmp.o \
	strcasecmp.o \
	errno.o \
	errno_location.o \
	strtoull.o \
	strtol.o \
	strtoul.o \
	strchr.o \
	memcmp.o \
	memmove.o \
	atoi.o \
	atol.o \

$(DIET_OBJ): $(DIETLIBC_A)
	$(call build,AR,$(AR) x $? $(DIET_OBJ))

dietlibc.a: $(DIET_OBJ)
	$(call build,AR,$(AR) cr $@ $^)

# use setjmp from newlib because... the one from dietlibc freezes
# memcpy/memset are also much faster in newlib
NEWLIB_OBJ = \
	lib_a-setjmp.o \
	lib_a-memcpy.o \
	lib_a-memcpy-stub.o \
	lib_a-memccpy.o \
	lib_a-memset.o \
	lib_a-memmove.o \

$(NEWLIB_OBJ): $(NEWLIB_LIBC_A)
	$(call build,AR,$(AR) x $? $(NEWLIB_OBJ))

newlib-libc.a: $(NEWLIB_OBJ)
	$(call build,AR,$(AR) cr $@ $^)

newlib-libm.a: $(NEWLIB_LIBM_A)
	$(call build,CP,$(CP) $^ $@)

gcc-libgcc.a: $(ARM_LIBGCC_A)
	$(call build,CP,$(CP) $^ $@)

clean::
	$(call rm_files, $(ML_LIBC))

$(PLATFORM_DIR)/version.c: FORCE
	$(call build,"VERSION",echo "const char build_version[] = \"$(VERSION)\";") > $@
	@echo 'const char build_id[] = "'`hg id`'";' >> $@
	@echo 'const char build_date[] ="'`$(DATE) "+%Y-%m-%d %H:%M:%S %Z"`'";' >> $@
	@echo 'const char build_user[] = "'`whoami`@`hostname`'";'  >> $@

# this must have exactly 0x11C (284) bytes, see reboot.c
$(PLATFORM_DIR)/version.bin: FORCE
	$(call build,"VERSION",echo -e '\b\b\b\bMagic Lantern $(VERSION)') > $@
	@echo 'Mercurial changeset: '`hg id` >> $@
	@echo 'Built on '`date -u "+%Y-%m-%d %H:%M:%S"`' by '`whoami`@`hostname` >> $@
	@echo '' >> $@
	@echo 'Camera  : $(MODEL)' >> $@
	@echo 'Firmware: $(FW_VERSION)' >> $@
	@echo -e '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' >> $@
	@echo -e '\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n' >> $@
	@truncate -s 284 $@

$(SRC_DIR)/menuindexentries.h:
	$(call build,"MENU IDX", if [ -f $(DOC_DIR)/menuindex.txt ]; then \
		cd $(DOC_DIR); $(PYTHON) menuindex.py; \
	else \
		echo ; \
		echo "No menuindex.txt! The \"Complete user guide\" menu is empty!" ; \
		echo "Run make docq to update menuindex.txt." ; \
		echo ; \
		truncate -s 0 $@ ; \
	fi)

menuindex.o: $(SRC_DIR)/menuindexentries.h

clean::
	$(call rm_files, version.c version.bin)

FORCE:
back to top