source: main/trunk/greenstone2/runtime-src/packages/security/CASCADE-MAKE.sh@ 28863

Last change on this file since 28863 was 28863, checked in by ak19, 10 years ago

Adding the OWASP-ESAPI-for-C and dependent packages and Makefile. The OWASP-ESAPI-for-C package's toplevel Makefile and src and example subfolders' Makefiles have been edited to allow passing in LDFLAGS and installation prefix in order to get compilation working.

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1#!/bin/bash
2
3# Makefile to compile up the OWASP-for-C package after first compiling up its dependencies
4# The OWASP-for-C package:
5# http://code.google.com/p/owasp-esapi-c/
6# http://owasp-esapi-c.googlecode.com/svn/trunk/doc/html/index.html
7# 3 of its Makefiles were changed to get things compiling: top level, src and example folders
8
9# unpack everything
10# (svn checkout owasp-for-c? or commit as a directory to gs?)
11# put uthash/src/* into owasp-for-c/include/.
12# create 'installed' folder
13# compile everything (or at least all the dependencies) into the installed folder, compile owasp
14
15securitydir=`pwd`
16installdir=$securitydir/installed
17
18LIBGPGERROR=libgpg-error-1.12
19LIBGCRYPT=libgcrypt-1.6.1
20LOG4C=log4c-1.2.4
21UTHASH=uthash-master
22OWASPC=gs_owasp-esapi-c_27.02.2014
23# svn checkout http://owasp-esapi-c.googlecode.com/svn/trunk/ owasp-esapi-c-read-only
24
25
26# If doing tarclean: then get rid of all the extracted folders and the installed folder
27if [ "x$1" = "xtarclean" ]; then
28 folders="$LIBGPGERROR $LIBGCRYPT $LOG4C $UTHASH $OWASPC $installdir"
29 for folder in $folders; do
30 if [ -d $folder ]; then
31 rm -rf $folder
32 fi
33 done
34 exit
35fi
36
37
38# make the installed folder
39if [ ! -e $installdir ]; then
40 mkdir $installdir
41fi
42
43
44# UNPACK
45bziplist="$LIBGPGERROR $LIBGCRYPT $OWASPC $UTHASH"
46for bzip in $bziplist; do
47 if test ! -d "$bzip" ; then
48 tar xvjf $bzip.tar.bz2
49 fi
50done
51if test ! -d "$LOG4C" ; then
52 tar xvzf $LOG4C.tar.gz
53fi
54#cp $UTHASH/src/* $OWASPC/include/.
55
56
57# If doing a make clean or distclean
58pkglist=
59if [ "x$1" != "x" ]; then
60 pkglist="$LIBGPGERROR $LIBGCRYPT $OWASPC $LOG4C"
61 for d in $pkglist; do
62 cd $d
63 make $1
64 cd $securitydir
65 done
66 exit 0
67fi
68
69# COMPILE DEPENDENCIES
70# The dependencies of OWASP are LIBGCRYPT, LOG4C and UTHASH.
71# The last is just header files that gets copied over into the src folder
72# LIBGCRYPT is dependent on LIBGPGERROR, so that needs to be compiled up first
73
74pkglist="$LIBGPGERROR $LIBGCRYPT $LOG4C"
75for d in $pkglist; do
76 echo " Compiling $d"
77
78 cd $d
79
80
81 # configure, but only if we haven't already
82 if [ ! -e Makefile ] && [ ! -e config.h ] ; then
83
84 # if we're making static libraries (.a) files in the lib folder, add --disable-shared to the configure step
85 # if we're making .so (shared object files/dlls) in the lib folder, then remove --disable-shared from configure
86
87 if [ "$d" = "$LIBGCRYPT" ]; then
88 ./configure --with-gpg-error-prefix=$installdir --prefix=$installdir --disable-shared
89 else
90 ./configure --prefix=$installdir --disable-shared
91 fi
92 fi
93
94 if [ $? != 0 ] ; then
95 echo "Error encountered when configuring $d"
96 exit 1
97 fi
98
99 # make
100 make
101 if [ $? != 0 ] ; then
102 echo "Error encountered making $d"
103 exit 1
104 fi
105
106 # make install
107 make install
108 if [ $? != 0 ] ; then
109 echo "Error encountered when installing $d"
110 exit 1
111 fi
112
113 cd $securitydir
114done
115
116# COMPILE OWASP ESAPI for C
117echo " Compiling $OWASPC"
118
119cd $OWASPC/
120CFLAGS=-I$installdir/include LDFLAGS=-L$installdir/lib prefix=$installdir make
121CFLAGS=-I$installdir/include LDFLAGS=-L$installdir/lib prefix=$installdir make install
122#CFLAGS=-I$installdir/include LDFLAGS=-L$installdir/lib prefix=$installdir make examples
123cd $securitydir
124
125# To get the OWASP example working, need to compile manually in the example folder,
126# since the above 'make examples' command does not work
127
128# make examples does the following (all on one line):
129
130#/.../security/owasp-esapi-c_27.02.2014/example>cc -I$installdir/include
131#-O0 -g3 -ggdb -DDEBUG=1 -std=c99 -Wall -Wextra -Wno-unused -Wformat=2 -Wformat-security -fstack-protector-all -pedantic -c -static
132#-I../include -I../../include access_ref_example.c -o access_ref_example -L../lib -L$installdir/lib
133#-Wl,-z,nodlopen -Wl,-z,nodldump -Wl,-z,relro -Wl,-z,now
134#-lesapi -lgcrypt -lgpg-error -llog4c
135
136# while the following works (run all on one line):
137
138#/.../security/owasp-esapi-c_27.02.2014/example>cc -I$installdir/include
139#-I../include -I../../include access_ref_example.c -o access_ref_example -L../lib -L$installdir/lib
140#-lesapi -lgcrypt -lgpg-error -llog4c
Note: See TracBrowser for help on using the repository browser.