7 if [ "X${ARGV}" = "X" ]; then
9 echo "No argument. Available options are:"
20 # Increasing maximum number of agents
21 if [ "X$1" = "Xsetmaxagents" ]; then
22 echo -n "Specify maximum number of agents: ";
24 echo "HEXTRA=-DMAX_AGENTS=$AGMAX" >> ./Config.OS
25 echo "Maximum number of agents set to $AGMAX."
30 CJSONV="external/cJSON/"
38 VERSION=`cat ./VERSION`
41 # Libraries. They need to be compiled before.
42 LIBS="os_xml os_regex os_net os_crypto"
44 SOURCES="shared config"
46 BINARIES="os_maild os_dbd os_csyslogd agentlessd os_execd analysisd logcollector remoted client-agent addagent util rootcheck syscheckd monitord os_auth"
47 ROOTCHECKBIN="rootcheck"
48 DIRECTORIES="" # Directories to make
52 if [ "X$OS" = "XSunOS" ]; then
53 PATH=$PATH:/usr/ccs/bin:/usr/xpg4/bin:/opt/csw/gcc3/bin:/opt/csw/bin:/usr/sfw/bin
59 if [ "X${ARGV}" = "Xall" -o "X${ARGV}" = "Xtest" -o "X${ARGV}" = "Xrootcheck" -o "X${ARGV}" = "Xlibs" ]; then
60 ls ./Config.OS >/dev/null 2>&1
65 # Checking for OpenSSLconf.h
66 if [ -e /usr/include/openssl/opensslconf.h ]; then
67 echo "DEXTRA=-DUSE_OPENSSL" >> Config.OS
68 echo "OPENSSLCMD=-lssl -lcrypto" >> Config.OS
69 elif [ -e /usr/include/openssl/conf.h ]; then
70 echo "DEXTRA=-DUSE_OPENSSL" >> Config.OS
71 echo "OPENSSLCMD=-lssl -lcrypto" >> Config.OS
74 # Checking for inotify
75 if [ "X$OS" = "XLinux" ]; then
76 if [ -e /usr/include/sys/inotify.h ]; then
77 echo "EEXTRA=-DUSEINOTIFY" >> Config.OS
78 elif [ -e /usr/include/linux/inotify.h ]; then
79 echo "EEXTRA=-DUSEINOTIFY" >> Config.OS
84 # Checking for libmagic
85 if [ "X$SYSCHECK" = "Xyes" ]; then
86 if [ -e /usr/include/linux/magic.h ]; then
87 echo "MEXTRA=-DUSE_MAGIC" >> Config.OS
88 echo "MAGICCMD=-lmagic" >> Config.OS
89 elif [ -e /usr/include/magic.h ]; then
90 echo "MEXTRA=-DUSE_MAGIC" >> Config.OS
91 echo "MAGICCMD=-lmagic" >> Config.OS
95 if [ "X$OS" = "XAIX" ]; then
96 echo "EEXTRA=-DAIX -DHIGHFIRST" >> Config.OS
97 PATH=$PATH:/usr/vac/bin
100 elif [ "X$OS" = "XSunOS" ]; then
101 # Set CPU optimization for Sun UltraSparc
102 # by Eric Straavaldsen
103 # Disabled by default. To enable it, just uncomment the following
104 # lines and comment the EEXTRA below.
106 #if [ $PROC = sparcv9 ]; then
107 # echo "EEXTRA=-lsocket -lnsl -lresolv -DSOLARIS -DHIGHFIRST -O3 -mcpu=ultrasparc">>Config.OS
109 echo "EEXTRA=-DSOLARIS -DHIGHFIRST">>Config.OS
110 echo "IEXTRA=-lsocket -lnsl -lresolv" >> Config.OS
113 elif [ "X$OS" = "XHP-UX" ]; then
114 echo "EEXTRA=-DHPUX -D_XOPEN_SOURCE_EXTENDED -DHIGHFIRST -D_REENTRANT" >> Config.OS
116 elif [ "X$OS" = "XDarwin" ]; then
117 echo "EEXTRA=-DDarwin -DHIGHFIRST" >> Config.OS
120 elif [ "X$OS" = "XFreeBSD" ]; then
121 echo "EEXTRA=-DFreeBSD" >> Config.OS
126 echo 'int main() { short one = 1; char *cp = (char*)&one; if ( *cp == 0 ) return(1); else return(0); }' > isbigendian.c
127 cc -o isbigendian isbigendian.c
130 echo "INFO: Big endian set."
131 echo "GEXTRA=-DHIGHFIRST" >> Config.OS
133 echo "INFO: Little endian set."
138 if [ "X$OS" = "XFreeBSD" -o "X$OS" = "XDragonFly" ]; then
139 echo "TEXTRA=-pthread" >> Config.OS
141 echo "TEXTRA=-lpthread" >> Config.OS
147 if [ "X${ARGV}" = "Xclean" ]; then
148 echo "" > ./Config.OS
151 # Getting values for each action
152 if [ "X${ARGV}" = "Xall" ]; then
153 DIRECTORIES="${LIBS} ${SOURCES} ${BINARIES}"
157 elif [ "X${ARGV}" = "Xtest" ]; then
158 DIRECTORIES="${LIBS} ${SOURCES}"
162 elif [ "X${ARGV}" = "Xlibs" ]; then
163 DIRECTORIES="${LIBS} ${SOURCES}"
167 elif [ "X${ARGV}" = "Xrootcheck" ]; then
168 DIRECTORIES="os_xml os_regex os_net ${SOURCES} ${ROOTCHECKBIN}"
169 elif [ "X${ARGV}" = "Xbuild" ]; then
170 DIRECTORIES="${BINARIES}" # Only binaries need to be built
172 DIRECTORIES="${LIBS} ${SOURCES} ${BINARIES}"
176 if [ "X${DOZLIB}" = "Xx" ]; then
179 echo " *** Making zlib (by Jean-loup Gailly and Mark Adler) *** "
180 cd external/; make zlib;
183 echo "Error Making zlib"
190 if [ "X${DOCJSON}" = "Xx" ]; then
193 echo " *** Making cJSON (by Dave Gamble) *** "
194 cd ${CJSONV}; make ossec;
197 echo "Error Making cJSON"
204 if [ "X${DO_LUA}" = "Xx" ]; then
207 echo " *** Making Lua 5.2 (by team at PUC-Rio in Brazi) *** "
208 echo " Copyright © 1994–2014 Lua.org, PUC-Rio. "
209 cd ${LUAV}; make ${LUA_PLAT};
212 echo "Error Making cJSON"
219 if [ "X${ARGV}" = "Xclean" ]; then
221 cd external/; make clean;
223 cd ${CJSONV}; make clean;
225 cd ${LUAV}; make clean;
227 cd tests/; make clean;
231 # Make and run tests if intended
232 if [ "X${ARGV}" = "Xtest" ]; then
238 # Checking if the bin directory is present
239 if [ ! "X${ARGV}" = "Xrootcheck" ]; then
240 ls ../bin >/dev/null 2>&1
245 echo "Compiling Rootcheck..."
251 # Making each directory
252 for i in ${DIRECTORIES}; do
256 echo "Error acessing directory $i"
259 if [ "X${ARGV}" = "Xclean" ]; then
262 elif [ "X${ARGV}" = "Xbuild" ]; then
266 echo "Error Making the binaries"
269 elif [ "X${ARGV}" = "Xrootcheck" ]; then
271 if [ $i = "rootcheck" ]; then
278 echo "Error Making $i"
284 echo " *** Making $i *** "
289 echo "Error Making $i"
296 if [ "X${ARGV}" = "Xrootcheck" ]; then
297 cp -pr ./rootcheck/ossec-rootcheck ../
298 cp -pr ./rootcheck/db ../
299 cp -pr ./rootcheck/rootcheck.conf ../
301 echo "Rootcheck compilation completed."
302 echo "Just run './ossec-rootcheck' to execute it."