Skip to content

Commit

Permalink
Improve makefile. More generic, data folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillem96 committed Dec 29, 2018
1 parent a049c30 commit a257385
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 50 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@

# Build files
build/
output/
output/
logo_bmp.h
91 changes: 42 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,71 +10,62 @@ BLVERSION_MINOR := 1
BUILD := build
OUTPUT := output
SOURCEDIR := src
DATA := data
SOURCES := src \
src/core \
src/ianos \
src/gfx \
src/libs/fatfs src/libs/elfload src/libs/compr \
src/mem \
src/menu/gui \
src/minerva \
src/panic \
src/power \
src/sec \
src/soc \
src/storage \
src/utils
INCLUDES := include
VPATH = $(dir $(wildcard ./$(SOURCEDIR)/*/)) $(dir $(wildcard ./$(SOURCEDIR)/*/*/))

OBJS = $(addprefix $(BUILD)/$(TARGET)/, \
start.o \
main.o \
btn.o \
clock.o \
cluster.o \
fuse.o \
gpio.o \
heap.o \
launcher.o \
i2c.o \
max7762x.o \
max17050.o \
mc.o \
sdmmc.o \
sdmmc_driver.o \
sdram.o \
fs_utils.o \
util.o \
di.o \
gfx.o \
pinmux.o \
se.o \
uart.o \
hw_init.o \
dirlist.o \
smmu.o \
panic.o \
gui_argon_menu.o \
gui_menu.o \
gui_menu_entry.o \
gui_menu_pool.o \
payloads.o \
minerva.o \
ianos.o \
)

OBJS += $(addprefix $(BUILD)/$(TARGET)/, \
lz.o blz.o \
diskio.o ff.o ffunicode.o ffsystem.o \
elfload.o elfreloc_arm.o \
)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))

OFILES_BIN := $(addsuffix .o,$(BINFILES))
OFILES_SRC := $(SFILES:.s=.o) $(CFILES:.c=.o)
HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))

OBJS = $(addprefix $(BUILD)/$(TARGET)/, $(OFILES_BIN) $(OFILES_SRC))


INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(BUILD)/$(TARGET)

ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
CFLAGS = $(INCLUDE) $(ARCH) -O2 -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections

export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)

.PHONY: all clean

all: $(TARGET).bin
all: directories $(TARGET).bin
@echo $(HFILES_BIN)
@echo -n "Payload size is "
@wc -c < $(OUTPUT)/$(TARGET).bin
@echo "Max size is 126296 Bytes."

directories:
@mkdir -p "$(BUILD)"
@mkdir -p "$(BUILD)/$(TARGET)"
@mkdir -p "$(OUTPUT)"

clean:
@rm -rf $(OBJS)
@rm -rf $(BUILD)
@rm -rf $(OUTPUT)
@rm -rf logo_bmp.h

$(MODULEDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS)
Expand All @@ -90,8 +81,10 @@ $(BUILD)/$(TARGET)/%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@

$(BUILD)/$(TARGET)/%.o: %.s
@mkdir -p "$(BUILD)"
@mkdir -p "$(BUILD)/$(TARGET)"
@mkdir -p "$(OUTPUT)"
$(CC) $(CFLAGS) -c $< -o $@

$(OFILES_SRC) : $(HFILES_BIN)

$(BUILD)/$(TARGET)/%.bmp.o %_bmp.h: data/%.bmp
@echo $(notdir $<)
@$(bin2o)
Binary file added data/logo.bmp
Binary file not shown.

0 comments on commit a257385

Please sign in to comment.