author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
# VxWorks Munching Feature |
2 |
# When compiling C++ sources on VxWorks in kernel mode, all .o files have to |
|
3 |
# be processed by the so-called 'munch' script which will generate |
|
4 |
# additional code for static c'tors and d'tors. The resulting .c file has to |
|
5 |
# be compiled in turn and linked to the executable. |
|
6 |
# This can only been done when linking applications, since the munch script |
|
7 |
# generates a .c file containing static symbols: linking a lib that was |
|
8 |
# already munched to a munched application would lead to duplicate symbols! |
|
9 |
||
10 |
isEmpty(VXWORKS_MUNCH_EXT):VXWORKS_MUNCH_EXT = vxm |
|
11 |
isEmpty(VXWORKS_MUNCH_TOOL):VXWORKS_MUNCH_TOOL = $(WIND_BASE)/host/resource/hutils/tcl/munch.tcl |
|
12 |
||
13 |
||
14 |
!exists($$VXWORKS_MUNCH_TOOL) { |
|
15 |
error("Could not find VxWorks Munch tool: '$${VXWORKS_MUNCH_TOOL}'. Please set the environment variable WIND_BASE correctly.") |
|
16 |
} |
|
17 |
||
18 |
# The following scope is entered for any project that specifies 'shared' as well |
|
19 |
# as for any project specifying neither 'shared', nor 'lib', nor 'staticlib'. |
|
20 |
# This means that for a static build only the executable is munched, while for |
|
21 |
# a shared build, every lib, plugin and executable is munched separately. |
|
22 |
||
23 |
shared|!staticlib:!lib { |
|
24 |
*-dcc { |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
25 |
VXWORKS_MUNCH_CMD = targ=`basename $(TARGET)`; \ |
0 | 26 |
ddump -Ng \"$(TARGET)\" | tclsh $$VXWORKS_MUNCH_TOOL -c $$VXWORKS_ARCH_MUNCH >\"$(OBJECTS_DIR)/\$\${targ}_ctdt.c\" && \ |
27 |
$$QMAKE_CC -c $$QMAKE_CFLAGS \"$(OBJECTS_DIR)/\$\${targ}_ctdt.c\" -o \"$(OBJECTS_DIR)/\$\${targ}_ctdt.o\" && \ |
|
28 |
$$QMAKE_LINK $$QMAKE_LFLAGS -X -r5 -r4 \"$(OBJECTS_DIR)/\$\${targ}_ctdt.o\" \"$(TARGET)\" -o \"$(TARGET).munched\" && \ |
|
29 |
mv \"$(TARGET).munched\" \"$(TARGET)\" && \ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
30 |
chmod +x \"$(TARGET)\" |
0 | 31 |
} |
32 |
*-g++ { |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
VXWORKS_MUNCH_CMD = targ=`basename $(TARGET)`; \ |
0 | 34 |
nm \"$(DESTDIR)$(TARGET)\" | tclsh $$VXWORKS_MUNCH_TOOL -c $$VXWORKS_ARCH_MUNCH >\"$(OBJECTS_DIR)/\$\${targ}_ctdt.c\" && \ |
35 |
$$QMAKE_CC -c $$QMAKE_CFLAGS -fdollars-in-identifiers \"$(OBJECTS_DIR)/\$\${targ}_ctdt.c\" -o \"$(OBJECTS_DIR)/\$\${targ}_ctdt.o\" && \ |
|
36 |
$$QMAKE_LINK $$QMAKE_LFLAGS -nostdlib -Wl,-X -T $(WIND_BASE)/target/h/tool/gnu/ldscripts/link.OUT \"$(OBJECTS_DIR)/\$\${targ}_ctdt.o\" \"$(DESTDIR)$(TARGET)\" -o \"$(DESTDIR)$(TARGET).munched\" && \ |
|
37 |
mv \"$(DESTDIR)$(TARGET).munched\" \"$(DESTDIR)$(TARGET)\" && \ |
|
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
38 |
chmod +x \"$(DESTDIR)$(TARGET)\" |
0 | 39 |
} |
40 |
||
41 |
# We need to create a dummy lib.a in case someone links against this lib. |
|
42 |
# In VxWorks it's the responsibility of the run-time linker ld to resolve |
|
43 |
# symbols, since there are no real shared libraries for the toolchain linker |
|
44 |
# to link against. |
|
45 |
||
46 |
shared:contains(TEMPLATE, lib) { |
|
47 |
VXWORKS_MUNCH_CMD += "&&" |
|
48 |
VXWORKS_MUNCH_CMD += (atarg=`basename $(TARGET) .so.$${VERSION}`.a ; touch \"$(DESTDIR)\$\${atarg}\") |
|
49 |
} |
|
50 |
||
37
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
51 |
!isEmpty(QMAKE_POST_LINK):QMAKE_POST_LINK = $$escape_expand(\\n\\t)$$QMAKE_POST_LINK |
758a864f9613
Revision: 201037
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
52 |
QMAKE_POST_LINK = $$VXWORKS_MUNCH_CMD$$QMAKE_POST_LINK |
0 | 53 |
silent:QMAKE_POST_LINK = @echo creating $@.$$VXWORKS_MUNCH_EXT && $$QMAKE_POST_LINK |
54 |
||
55 |
isEmpty(DESTDIR) { |
|
56 |
target.targets += "`basename $(TARGET)`.$$VXWORKS_MUNCH_EXT" |
|
57 |
QMAKE_DISTCLEAN += "`basename $(TARGET)`.$$VXWORKS_MUNCH_EXT" |
|
58 |
} else { |
|
59 |
target.targets += "$(DESTDIR)/`basename $(TARGET)`.$$VXWORKS_MUNCH_EXT" |
|
60 |
QMAKE_DISTCLEAN += "$(DESTDIR)/`basename $(TARGET)`.$$VXWORKS_MUNCH_EXT" |
|
61 |
} |
|
62 |
*-g++:LIBS += -lgcc |
|
63 |
} |
|
64 |