5

我写了一个 Makefile,但我无法让它工作。我有一个选项应该选择要编译到哪个处理器。但是,当我从命令行运行时make,它会说:

tandex@tandex-P-6860FX:~/emulators/nintendo sdks/3DS SDK [HomeBrew]$ make
gcc -march=arm7tdmi -static -fexceptions -fnon-call-exceptions -fstack-check test.c -c
test.c:1:0: error: bad value (arm7tdmi) for -march= switch

make: *** [ALL] Error 1

但是在 gcc 的手册页中,它指出 arm7tdmi 是一个允许的值。我错过了什么吗?

生成文件:

#3DS Compilation Makefile (c) TanDex (TEQ)RunawayFreelancers
#
#Version 0.99 (Alpha) For *nix Devices
#
#Please Check Back Soon for 3rd SDK

#SELECT THE COMPILER TO USE! GCC RECOMMENDED!
#FOR SANITY SAKE, USE C FILES WITH GCC AND CPP FILES WITH G++
CC=gcc
#CC=g++

#OBJECTCOPY REFERENCE, DO NOT REMOVE
OBJC=objcopy
OBJREFS= -O Binary

#SELECT THE PROCESSOR TO TUNE IT TO. ARMV7 (Nintendo DS) or ARMV9(Nintendo DS
(Graphical Support))
#or ARM11 Core ARM1176JZ-S and ARM1176JZF-S (3DS Processor? Not Sure if Correct. Try
and see if they Work?)
#
#NOTE: DS GAMES REQUIRE BOTH A ARM7 AND ARM9 BINARY. RUN THIS TWICE (ONCE FOR EACH)
#
#UNCOMMENT FOR PROCESOR

PROCESSOR=arm7tdmi
#PROCESSOR=arm946e-s
#PROCESSOR=arm1176jz-s
#PROCESSOR=arm1176jzf-s

#FILES
#
#PLACE ALL OF THE FILES HERE, THAT ARE BEING COMPILED!
FILES=test.c

#SET BIN FILE NAME BASED ON PROCESSOR SELECTED
ifeq($(PROCESSOR),arm7tdmi)\
NAME=ARM7.BIN
ifeq($(PROCESSOR), arm946e-s)\
NAME=ARM9.BIN
ifeq($(PROCESSOR), arm1176jz-s)\
NAME=ARM11.BIN
ifeq($(PROCESSOR), arm1176jzf-s)\
NAME=ARM11.BIN

#CREATE OBJECTS
ifeq($(CC), gcc)\
OBJECTS=$(FILES:.c=.o)
ifeq($(CC), g++)\
OBJECTS=$(FILES:.cpp=.o)

#FLAGS! DO NOT CHANGE THESE!!!!!!!!!!! THAT MEANS YOU!!!!!
#
#FOR THOSE WHO WANT TO KNOW WHAT THESE DO, HERE THEY ARE:
#-mtune=$(PROCESSOR)        FORE THE COMPILER TO TUNE OUTPUT TO THE SPECIFIED
PROCESSOR
#-static            REQUIRED FOR CLEAN BINARY OUTPUT?? (NOT SURE WHAT THIS
DOES, BUT WAS SUGESTED ON A POST ON STACKOVERFLOW)
#-fexceptions           FORCE EXCEPTIONS
#-fnon-call-exceptions      FORCE EXCEPTIONS TO ONLY BE RETURNED BY THE SYSTEM
(MEMORY AND FPU INSTRUTIONS FOR EXAMPLE)
#-fstack-check          FORCE STACK CHECKING (DS / 3DS USE AWKWARD STACK
IMPLEMENTATION)
CFLAGS=-march=$(PROCESSOR) -static -fexceptions -fnon-call-exceptions -fstack-check

ALL:
$(CC) $(CFLAGS) $(FILES) -c
.c.o:
$(OBJC) $(OBJREFS) $(OBJECTS) $(NAME)
.cpp.o:
$(OBJC) $(OBJREFS) $(OBJECTS) $(NAME)
4

2 回答 2

5

您可能没有调用正确的 gcc。您似乎在调用系统中安装的 gcc,而不是 3DS SDK 附带的 gcc。

于 2012-12-10T02:44:48.533 回答
1

看来问题出在-march=arm7tdmi.

我认为解决方法是避免使用-march=arm7tdmi; 和 use -march=cpu-type,其中是GCC 手册的3.17.4 ARM Optionscpu-type中列出的选项之一。

这是页面的一部分:

-march=名字

这指定了目标 ARM 体系结构的名称。GCC 使用这个名称来确定它在生成汇编代码时可以发出什么样的指令。此选项可以与 -mcpu= 选项一起使用或代替 -mcpu= 选项。允许的名称有:'armv2'、'armv2a'、'armv3'、'armv3m'、'armv4'、'armv4t'、'armv5'、'armv5t'、'armv5e'、'armv5te'、'armv6'、'armv6j '、'armv6t2'、'armv6z'、'armv6kz'、'armv6-m'、'armv7'、'armv7-a'、'armv7-r'、'armv7-m'、'armv7e-m'、'armv7ve '、'armv8-a'、'armv8-a+crc'、'iwmmxt'、'iwmmxt2'、'ep9312'。

于 2015-07-31T10:06:42.910 回答