我想修改Makefile以生成相应的汇编指令。 Makefile和代码库位于:
https://github.com/swetland/omap4boot
但是,将-S
添加到CFLAGS
原语不会产生所需的行为。
我错过了什么?
问候。
Simplified 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)`
答案 0 :(得分: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
答案 1 :(得分:1)
-S
是传递给编译器生成汇编代码的正确标志。
您应该确保编译代码的实际规则包括CFLAGS
,如下所示:
gcc $(CFLAGS) $@ file.c