--- a/makefiles-garage/imgtools/romtools/readimage/Makefile Mon Nov 16 10:04:44 2009 +0000
+++ b/makefiles-garage/imgtools/romtools/readimage/Makefile Fri Jan 08 16:16:51 2010 +0000
@@ -20,6 +20,124 @@
$(error EPOCROOT must be defined as the parent directory of your epoc32 tree)
endif
-todo_target = seclib
-include $(EPOCROOT)/build/makefiles-garage/todo.mk
-all: todo
+cpp_inc_paths = \
+-I ../readimage/inc \
+-I ../rofsbuild \
+-I../rombuild \
+-I ../../imglib/compress \
+-I ../../imglib/patchdataprocessor/include \
+-I ../../sisutils/inc \
+-I ../../imglib/inc
+
+lib_opts = -lboost_thread-mt \
+-L../../sisutils -lsisutils \
+
+exe = readimage
+
+CPPFLAGS = $(cpp_inc_paths) $(global_cpp_flags) -D__SUPPORT_ELF_FILES__
+CXXFLAGS = $(global_cxx_flags) -pthread
+LDFLAGS = $(lib_opts) $(global_ld_flags)
+
+prereqs = sisutils rombuild rofsbuild patchdataprocessor
+
+srcs = \
+src/common.cpp \
+src/e32_image_reader.cpp \
+src/image_handler.cpp \
+src/image_reader.cpp \
+src/rofs_image_reader.cpp \
+src/rom_image_reader.cpp \
+../../imglib/e32uid/e32uid.cpp \
+../../imglib/host/h_file.cpp \
+../../imglib/host/h_mem.cpp \
+../../imglib/host/h_utl.cpp \
+../rofsbuild/r_build.cpp \
+../rofsbuild/r_coreimage.cpp \
+../rombuild/r_global.cpp \
+../../imglib/e32image/e32image.cpp \
+../../imglib/e32image/deflate/decode.cpp \
+../../imglib/e32image/deflate/encode.cpp \
+../../imglib/e32image/deflate/deflate.cpp \
+../../imglib/e32image/deflate/inflate.cpp \
+../../imglib/e32image/deflate/panic.cpp \
+../../imglib/e32image/deflate/compress.cpp \
+../../imglib/compress/pagedcompress.cpp \
+../../imglib/compress/byte_pair.cpp \
+../../imglib/patchdataprocessor/source/patchdataprocessor.cpp
+
+fixfiles = inc/image_reader.h src/image_reader.cpp src/rofs_image_reader.cpp src/rom_image_reader.cpp
+
+fixbackups = $(addsuffix .original,$(fixfiles))
+
+.PHONY: all clean $(prereqs) fixes remove_fixes
+
+all: $(exe)
+
+$(srcs): fixes
+
+bases = $(basename $(srcs))
+
+objs = $(addsuffix .o,$(bases))
+
+$(prereqs): $(global_prereqs)
+ $(MAKE) -C $(EPOCROOT)/build $@
+
+$(objs): $(prereqs)
+
+$(exe): $(objs)
+ $(CC) -o $@ $(objs) $(LDFLAGS)
+
+fixes:: $(fixbackups)
+
+clean: remove_fixes
+ rm -f $(objs) $(exe)
+
+inc/image_reader.h.original:
+ cp $(basename $@) $@ && \
+ sed -e 's|^#include <direct.h>||g' -i $(basename $@)
+
+src/image_reader.cpp.original:
+ cp $(basename $@) $@ && \
+ sed -e 's|_getcwd|GETCWD|g' -e 's|_chdir|CHDIR|g' -e 's|_mkdir|MKDIR|g' -e '/^#include "image_reader.h"/a\
+#if defined(_WIN32)\
+#include <direct.h>\
+#define GETCWD _getcwd\
+#define MKDIR _mkdir\
+#define CHDIR _chdir\
+#elif defined(__LINUX__)\
+#include <unistd.h>\
+#include <sys/stat.h>\
+#define GETCWD getcwd\
+#define MKDIR(d) mkdir(d,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)\
+#define CHDIR chdir\
+#else\
+#error Target OS not defined\
+#endif' -i -i $(basename $@)
+
+src/rofs_image_reader.cpp.original:
+ cp $(basename $@) $@ && \
+ sed -e 's|iInputFile->seekg(aOff, aStartPos);|iInputFile->seekg(aOff, SEEKDIR(aStartPos));|g' -e '/^#include "e32_image_reader.h"/a\
+#if defined(_WIN32)\
+#define SEEKDIR(pos) pos\
+#elif defined(__LINUX__)\
+#define SEEKDIR(pos) std::_Ios_Seekdir(pos)\
+#else\
+#error Target OS not defined\
+#endif' -i -i $(basename $@)
+
+src/rom_image_reader.cpp.original:
+ cp $(basename $@) $@ && \
+ sed -e 's|_alloca|ALLOCA|g' -e '/#include "r_rom.h"/a\
+#if defined(_WIN32)\
+#define ALLOCA _alloca\
+#elif defined(__LINUX__)\
+#include <alloca.h>\
+#define ALLOCA alloca\
+#else\
+#error Target OS not defined\
+#endif' -i -i $(basename $@)
+
+
+remove_fixes:
+ for file in $(fixbackups); do if [ -f $$file ]; then mv -f $$file $${file%\.original}; fi; done
+