]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - tools/elftosb/makefile.rules
tools: elftosb: use g++ to compile elftosb to prevent link error due to missing libm
[karo-tx-uboot.git] / tools / elftosb / makefile.rules
1 #*******************************************************************************
2 #                               makefile.rules
3 # Description:
4 #   gnu make makefile rules for elftosb executable.  make needs to be called
5 #   with the following command:
6 #
7 #   make -C ${BUILD_DIR} -f ${SRC_DIR}/makefile.rules SRC_DIR=${SRC_DIR} $@;
8 #
9 #   SRC_DIR needs to be passed in.  It is assumed that make is running in
10 #   the build directory.
11
12 #*******************************************************************************
13 #                               Environment
14
15 # UNAMES is going to be set to either "Linux" or "CYGWIN_NT-5.1"
16 UNAMES = $(shell uname -s)
17
18 CXX ?= g++
19
20 #*******************************************************************************
21 #                               Directories
22
23 #*******************************************************************************
24 #                               Paths
25
26 # search path for source files. make finds them automatically.
27 VPATH =                                         \
28         ${SRC_DIR}/common                       \
29         ${SRC_DIR}/elftosb2                     \
30         ${SRC_DIR}/sbtool                       \
31         ${SRC_DIR}/keygen
32
33 # include directories
34 INC_PATH =                                      \
35     -I${SRC_DIR}/elftosb2                       \
36     -I${SRC_DIR}/keygen                         \
37     -I${SRC_DIR}/sbtool                         \
38     -I${SRC_DIR}/common
39
40 #*******************************************************************************
41 #                               Build flags
42 # Compiler flags
43 #    -g                                         : Produce debugging information.
44
45 CXXFLAGS        = -g $(INC_PATH) -D${UNAMES}
46
47 #*******************************************************************************
48 #                               File lists
49
50 OBJ_FILES_COMMON =                              \
51         AESKey.o                                \
52         Blob.o                                  \
53         crc.o                                   \
54         DataSource.o                            \
55         DataTarget.o                            \
56         ELFSourceFile.o                         \
57         EncoreBootImage.o                       \
58         EvalContext.o                           \
59         GHSSecInfo.o                            \
60         GlobMatcher.o                           \
61         HexValues.o                             \
62         Logging.o                               \
63         Operation.o                             \
64         OptionDictionary.o                      \
65         options.o                               \
66         OutputSection.o                         \
67         Random.o                                \
68         RijndaelCBCMAC.o                        \
69         rijndael.o                              \
70         SHA1.o                                  \
71         SourceFile.o                            \
72         SRecordSourceFile.o                     \
73         stdafx.o                                \
74         StELFFile.o                             \
75         StExecutableImage.o                     \
76         StSRecordFile.o                         \
77         Value.o                                 \
78         Version.o                               \
79         format_string.o                         \
80         ExcludesListMatcher.o                   \
81         SearchPath.o                            \
82         DataSourceImager.o                      \
83         IVTDataSource.o
84
85 OBJ_FILES_ELFTOSB2 =                            \
86         ${OBJ_FILES_COMMON}                     \
87         BootImageGenerator.o                    \
88         ConversionController.o                  \
89         ElftosbAST.o                            \
90         elftosb.o                               \
91         elftosb_lexer.o                         \
92         ElftosbLexer.o                          \
93         elftosb_parser.tab.o                    \
94         EncoreBootImageGenerator.o
95
96 OBJ_FILES_SBTOOL =                              \
97         ${OBJ_FILES_COMMON}                     \
98         EncoreBootImageReader.o                 \
99         sbtool.o
100
101 OBJ_FILES_KEYGEN =                              \
102         ${OBJ_FILES_COMMON}                     \
103         keygen.o
104
105
106 LIBS = -lstdc++
107
108
109 ifeq ("${UNAMES}", "Linux")
110 EXEC_FILE_ELFTOSB2 = elftosb
111 EXEC_FILE_SBTOOL = sbtool
112 EXEC_FILE_KEYGEN = keygen
113 else
114 ifeq ("${UNAMES}", "CYGWIN_NT-5.1")
115 EXEC_FILE_ELFTOSB2 = elftosb.exe
116 EXEC_FILE_SBTOOL = sbtool.exe
117 EXEC_FILE_KEYGEN = keygen.exe
118 endif # ifeq ("${UNAMES}", "CYGWIN_NT-5.1")
119 endif # ifeq ("${UNAMES}", "Linux")
120
121
122 #*******************************************************************************
123 #                                 Targets
124
125 all: elftosb sbtool keygen
126
127 # Uncomment the next line to print out the environment variables.
128 all: exec_always
129
130 exec_always:
131         @echo "SRC_DIR = ${SRC_DIR}"
132         @echo "OBJ_FILES = ${OBJ_FILES_ELFTOSB2}"
133         @echo "LIBS = ${LIBS}"
134         @echo "EXEC_FILE_ELFTOSB2 = ${EXEC_FILE_ELFTOSB2}"
135         @echo "BUILD_DIR = ${BUILD_DIR}"
136
137 clean:
138         rm -f ${OBJ_FILES_ELFTOSB2} ${OBJ_FILES_SBTOOL} ${OBJ_FILES_KEYGEN} \
139                 ${EXEC_FILE_ELFTOSB2} ${EXEC_FILE_SBTOOL} ${EXEC_FILE_KEYGEN}
140
141 elftosb: ${OBJ_FILES_ELFTOSB2}
142         $(CXX) ${OBJ_FILES_ELFTOSB2} ${LIBS} -o ${EXEC_FILE_ELFTOSB2}
143
144 sbtool: ${OBJ_FILES_SBTOOL}
145         $(CXX) ${OBJ_FILES_SBTOOL} ${LIBS} -o ${EXEC_FILE_SBTOOL}
146
147 keygen: ${OBJ_FILES_KEYGEN}
148         $(CXX) ${OBJ_FILES_KEYGEN} ${LIBS} -o ${EXEC_FILE_KEYGEN}
149
150
151 #ifeq ("${UNAMES}", "Linux")
152 # Use default rules for creating all the .o files from the .c files.  Only
153 # for linux
154 .SUFFIXES : .c .cpp .o .h
155
156 .c.o:
157         $(CC) ${CXXFLAGS} -c $<
158
159 .cpp.o:
160         $(CXX) ${CXXFLAGS} -c $<
161
162 #endif
163
164 #*******************************************************************************
165 #                       Automatic dependency generation
166
167 %.d: %.c
168         @set -e; \
169         $(CC) -MM $(CXXFLAGS) $< | \
170         sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
171         [ -s $@ ]  || rm -f $@
172
173 %.d: %.cpp
174         @set -e; \
175         $(CC) -MM $(CXXFLAGS) $< | \
176         sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@; \
177         [ -s $@ ]  || rm -f $@
178
179 #*******************************************************************************