Commit | Line | Data |
---|---|---|
ae1623bb MJ |
1 | BUILD_ID_PREFIX=cd |
2 | BUILD_ID_SUFFIX=d98cdd87f7fe64c13b6daad553987eafd40cbb | |
3 | BUILD_ID=$(BUILD_ID_PREFIX)$(BUILD_ID_SUFFIX) | |
4 | ||
5 | BUILD_DIR ?= build | |
6 | ||
7 | OBJS=$(BUILD_DIR)/dwarf_full/libhello_so \ | |
8 | $(BUILD_DIR)/elf_only/libhello_so \ | |
9 | $(BUILD_DIR)/build_id/libhello_so \ | |
10 | $(BUILD_DIR)/debug_link/libhello_so | |
11 | ||
12 | all: $(OBJS) | |
13 | ||
14 | %.o: %.c | |
15 | $(CC) -gdwarf -fdebug-prefix-map=$(CURDIR)=. -fPIC -c -I. -o $@ $< | |
16 | ||
17 | # Master copy: ELF with DWARF and build-id | |
18 | $(BUILD_DIR)/dwarf_full/libhello_so: tp.o libhello.o | |
19 | mkdir -p $(@D) | |
20 | $(CC) -shared -gdwarf -llttng-ust -ldl -Wl,-soname,libhello.so -Wl,--build-id=0x$(BUILD_ID) -o $@ $^ | |
21 | ||
22 | # ELF only, no debug symbols, no build-d | |
23 | $(BUILD_DIR)/elf_only/libhello_so: $(BUILD_DIR)/dwarf_full/libhello_so | |
24 | mkdir -p $(@D) | |
25 | objcopy -g $< $@.tmp | |
26 | objcopy --remove-section=.note.gnu.build-id $@.tmp | |
27 | mv $@.tmp $@ | |
28 | ||
29 | # ELF with external build-id DWARF | |
30 | $(BUILD_DIR)/build_id/libhello_so: $(BUILD_DIR)/dwarf_full/libhello_so | |
31 | mkdir -p $(@D)/.build-id/$(BUILD_ID_PREFIX) | |
32 | objcopy --only-keep-debug $< $(@D)/.build-id/$(BUILD_ID_PREFIX)/$(BUILD_ID_SUFFIX).debug | |
33 | objcopy -g $< $@ | |
34 | ||
35 | # ELF with external debug link DWARF | |
36 | $(BUILD_DIR)/debug_link/libhello_so: $(BUILD_DIR)/dwarf_full/libhello_so | |
37 | mkdir -p $(@D) | |
38 | objcopy --remove-section=.note.gnu.build-id $< $@.tmp | |
39 | objcopy --only-keep-debug $@.tmp $(@D)/libhello_so.debug | |
40 | objcopy -g $@.tmp | |
41 | cd $(@D) && objcopy --add-gnu-debuglink=libhello_so.debug $(@F).tmp | |
42 | mv $@.tmp $@ | |
43 | ||
44 | clean: | |
45 | rm -f *.o | |
46 | ||
47 | dist-clean: clean | |
48 | rm -rf $(BUILD_DIR) | |
49 | ||
50 | .PHONY: all clean dist-clean |