makefiles-garage/global-make-env.mk
author mikek
Fri, 08 Jan 2010 16:16:51 +0000
changeset 1 820b22e13ff1
parent 0 37428ad74fc2
permissions -rw-r--r--
Commit further implemented Linux makefiles
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 makefile sets up the global environment for building the Symbian build tools.
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    15
# It is included by all the makefiles.
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    16
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    17
ifndef global_make_env
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    18
# include the following only once
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    19
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    20
export global_make_env = 1
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    21
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    22
export gcc_patch = $(shell gcc --version | head -n 1 | sed -e 's/^.*\([0-9]\.[0-9]\.[0-9]\)$$/\1/g' -)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    23
export gcc_ver = $(shell gcc --version | head -n 1 | sed -e 's/^.*\([0-9]\.[0-9]\)\.[0-9]$$/\1/g' -)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    24
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    25
linux_gcc_inc_path = $(EPOCROOT)/epoc32/include/tools/linux/gcc
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    26
linux_gcc_ver_inc_path = $(linux_gcc_inc_path)/$(gcc_ver)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    27
linux_gcc_patch_inc_path = $(linux_gcc_inc_path)/$(gcc_patch)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    28
linux_gcc_defs_inc = $(linux_gcc_ver_inc_path)/hack_defs.h 
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    29
preinclude = $(linux_gcc_ver_inc_path)/preinclude.h
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    30
make_preinclude := $(shell if [ -f $(preinclude) ]; then echo N; else echo Y; fi)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    31
global_cpp_defs = -D__LINUX__ -D__TOOLS2__ -D__TOOLS__ -D__GCC32__ -D__PLACEMENT_NEW_INLINE -D__PLACEMENT_VEC_NEW_INLINE
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    32
global_cpp_inc_paths = -I $(EPOCROOT)/epoc32/include -I $(EPOCROOT)/epoc32/include/tools/linux/gcc/$(gcc_ver)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    33
global_cpp_preinclude = -include $(preinclude)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    34
   
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    35
export CC = g++
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    36
export global_cpp_flags = $(global_cpp_defs) $(global_cpp_inc_paths) $(global_cpp_preinclude)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    37
export global_cxx_flags = -O2
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    38
export global_prereqs = $(preinclude)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    39
export global_cflags = 
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    40
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    41
ifeq ($(make_preinclude),Y)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    42
# We need to make the global preinclude.h file
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    43
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    44
$(preinclude): $(linux_gcc_defs_inc)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    45
	printf "#ifndef PREINCLUDE_H\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    46
"#include <cstdlib>\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    47
"#include <e32def.h>\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    48
"#include <hack_defs.h>\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    49
"#include <cstring>\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    50
"#include <climits>\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    51
"#include <exception>\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    52
"#include <new>\n"\
1
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
    53
"#endif\n" > $@
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    54
	$(MAKE)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    55
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    56
$(linux_gcc_patch_inc_path):
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    57
	mkdir -p $@
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    58
	
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    59
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    60
$(linux_gcc_ver_inc_path) : $(linux_gcc_patch_inc_path)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    61
	rm -f $@
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    62
	ln -s $< $@
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    63
	
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    64
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    65
$(linux_gcc_defs_inc): $(linux_gcc_ver_inc_path)
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    66
	printf "#ifndef HACK_DEFS_H\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    67
"#define HACK_DEFS_H\n"\
1
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
    68
"#define IMPORT_C\n"\
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    69
"#define __NO_THROW\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    70
"#define NONSHARABLE_CLASS(x) class x\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    71
"#undef _FOFF\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    72
"#define _FOFF(c,f) (((TInt)&(((c *)0x1000)->f))-0x1000)\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    73
"#define TEMPLATE_SPECIALIZATION template<>\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    74
"#undef __ASSERT_COMPILE\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    75
"#define __ASSERT_COMPILE(x)\n"\
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    76
"#define TAny void\n"\
1
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
    77
"#endif\n" > $@ 
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    78
  
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    79
endif
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    80
# End: make the global preinclude.h file  
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    81
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    82
endif
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    83
# End: included only once
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    84
1
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
    85
ifdef call_in
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
    86
# Running one of the call_in targets
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    87
1
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
    88
_list_fixes:
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    89
	@if [ "$(fixfiles)" != "" ]; then \
1
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
    90
		echo $(targ): fixups for:-; \
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    91
		for file in $(fixfiles); do echo "  $$file"; done; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    92
	fi
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    93
1
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
    94
_list_prereqs:
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    95
	@if [ "$(prereqs)" != "" ]; then \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    96
		echo $(targ): needs:-; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    97
		for prereq in $(prereqs); do echo "  $$prereq"; done; \
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
    98
	fi
1
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
    99
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   100
_what:
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   101
	@if [ "$(exe)" != "" ]; then \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   102
		targfile=`pwd`/$(exe); \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   103
	elif [ "$(lib)" != "" ]; then  \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   104
		targfile=`pwd`/$(lib); \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   105
	fi; \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   106
	if [ "$$targfile" != "" ]; then \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   107
		printf "Target $(targ) builds $$targfile"; \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   108
		if [ ! -f $$targfile ]; then printf " (*** Missing ***)"; fi; \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   109
		printf "\n"; \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   110
	fi
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   111
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   112
_missing:
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   113
	@if [ "$(exe)" != "" ]; then \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   114
		targfile=`pwd`/$(exe); \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   115
	elif [ "$(lib)" != "" ]; then  \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   116
		targfile=`pwd`/$(lib); \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   117
	fi; \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   118
	if [ "$$targfile" != "" ]; then \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   119
		if [ ! -f $$targfile ]; then printf "Target $(targ) is missing $$targfile\n"; fi; \
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   120
	fi
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   121
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   122
	
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   123
fixes::
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   124
	
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   125
endif
1
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   126
# End: Running one of the call_in targets
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   127
820b22e13ff1 Commit further implemented Linux makefiles
mikek
parents: 0
diff changeset
   128
0
37428ad74fc2 Initial commit.
Mike Kinghan <mikek@symbian.org>
parents:
diff changeset
   129