Makefile
author Mike Kinghan <mikek@symbian.org>
Mon, 16 Nov 2009 10:04:44 +0000
changeset 0 37428ad74fc2
child 1 820b22e13ff1
permissions -rw-r--r--
Initial commit.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2009 Symbian Foundation Ltd
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     2
# This component and the accompanying materials are made available
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     3
# under the terms of the License "Eclipse Public License v1.0"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     4
# which accompanies this distribution, and is available
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     5
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     6
#
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     7
# Initial Contributors:
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     8
# Symbian Foundation Ltd - initial contribution.
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
     9
# Mike Kinghan, mikek@symbian.org
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    10
#
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    11
# Contributors:
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    12
#
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    13
# Description:
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    14
# This is a Linux makefile for the Symbian build tools components.
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    15
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    16
epocroot := $(dir $(realpath ../epoc32))
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    17
ifneq '$(epocroot)' ''
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    18
epocroot := $(patsubst %/,%,$(epocroot))
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    19
$(warning WARNING: EPOCROOT not set. Assuming $(epocroot))
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    20
export EPOCROOT=$(epocroot)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    21
else
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    22
$(error EPOCROOT must be defined as the parent directory of your epoc32 tree)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    23
endif
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    24
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    25
ifdef EPOCROOT
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    26
include $(EPOCROOT)/build/makefiles-garage/global-make-env.mk
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    27
endif
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    28
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    29
garage = $(EPOCROOT)/build/makefiles-garage
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    30
garage_makefiles = $(shell find $(garage) -name Makefile)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    31
targets = $(notdir $(patsubst %/Makefile,%,$(garage_makefiles)))
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    32
clean_targets = $(addsuffix -clean,$(targets))
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    33
garage_make_dirs = $(patsubst %/Makefile,%,$(garage_makefiles))
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    34
make_dirs = $(patsubst $(garage)%,$(EPOCROOT)/build%,$(garage_make_dirs)) 
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    35
makefiles = $(patsubst $(garage)/%,$(EPOCROOT)/build/%,$(garage_makefiles))
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    36
raptor_linux_binaries = $(EPOCROOT)/build/sbsv2/raptor/linux-*
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    37
new_subdirs = $(EPOCROOT)/build/imgtools/romtools/r_t_areaset
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    38
subdirs = imgtools e32tools sbsv2 srctools buildframework buildtoolguides bintools
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    39
	
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    40
.PHONY: all tools export gen_preinclude clean distclean deploy_makefiles gather_makefiles help \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    41
sbs_comp_list sbs_targ_list list_hacks list_prereqs
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    42
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    43
all: tools
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    44
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    45
tools: $(preinclude) $(makefiles)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    46
	for dir in $(subdirs); do $(MAKE) -C $$dir; done
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    47
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    48
 
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    49
#export: tools
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    50
#	for dir in $(subdirs); do $(MAKE) -C $$dir export; done
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    51
		
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    52
clean: $(makefiles)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    53
	for dir in $(subdirs); do $(MAKE) -C $$dir clean; done
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    54
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    55
distclean: clean
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    56
	rm -f -r $(makefiles) $($(preinclude) $(linux_gcc_defs_inc) $(raptor_linux_binaries) $(new_subdirs)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    57
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    58
help:
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    59
	@echo "Build the Symbian build tools by conventional GNU/Linux means."
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    60
	@echo "PHONY targets:"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    61
	@echo "" 	
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    62
	@echo "  help"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    63
	@echo "  all              - Build all real targets (default)"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    64
	@echo "  clean            - Remove all build object files, libraries and executables"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    65
	@echo "  TARGET-clean     - clean the real target TARGET"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    66
	@echo "  distclean        - Remove everything but the original files"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    67
	@echo "  deploy_makefiles - Copy makefiles from the garage to the locations where they run"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    68
	@echo "  gather_makefiles - Gather any new or updated makefiles from the places where they run into the garage"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    69
	@echo "  export           - TODO: No exports are implemented yet"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    70
	@echo "  what             - TODO: \"What is built?\" not implemented yet"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    71
	@echo "  TARGET-what      - TODO: \"What is built for TARGET?\" not implemented yet" 
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    72
	@echo "  sbs_comp_list    - List the components that sbs would find (BLD.INF files)"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    73
	@echo "  sbs_targ_list    - List the targets that sbs would find (MMP files)"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    74
	@echo "  list_prereqs     - List the dependency graph of final targets"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    75
	@echo "  list_hacks       - List the targets and files for which hacks are currently applied."
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    76
	@echo "                     The hacks are applied by the make and removed by clean." 
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    77
	@echo ""  
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    78
	@echo "Real targets in hierarchy:"
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    79
	@echo ""
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    80
	@for file in $(sort $(garage_makefiles)); do \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    81
		dummy=`grep 'include $$(EPOCROOT)/build/makefiles-garage/todo.mk' $$file 2> /dev/null`;\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    82
		todo=;\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    83
		file=$${file#$(garage)/};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    84
		file=$${file%/Makefile};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    85
		targ=$${file##*/};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    86
		file=$${file%/*};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    87
		file=$${file%$${targ}};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    88
		file=`echo $$file | sed -e 's|/||g' -`;\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    89
		file=$${file//?/-};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    90
		if [ "$${dummy}" != "" ]; then todo='  ### TODO ###'; fi; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    91
		echo "  $$file$$targ$$todo";\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    92
	done
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    93
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    94
$(makefiles): $(EPOCROOT)/build/%: $(garage)/%
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    95
	mkdir -p $(dir $@) && cp $< $@
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    96
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    97
deploy_makefiles: $(makefiles)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    98
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    99
gather_makefiles:
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   100
	for dir in $(subdirs); do \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   101
		grep --include Makefile -r -e 'include $$(EPOCROOT)/build/makefiles-garage/global-make-env.mk' $$dir | \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   102
		sed -e 's|:include $$(EPOCROOT)/build/makefiles-garage/global-make-env.mk||g' -e 's|$(EPOCROOT)/build/||g' - | while read makefile; do \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   103
			if [ ! -f $(garage)/$$makefile ]; then \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   104
				echo "### Garaging new makefile $(garage)/$$makefile ###" ;\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   105
				cp -f --parents $$makefile $(garage); \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   106
			else if [ $(EPOCROOT)/build/$$makefile -nt $(garage)/$$makefile ]; then \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   107
				if [ "`diff $(EPOCROOT)/build/$$makefile $(garage)/$$makefile`" != "" ]; then \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   108
					echo "### Updating garaged makefile $(garage)/$$makefile ###" ;\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   109
					cp -f --parents $$makefile $(garage); \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   110
				fi; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   111
			fi; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   112
			fi; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   113
		done; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   114
	done
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   115
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   116
sbs_comp_list:
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   117
	@for file in `find . -iname 'bld.inf'`; do echo $${file}; done
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   118
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   119
sbs_targ_list:
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   120
	@for file in `find . -iname '*.mmp'`; do echo $${file}; done
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   121
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   122
list_hacks: $(makefiles)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   123
	@for make_dir in $(sort $(make_dirs)); do \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   124
		$(MAKE) -s -C $$make_dir query=1 targ=$${make_dir##*/} hacks; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   125
	done	
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   126
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   127
list_prereqs: $(makefiles)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   128
	@for make_dir in $(sort $(make_dirs)); do \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   129
		$(MAKE) -s -C $$make_dir query=1 targ=$${make_dir##*/} prereqs; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   130
	done
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   131
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   132
$(targets): $(preinclude) $(makefiles)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   133
	garage_makedir=`find $(garage) -name $@`;\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   134
	makedir=$${garage_makedir##$(garage)/};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   135
	makedir=$(EPOCROOT)/build/$${makedir};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   136
	$(MAKE) -C $${makedir}
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   137
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   138
$(clean_targets): $(makefiles)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   139
	targ=$@; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   140
	targ=$${targ%-clean}; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   141
	garage_makedir=`find $(garage) -name $${targ}`;\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   142
	echo $$targ; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   143
	makedir=$${garage_makedir##$(garage)/};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   144
	makedir=$(EPOCROOT)/build/$${makedir};\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   145
	$(MAKE) -C $${makedir} clean
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   146