-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5177de
commit 82ddda3
Showing
10 changed files
with
562 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Normal rules | ||
# | ||
*~ | ||
|
||
# | ||
# Generated files | ||
# | ||
/.obj | ||
/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# | ||
# Top makefile | ||
# | ||
|
||
CROSS ?= arm-none-eabi- | ||
NAME := dump-arm32 | ||
|
||
# | ||
# System environment variable. | ||
# | ||
ifeq ($(OS), Windows_NT) | ||
HOSTOS := windows | ||
else | ||
ifneq (,$(findstring Linux, $(shell uname -a))) | ||
HOSTOS := linux | ||
endif | ||
endif | ||
|
||
# | ||
# Load default variables. | ||
# | ||
ASFLAGS := -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99 | ||
CFLAGS := -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99 | ||
CXXFLAGS := -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding | ||
LDFLAGS := -Wl,-gc-sections -T link.ld -nostartfiles -nostdinc -nostdlib | ||
OCFLAGS := -v -O binary | ||
ODFLAGS := | ||
MCFLAGS := -march=armv7-a -mtune=cortex-a7 -mfpu=vfpv4 -mfloat-abi=softfp -marm -mno-thumb-interwork -mno-unaligned-access -fno-stack-protector | ||
|
||
LIBDIRS := | ||
LIBS := | ||
INCDIRS := | ||
SRCDIRS := | ||
|
||
# | ||
# Add external library | ||
# | ||
INCDIRS += src | ||
SRCDIRS += src | ||
|
||
# | ||
# You shouldn't need to change anything below this point. | ||
# | ||
AS := $(CROSS)gcc -x assembler-with-cpp | ||
CC := $(CROSS)gcc | ||
CXX := $(CROSS)g++ | ||
LD := $(CROSS)ld | ||
AR := $(CROSS)ar | ||
SZ := $(CROSS_COMPILE)size | ||
OC := $(CROSS)objcopy | ||
OD := $(CROSS)objdump | ||
STRIP := $(CROSS_COMPILE)strip | ||
MKDIR := mkdir -p | ||
CP := cp -af | ||
RM := rm -fr | ||
CD := cd | ||
FIND := find | ||
|
||
# | ||
# X variables | ||
# | ||
X_ASFLAGS := $(MCFLAGS) $(ASFLAGS) | ||
X_CFLAGS := $(MCFLAGS) $(CFLAGS) | ||
X_CXXFLAGS := $(MCFLAGS) $(CXXFLAGS) | ||
X_LDFLAGS := $(LDFLAGS) | ||
X_OCFLAGS := $(OCFLAGS) | ||
X_LIBDIRS := $(LIBDIRS) | ||
X_LIBS := $(LIBS) -lgcc | ||
|
||
X_OUT := output | ||
X_NAME := $(patsubst %, $(X_OUT)/%, $(NAME)) | ||
X_INCDIRS := $(patsubst %, -I %, $(INCDIRS)) | ||
X_SRCDIRS := $(patsubst %, %, $(SRCDIRS)) | ||
X_OBJDIRS := $(patsubst %, .obj/%, $(X_SRCDIRS)) | ||
|
||
X_SFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.S)) | ||
X_CFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.c)) | ||
X_CPPFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.cpp)) | ||
|
||
X_SDEPS := $(patsubst %, .obj/%, $(X_SFILES:.S=.o.d)) | ||
X_CDEPS := $(patsubst %, .obj/%, $(X_CFILES:.c=.o.d)) | ||
X_CPPDEPS := $(patsubst %, .obj/%, $(X_CPPFILES:.cpp=.o.d)) | ||
X_DEPS := $(X_SDEPS) $(X_CDEPS) $(X_CPPDEPS) | ||
|
||
X_SOBJS := $(patsubst %, .obj/%, $(X_SFILES:.S=.o)) | ||
X_COBJS := $(patsubst %, .obj/%, $(X_CFILES:.c=.o)) | ||
X_CPPOBJS := $(patsubst %, .obj/%, $(X_CPPFILES:.cpp=.o)) | ||
X_OBJS := $(X_SOBJS) $(X_COBJS) $(X_CPPOBJS) | ||
|
||
VPATH := $(X_OBJDIRS) | ||
|
||
.PHONY: all clean | ||
all : $(X_NAME) | ||
|
||
$(X_NAME) : $(X_OBJS) | ||
@echo [LD] Linking $@.elf | ||
@$(CC) $(X_LDFLAGS) $(X_LIBDIRS) -Wl,--cref,-Map=$@.map $^ -o $@.elf $(X_LIBS) | ||
@echo [OC] Objcopying $@.bin | ||
@$(OC) $(X_OCFLAGS) $@.elf $@.bin | ||
@echo [SZ] Listing $@.elf | ||
@$(SZ) $@.elf | ||
|
||
$(X_SOBJS) : .obj/%.o : %.S | ||
@echo [AS] $< | ||
@$(AS) $(X_ASFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@ | ||
|
||
$(X_COBJS) : .obj/%.o : %.c | ||
@echo [CC] $< | ||
@$(CC) $(X_CFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@ | ||
|
||
$(X_CPPOBJS) : .obj/%.o : %.cpp | ||
@echo [CXX] $< | ||
@$(CXX) $(X_CXXFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@ | ||
|
||
clean: | ||
@$(RM) .obj $(X_OUT) | ||
|
||
# | ||
# Include the dependency files, should be place the last of makefile | ||
# | ||
sinclude $(shell $(MKDIR) $(X_OBJDIRS) $(X_OUT)) $(X_DEPS) |
Oops, something went wrong.