cd /proj/DTE_releases/latest/cello/cade_A_tools_utils/
zip -r ~/zpm_r35.zip zpm

###########
Linux
###########
Compile on seliiuts02919.seli.gic.ericsson.se or seliiuts03047 or seliiuts02893 to seliiuts02913 or ottlsvr18 (libc 2.11.3) (or seliiuts02929 or sekilx484.wrbs.rnd.ki.sw.ericsson.se or sekilx1260.wrbs.rnd.ki.sw.ericsson.se)

--> module add gcc/4.7.2 && module add make/4.3 && module add glib/2.40.0

Download zlib 1.3.1 from https://zlib.net/zlib-1.3.1.tar.gz and store in /tmp/$USER

--> cd /tmp/$USER && rm -rf zlib-1.3.1 && tar xf zlib-1.3.1.tar.gz && cd /tmp/$USER/zlib-1.3.1 && env CFLAGS="-m32 -O3 -fPIC" ./configure && make
--> cd /tmp/$USER && cp ~/zpm_r35.zip . && rm -rf zpm && unzip zpm_r35.zip && cd zpm && chmod -R 755 .

Edit the file /tmp/$USER/zpm/Makefile :
line 95, replace: INCLUDE      = -I./OSE -I${ZPM} -I${ZDB} -I${SSMINC} -I${TRACE} -I${LLOG}
with:             INCLUDE      = -I./OSE -I${ZPM} -I${ZDB} -I${SSMINC} -I${TRACE} -I${LLOG} -I/tmp/$USER/zlib-1.3.1
line 101, replace:  LIBS         =                   -L${CADE}/tools/gcc/Linux/i686/lib -lz -liberty -L${CADE}/tools/gcc/${NATIVE_OS}/${NATIVE_PROCESSOR}/lib -lc
with:               LIBS         = -L/tmp/$USER/zlib-1.3.1 -L${CADE}/tools/gcc/Linux/i686/lib -lz -liberty -L${CADE}/tools/gcc/${NATIVE_OS}/${NATIVE_PROCESSOR}/lib -lc

--> LFLAGS=-static make release
--> strip zpm

###########
Cygwin:
###########
--> cp ~/zpm_r35.zip /tmp/$USER && cd /tmp/$USER && rm -rf zpm && unzip zpm_r35.zip && cd zpm && chmod -R 755 .
--> Edit the file Makefile and replace the lines
ifeq ($(shell uname -s), CYGWIN_NT-6.0)
with
ifeq ($(shell uname -s), CYGWIN_NT-6.1-WOW64)
--> Edit the file include/bits/endian.h, replace the line "#define __BYTE_ORDER __BIG_ENDIAN" with:
#ifdef __CYGWIN__
#define __BYTE_ORDER __LITTLE_ENDIAN
#else
#define __BYTE_ORDER __BIG_ENDIAN
#endif
--> Edit the file zdb_src/zdb.h, before the line "include <elf.h>", add:
#include <sys/cdefs.h>
#define __CONCAT1(x,y)  x ## y
#define __CONCAT(x,y)   __CONCAT1(x,y)
--> Edit the file zdb_src/zdb_dwarf2.c, before the line "include <elf.h>", add:
#define __CONCAT1(x,y)  x ## y
#define __CONCAT(x,y)   __CONCAT1(x,y)
--> LFLAGS=-static make all
--> strip zpm

FINAL CHECKS:
  1) Check binary file with "ldd zpm" and "file zpm"
  2) Try decoding the file moshell/commonjars/src/zpm/KiRnc115_7339_011300_0x0000054c.pmd with zpm and make sure it does not crash
  3) Try decoding the file moshell/commonjars/src/zpm/46_001200_0x7eebf099.pmd with zpm and make sure it does not go into endless loop
  
