2

我想修改一个 Makefile 来生成相应的汇编指令。Makefile 和代码存储库位于此处:

https://github.com/swetland/omap4boot

但是,添加-SCFLAGS原语不会产生所需的行为。

我错过了什么?

问候。

简化的 Makefile(省略了一些行)。

what_to_build:: all

-include local.mk

TOOLCHAIN ?= arm-eabi-

BOARD ?= panda

TARGET_CC := $(TOOLCHAIN)gcc
TARGET_LD := $(TOOLCHAIN)ld
TARGET_OBJCOPY := $(TOOLCHAIN)objcopy
TARGET_OBJDUMP := $(TOOLCHAIN)objdump

TARGET_CFLAGS := -g -S -Os  -Wall
TARGET_CFLAGS +=  -march=-march=armv7-a+sec -fno-builtin -ffreestanding
TARGET_CFLAGS += -I. -Iinclude
TARGET_CFLAGS += -include config_$(BOARD).h

TARGET_LIBGCC := $(shell $(TARGET_CC) $(TARGET_CFLAGS) -print-libgcc-file-name)

HOST_CFLAGS := -g -S -O2 -Wall
HOST_CFLAGS += -Itools

OUT := out/$(BOARD)
OUT_HOST_OBJ := $(OUT)/host-obj
OUT_TARGET_OBJ := $(OUT)/target-obj

ALL :=

include build/rules.mk

M_NAME := usbboot
M_OBJS := tools/usbboot.o
M_OBJS += tools/usb_linux.o
M_OBJS += 2ndstage.o
include build/host-executable.mk

M_NAME := mkheader
M_OBJS := tools/mkheader.o
include build/host-executable.mk

M_NAME := bin2c
M_OBJS := tools/bin2c.o
include build/host-executable.mk

M_NAME := aboot
M_BASE := 0x40309000
M_OBJS := arch/omap4/start.o
M_OBJS += arch/omap4/serial.o 


include build/target-executable.mk

$(OUT)/aboot.ift: $(OUT)/aboot.bin $(OUT)/mkheader
@echo generate $@
@./$(OUT)/mkheader $(TEXT_BASE) `wc -c $(OUT)/aboot.bin` > $@
@cat $(OUT)/aboot.bin >> $@
ALL += $(OUT)/aboot.ift

$(OUT_HOST_OBJ)/2ndstage.o: $(OUT)/aboot.bin $(OUT)/bin2c
@echo generate $@
$(QUIET)./$(OUT)/bin2c aboot < $(OUT)/aboot.bin > $(OUT)/2ndstage.c
gcc -c -o $@ $(OUT)/2ndstage.c

clean::
@echo clean
@rm -rf $(OUT)

all:: $(ALL)`
4

2 回答 2

2

从我的 Makefile 中,根据需要进行调整。通常还有 C 部分,因为我主要将 asm 用于文档。我标记了那条线。

$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
        @mkdir -p `dirname $@`
        $(CC) $(CXXFLAGS) -S $< -o $(OBJDIR)/$*.asm $(INCLUDE_PATHS) -masm=intel
        $(CC) $(CXXFLAGS) -c $< -o $@ $(INCLUDE_PATHS)   <--- this is for normal compilation
于 2013-06-07T05:18:27.177 回答
1

-S是传递给编译器以生成汇编代码的正确标志。

您应该确保编译代码的实际规则包括CFLAGS,如下所示:

gcc $(CFLAGS) $@ file.c
于 2013-06-06T12:28:37.400 回答