diff --git a/Makefile b/Makefile index b8ef2118..e26ae311 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/tools/Makefile b/tools/Makefile new file mode 100644 index 00000000..d2567eaa --- /dev/null +++ b/tools/Makefile @@ -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 diff --git a/tools/common/elf.h b/tools/common/elf.h index c7c3deab..58c8a0c6 100644 --- a/tools/common/elf.h +++ b/tools/common/elf.h @@ -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 magic; // File identification. be_val fileClass; // File class. be_val encoding; // Data encoding. diff --git a/tools/elf2rpl/Makefile b/tools/elf2rpl/Makefile new file mode 100644 index 00000000..3fc1337e --- /dev/null +++ b/tools/elf2rpl/Makefile @@ -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) diff --git a/tools/elf2rpl/main.cpp b/tools/elf2rpl/main.cpp index a202d231..402d8261 100644 --- a/tools/elf2rpl/main.cpp +++ b/tools/elf2rpl/main.cpp @@ -150,7 +150,7 @@ read(ElfFile &file, const std::string &filename) elf::Header header; in.read(reinterpret_cast(&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;