18 include $(EPOCROOT)/build/makefiles-garage/global-make-env.mk |
18 include $(EPOCROOT)/build/makefiles-garage/global-make-env.mk |
19 else |
19 else |
20 $(error EPOCROOT must be defined as the parent directory of your epoc32 tree) |
20 $(error EPOCROOT must be defined as the parent directory of your epoc32 tree) |
21 endif |
21 endif |
22 |
22 |
23 todo_target = seclib |
23 cpp_inc_paths = \ |
24 include $(EPOCROOT)/build/makefiles-garage/todo.mk |
24 -I ../readimage/inc \ |
25 all: todo |
25 -I ../rofsbuild \ |
|
26 -I../rombuild \ |
|
27 -I ../../imglib/compress \ |
|
28 -I ../../imglib/patchdataprocessor/include \ |
|
29 -I ../../sisutils/inc \ |
|
30 -I ../../imglib/inc |
|
31 |
|
32 lib_opts = -lboost_thread-mt \ |
|
33 -L../../sisutils -lsisutils \ |
|
34 |
|
35 exe = readimage |
|
36 |
|
37 CPPFLAGS = $(cpp_inc_paths) $(global_cpp_flags) -D__SUPPORT_ELF_FILES__ |
|
38 CXXFLAGS = $(global_cxx_flags) -pthread |
|
39 LDFLAGS = $(lib_opts) $(global_ld_flags) |
|
40 |
|
41 prereqs = sisutils rombuild rofsbuild patchdataprocessor |
|
42 |
|
43 srcs = \ |
|
44 src/common.cpp \ |
|
45 src/e32_image_reader.cpp \ |
|
46 src/image_handler.cpp \ |
|
47 src/image_reader.cpp \ |
|
48 src/rofs_image_reader.cpp \ |
|
49 src/rom_image_reader.cpp \ |
|
50 ../../imglib/e32uid/e32uid.cpp \ |
|
51 ../../imglib/host/h_file.cpp \ |
|
52 ../../imglib/host/h_mem.cpp \ |
|
53 ../../imglib/host/h_utl.cpp \ |
|
54 ../rofsbuild/r_build.cpp \ |
|
55 ../rofsbuild/r_coreimage.cpp \ |
|
56 ../rombuild/r_global.cpp \ |
|
57 ../../imglib/e32image/e32image.cpp \ |
|
58 ../../imglib/e32image/deflate/decode.cpp \ |
|
59 ../../imglib/e32image/deflate/encode.cpp \ |
|
60 ../../imglib/e32image/deflate/deflate.cpp \ |
|
61 ../../imglib/e32image/deflate/inflate.cpp \ |
|
62 ../../imglib/e32image/deflate/panic.cpp \ |
|
63 ../../imglib/e32image/deflate/compress.cpp \ |
|
64 ../../imglib/compress/pagedcompress.cpp \ |
|
65 ../../imglib/compress/byte_pair.cpp \ |
|
66 ../../imglib/patchdataprocessor/source/patchdataprocessor.cpp |
|
67 |
|
68 fixfiles = inc/image_reader.h src/image_reader.cpp src/rofs_image_reader.cpp src/rom_image_reader.cpp |
|
69 |
|
70 fixbackups = $(addsuffix .original,$(fixfiles)) |
|
71 |
|
72 .PHONY: all clean $(prereqs) fixes remove_fixes |
|
73 |
|
74 all: $(exe) |
|
75 |
|
76 $(srcs): fixes |
|
77 |
|
78 bases = $(basename $(srcs)) |
|
79 |
|
80 objs = $(addsuffix .o,$(bases)) |
|
81 |
|
82 $(prereqs): $(global_prereqs) |
|
83 $(MAKE) -C $(EPOCROOT)/build $@ |
|
84 |
|
85 $(objs): $(prereqs) |
|
86 |
|
87 $(exe): $(objs) |
|
88 $(CC) -o $@ $(objs) $(LDFLAGS) |
|
89 |
|
90 fixes:: $(fixbackups) |
|
91 |
|
92 clean: remove_fixes |
|
93 rm -f $(objs) $(exe) |
|
94 |
|
95 inc/image_reader.h.original: |
|
96 cp $(basename $@) $@ && \ |
|
97 sed -e 's|^#include <direct.h>||g' -i $(basename $@) |
|
98 |
|
99 src/image_reader.cpp.original: |
|
100 cp $(basename $@) $@ && \ |
|
101 sed -e 's|_getcwd|GETCWD|g' -e 's|_chdir|CHDIR|g' -e 's|_mkdir|MKDIR|g' -e '/^#include "image_reader.h"/a\ |
|
102 #if defined(_WIN32)\ |
|
103 #include <direct.h>\ |
|
104 #define GETCWD _getcwd\ |
|
105 #define MKDIR _mkdir\ |
|
106 #define CHDIR _chdir\ |
|
107 #elif defined(__LINUX__)\ |
|
108 #include <unistd.h>\ |
|
109 #include <sys/stat.h>\ |
|
110 #define GETCWD getcwd\ |
|
111 #define MKDIR(d) mkdir(d,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)\ |
|
112 #define CHDIR chdir\ |
|
113 #else\ |
|
114 #error Target OS not defined\ |
|
115 #endif' -i -i $(basename $@) |
|
116 |
|
117 src/rofs_image_reader.cpp.original: |
|
118 cp $(basename $@) $@ && \ |
|
119 sed -e 's|iInputFile->seekg(aOff, aStartPos);|iInputFile->seekg(aOff, SEEKDIR(aStartPos));|g' -e '/^#include "e32_image_reader.h"/a\ |
|
120 #if defined(_WIN32)\ |
|
121 #define SEEKDIR(pos) pos\ |
|
122 #elif defined(__LINUX__)\ |
|
123 #define SEEKDIR(pos) std::_Ios_Seekdir(pos)\ |
|
124 #else\ |
|
125 #error Target OS not defined\ |
|
126 #endif' -i -i $(basename $@) |
|
127 |
|
128 src/rom_image_reader.cpp.original: |
|
129 cp $(basename $@) $@ && \ |
|
130 sed -e 's|_alloca|ALLOCA|g' -e '/#include "r_rom.h"/a\ |
|
131 #if defined(_WIN32)\ |
|
132 #define ALLOCA _alloca\ |
|
133 #elif defined(__LINUX__)\ |
|
134 #include <alloca.h>\ |
|
135 #define ALLOCA alloca\ |
|
136 #else\ |
|
137 #error Target OS not defined\ |
|
138 #endif' -i -i $(basename $@) |
|
139 |
|
140 |
|
141 remove_fixes: |
|
142 for file in $(fixbackups); do if [ -f $$file ]; then mv -f $$file $${file%\.original}; fi; done |
|
143 |