Update makefile for elf2rpl

This commit is contained in:
James Benton 2016-01-04 05:46:52 -08:00
parent 44225e4c28
commit e781efe156
5 changed files with 73 additions and 14 deletions

View File

@ -1,5 +1,5 @@
WUT_ROOT := $(CURDIR)
TARGETS := crt rpl
TARGETS := crt rpl tools
all:
@for dir in $(TARGETS); do \
@ -8,18 +8,12 @@ all:
$(MAKE) --no-print-directory -C $$dir; \
echo "Leaving Directory $$dir"; \
done
ifeq ($(OS),Windows_NT)
@echo "Please build tools with make-tools.bat"
else
@echo \
@echo "Entering Directory tools"
@$(MAKE) --no-print-directory -C tools
@echo "Leaving Directory tools"
endif
clean:
@rm -rf lib
@rm -rf bin
@for dir in $(TARGETS); do \
echo; \
echo Cleaning $$dir; \
$(MAKE) --no-print-directory -C $$dir clean; \
done
@ -28,9 +22,9 @@ install:
@mkdir -p bin
@mkdir -p lib
@for dir in $(TARGETS); do \
echo; \
echo Installing $$dir; \
$(MAKE) --no-print-directory -C $$dir install; \
done
@cp tools/bin/* bin/
.PHONY: all clean install

38
tools/Makefile Normal file
View File

@ -0,0 +1,38 @@
.SUFFIXES:
WUT_ROOT := $(CURDIR)/..
TARGETS := elf2rpl
ifeq ($(OS),Windows_NT)
all:
@echo "Please build tools with make-tools.bat"
install:
@echo "Please build tools with make-tools.bat"
clean:
@echo "Please build tools with make-tools.bat"
else
all:
@for dir in $(TARGETS); do \
echo; \
echo Entering Directory $$dir; \
$(MAKE) --no-print-directory -C $$dir; \
echo Leaving Directory $$dir; \
done
clean:
@for dir in $(TARGETS); do \
echo Cleaning $$dir; \
$(MAKE) --no-print-directory -C $$dir clean; \
done
install: all
@mkdir -p $(WUT_ROOT)/bin
@for dir in $(TARGETS); do \
echo Installing $$dir; \
cp $$dir/$$dir $(WUT_ROOT)/bin; \
done
endif
.PHONY: all install clean

View File

@ -192,10 +192,10 @@ enum RplFileInfoFlag : uint32_t
RPL_IS_RPX = 0x2,
};
static const unsigned HeaderMagic = 0x7f454c46;
struct Header
{
static const unsigned Magic = 0x7f454c46;
be_val<uint32_t> magic; // File identification.
be_val<uint8_t> fileClass; // File class.
be_val<uint8_t> encoding; // Data encoding.

27
tools/elf2rpl/Makefile Normal file
View File

@ -0,0 +1,27 @@
WUT_ROOT := $(CURDIR)/../..
TARGET := elf2rpl
SOURCE := .
INCLUDE := ../common
CXX := g++
CFILES := $(foreach dir,$(SOURCE),$(wildcard $(dir)/*.cpp))
INCLUDES := $(foreach dir,$(INCLUDE),-I$(dir))
CFLAGS := -O2 -Wall --std=c++14
LDFLAGS :=
all: $(TARGET)
clean:
@echo "[RM] $(notdir $(TARGET))"
@rm -rf $(TARGET)
install: all
@echo Installing $(TARGET)
@cp elf2rpl $(WUT_ROOT)/bin/elf2rpl
$(TARGET): $(CFILES)
@echo "[CXX] $(notdir $<)"
@$(CXX) $(CFLAGS) $(INCLUDES) $< -o $@ $(LDFLAGS)

View File

@ -150,7 +150,7 @@ read(ElfFile &file, const std::string &filename)
elf::Header header;
in.read(reinterpret_cast<char *>(&header), sizeof(elf::Header));
if (header.magic != elf::Header::Magic) {
if (header.magic != elf::HeaderMagic) {
std::cout << "Invalid ELF magic header" << std::endl;
return false;
}
@ -922,7 +922,7 @@ write(ElfFile &file, const std::string &filename)
}
elf::Header header;
header.magic = elf::Header::Magic;
header.magic = elf::HeaderMagic;
header.fileClass = 1;
header.encoding = elf::ELFDATA2MSB;
header.elfVersion = elf::EV_CURRENT;