-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.syms
75 lines (65 loc) · 1.96 KB
/
Makefile.syms
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Utility makefile to generate a helper object 'syms.o'
# who may be linked with CEXP to force the linker adding
# more stuff from the system libraries than needed
# by CEXP itself.
#
# There are two ways of using this.
# 1) you may add object files to OBJLIST. The objects
# in that list are 'modules' intended to be loaded
# by the CEXP application later. The set of all
# undefined symbols referenced by objects in OBJLIST
# is added to 'syms.o'
# 2) you may add system libraries to LIBLIST to add
# all symbols exported by the given libraries to 'syms.o'
#
# The resulting 'syms.o' file must be linked with the
# final CEXP application (e.g. the 'cexp' demo utility)
#
# You may use OBJLIST and LIBLIST at the same time or leave
# either of them empty.
#
# NOTE: in some cases, 'syms.o' may enforce adding parts
# of libraries who reference symbols that are defined
# NOWHERE. This may happen when the respective
# library parts are normally never used but are added
# as a side effect of 'syms.o'.
# In this case, you may have to manually tune the intermediate
# file 'symlist' and remove offending symbols by commenting
# (C-style /**/ comments) them out.
#
# Author: Till Straumann <[email protected]>, 2003/1
#
# CAVEATS: you may need GNU versions of AWK, NM and LD
#
AWK=awk
NM=nm
# add objects searched for undefined symbols
OBJLIST=
# add libraries searched for exported symbols
LIBLIST=
all: syms.o
objsyms: $(OBJLIST)
$(RM) -f $@
ifeq "$(OBJLIST)xxx" "xxx"
touch $@
else
$(NM) -u $(OBJLIST) > $@
endif
libsyms: $(LIBLIST)
$(RM) -f $@
ifeq "$(LIBLIST)xxx" "xxx"
touch $@
else
$(NM) --defined-only -g $(LIBLIST) > $@
endif
symlist: objsyms libsyms
$(RM) -f $@
$(AWK) '/^[^:]+$$/{printf("EXTERN(%s)\n",$$NF);}' $^ | sort | uniq > $@
empty.c:
touch $@
empty.o: empty.c
$(CC) -c -o $@ $<
syms.o: empty.o symlist
$(LD) -T symlist empty.o -o $@
clean::
$(RM) symlist objsyms libsyms empty.c empty.o symlist