Skip to content

Commit

Permalink
Makefile: generate binary with debug symbols and without
Browse files Browse the repository at this point in the history
Instead of generating a final binary with debug symbols and stripping
them out to additional file, just copy the final binary to the final
target destination (kernel64.bin) and strip the file.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Nov 13, 2023
1 parent f5644f1 commit 45e84a3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,21 @@ endif
$(PREP_LINK_SCRIPT) : $(LINK_SCRIPT)
$(VERBOSE) $(CC) $(AFLAGS) -E -P -C -x c $< -o $@

$(TARGET): $(OBJS) $(PREP_LINK_SCRIPT)
$(TARGET_DEBUG): $(OBJS) $(PREP_LINK_SCRIPT)
@echo "LD " $@
$(VERBOSE) $(LD) -T $(PREP_LINK_SCRIPT) -o $@ $(OBJS) $(PFMLIB_LINKER_FLAGS)
@echo "GEN " $(SYMBOLS_NAME).S
$(VERBOSE) $(NM) -p --format=posix $(TARGET) | $(PYTHON) $(SYMBOLS_DIR)/$(SYMBOLS_TOOL)
$(VERBOSE) $(NM) -p --format=posix $@ | $(PYTHON) $(SYMBOLS_DIR)/$(SYMBOLS_TOOL)
@echo "CC " $(SYMBOLS_NAME).S
$(VERBOSE) $(CC) -c -o $(SYMBOLS_NAME).o $(AFLAGS) $(SYMBOLS_NAME).S
$(VERBOSE) rm -rf $(SYMBOLS_NAME).S
@echo "LD " $(TARGET) $(SYMBOLS_NAME).o
@echo "LD " $@ $(SYMBOLS_NAME).o
$(VERBOSE) $(LD) -T $(PREP_LINK_SCRIPT) -o $@ $(OBJS) $(PFMLIB_LINKER_FLAGS) $(SYMBOLS_NAME).o

$(TARGET): $(TARGET_DEBUG)
@echo "STRIP"
$(VERBOSE) $(OBJCOPY) --only-keep-debug $(TARGET) $(TARGET_DEBUG)
$(VERBOSE) $(STRIP) $(STRIP_OPTS) $(TARGET)
$(VERBOSE) cp $< $@
$(VERBOSE) $(STRIP) $(STRIP_OPTS) $@

$(PFMLIB_ARCHIVE): $(PFMLIB_TARBALL)
@echo "UNTAR libpfm"
Expand Down Expand Up @@ -242,7 +244,7 @@ clean:
$(VERBOSE) find $(PFMLIB_DIR) -mindepth 1 ! -name $(PFMLIB_NAME)-$(PFMLIB_VER).tar.gz -delete
$(VERBOSE) $(RM) -f $(ASM_OFFSETS_H) $(ASM_OFFSETS_S)
$(VERBOSE) $(RM) -rf $(ACPICA_DEST_DIR)/source
$(VERBOSE) $(RM) -f $(TARGET_DEBUG)
$(VERBOSE) $(RM) -f $(TARGET_DEBUG) $(TARGET)
$(VERBOSE) $(RM) -rf $(GRUB_DIR)

# Check whether we can use kvm for qemu
Expand Down Expand Up @@ -277,11 +279,11 @@ $(ISO_FILE): dockerboot.iso
else
$(ISO_FILE): $(TARGET)
@echo "GEN ISO" $(ISO_FILE)
$(VERBOSE) $(GRUB_FILE) --is-x86-multiboot2 $(TARGET) || { echo "Multiboot not supported"; exit 1; }
$(VERBOSE) $(GRUB_FILE) --is-x86-multiboot2 $< || { echo "Multiboot not supported"; exit 1; }
$(VERBOSE) $(RM) -rf $(GRUB_DIR) && mkdir -p $(GRUB_DIR)/grub
$(VERBOSE) cp $(TARGET) $(GRUB_DIR)/
$(VERBOSE) cp $< $(GRUB_DIR)/
$(VERBOSE) cp $(GRUB_CONFIG) $(GRUB_DIR)/grub/grub.cfg
$(VERBOSE) $(XZ) -q -f $(GRUB_DIR)/$(TARGET)
$(VERBOSE) $(XZ) -q -f $(GRUB_DIR)/$<
$(VERBOSE) $(GRUB_MKRESCUE) --install-modules="$(GRUB_MODULES)" --fonts=no --compress=xz -o $(ISO_FILE) grub &> /dev/null
endif

Expand Down

0 comments on commit 45e84a3

Please sign in to comment.