OSDN Git Service

Ver.1.5.34 Fixed CLang warning and others
[opengate/opengate.git] / opengate / opengatesrv / Makefile
index 0a00ae4..d9eb978 100644 (file)
@@ -2,14 +2,32 @@
 ##  must be matched to descriptions in html files ########
 ##  some other parameters exist in opengatesrv.h  ########
 ##########################################################
-HTMLTOP = /usr/local/www/data
-DOCPATH = /usr/local/www/data/opengate
-CGIPATH = /usr/local/www/cgi-bin/opengate
+WWWTOP = /usr/local/www/apache24
+DOCDIR = /data
+CGIDIR = /cgi-bin
+OPENGATEDIR = /opengate
 CONFIGPATH = /etc/opengate
+LOCKFILE = /tmp/opengate.lock
 
-CFLAGS= 
-LIBS = -lssl -lcrypto -lradius -lpam -lezxml -L../ezxml
-OBJS = utilities.o comm-auth.o comm-cgi.o comm-java.o comm-ipfw.o comm-ip6fw.o comm-arp.o comm-ndp.o error.o tcp_connect.o sock_ntop_host.o wrapper.o signal.o auth-pam.o auth-rad.o auth-pop3s.o comm-userdb.o get-param.o auth-ftps.o htmltemplate.o addr-convert.o
+DOCUMENTROOT = ${WWWTOP}${DOCDIR}
+INSTALLDOCPATH = ${WWWTOP}${DOCDIR}${OPENGATEDIR}
+INSTALLCGIPATH = ${WWWTOP}${CGIDIR}${OPENGATEDIR}
+MAKEDIR != pwd
+
+CFLAGS= -g -O3 -Wall -I/usr/local/include
+
+.if exists(/usr/local/include/ldap.h)
+LIBLDAP = -lldap -llber
+.endif
+
+.if exists(/usr/local/include/sqlite3.h)
+LIBSQLITE = -lsqlite3 -lpthread
+.endif
+
+LIBS = -lssl -lcrypto -lradius -lpam -lezxml ${LIBLDAP} ${LIBSQLITE} -L../ezxml -L/usr/local/lib
+
+
+OBJS = utilities.o comm-auth.o comm-cgi.o watch-client.o comm-ipfw.o comm-ip6fw.c comm-arp.o comm-ndp.o error.o tcp_connect.o sock_ntop_host.o wrapper.o signal.o auth-pam.o auth-rad.o auth-pop3s.o comm-userdb.o get-param.o auth-ftps.o auth-ldap.o htmltemplate.o addr-convert.o get-mac.o ctrl-firewall.o ctrl-alarms.o udp-client.o
 MAINPROGO = main.o
 HDRS = opengatesrv.h
 MAINPROG = opengatesrv
@@ -17,10 +35,9 @@ AUTHPROGO = opengateauth.o
 AUTHPROG = opengateauth
 FWDPROGO = opengatefwd.o
 FWDPROG = opengatefwd
-FWSCRIPT = ipfectrl.pl
 LIBOPT = ezxml
 
-TESTPROGS = test-get-param test-comm-auth test-comm-ipfw test-comm-java test-cgi
+TESTPROGS = test-get-param test-comm-auth test-comm-ipfw test-watch-client test-cgi test-comm-userdb
 CLEANFILES = *.o *~ *.core 
 
 all:   ${MAINPROG} ${AUTHPROG} ${FWDPROG} ${TESTPROGS} ${LIBOPT}
@@ -43,70 +60,88 @@ test-comm-auth:     ${OBJS} test-comm-auth.o ${LIBOPT}
 test-comm-ipfw:        ${OBJS} test-comm-ipfw.o ${LIBOPT}
                ${CC} ${CFLAGS} -o $@ ${OBJS} test-comm-ipfw.o ${LIBS}
 
-test-comm-java:        ${OBJS} test-comm-java.o ${LIBOPT}
-               ${CC} ${CFLAGS} -o $@ ${OBJS} test-comm-java.o ${LIBS}
+test-watch-client:     ${OBJS} test-watch-client.o ${LIBOPT}
+               ${CC} ${CFLAGS} -o $@ ${OBJS} test-watch-client.o ${LIBS}
 
 test-cgi:      ${OBJS} test-cgi.o ${LIBOPT}
                ${CC} ${CFLAGS} -o $@ ${OBJS} test-cgi.o ${LIBS}
 
+test-comm-userdb:      ${OBJS} test-comm-userdb.o ${LIBOPT}
+               ${CC} ${CFLAGS} -o $@ ${OBJS} test-comm-userdb.o ${LIBS}
+
 ezxml: 
                ${MAKE} -C ../ezxml
 clean:
                rm -f ${MAINPROG} ${AUTHPROG} ${FWDPROG} ${TESTPROGS} ${CLEANFILES}
                ${MAKE} clean -C ../ezxml
+               rm -f ../*/*~  ../*~ ../*/*/*~
 
-install:       install-cgi install-html install-conf install-fwscript
+install:       del-lockfile install-cgi install-html install-conf
 
+del-lockfile:
+.if exists(${LOCKFILE})
+               # remove lockfile
+               rm ${LOCKFILE}
+.endif
 
 install-cgi:   ${MAINPROG} ${AUTHPROG} ${FWDPROG}
                ## Copy main CGI program and Set S bit ##
-.if !exists(${CGIPATH})
-               mkdir ${CGIPATH}
+.if !exists(${INSTALLCGIPATH})
+               mkdir ${INSTALLCGIPATH}
 .endif
-               cp ${MAINPROG} ${CGIPATH}/${MAINPROG}.cgi
-               chmod 4755 ${CGIPATH}/${MAINPROG}.cgi
-               cp ${AUTHPROG} ${CGIPATH}/${AUTHPROG}.cgi
-               chmod 755 ${CGIPATH}/${AUTHPROG}.cgi
-               cp ${FWDPROG} ${CGIPATH}/${FWDPROG}.cgi
-               chmod 755 ${CGIPATH}/${FWDPROG}.cgi
+               cp ${MAINPROG} ${INSTALLCGIPATH}/${MAINPROG}.cgi
+               chmod 4755 ${INSTALLCGIPATH}/${MAINPROG}.cgi
+               cp ${AUTHPROG} ${INSTALLCGIPATH}/${AUTHPROG}.cgi
+               chmod 755 ${INSTALLCGIPATH}/${AUTHPROG}.cgi
+               cp ${FWDPROG} ${INSTALLCGIPATH}/${FWDPROG}.cgi
+               chmod 755 ${INSTALLCGIPATH}/${FWDPROG}.cgi
                #
 
 install-html:
-               ## Copy HTML documents and java ##
-.if !exists(${DOCPATH})
-               mkdir ${DOCPATH}
+               ## Copy HTML documents and etc ##
+.if !exists(${INSTALLDOCPATH})
+               mkdir ${INSTALLDOCPATH}
 .endif
-               cp -R ../javahtml/* ${DOCPATH}
+               cp -R ../javahtml/* ${INSTALLDOCPATH}
+               # Make dummy page for network connectivity check of iOS
+               mkdir -p ${DOCUMENTROOT}/library/test/
+               cp ../javahtml/success.html ${DOCUMENTROOT}/library/test/
+
                #
                # Replace index.html.var
-.if exists(${HTMLTOP}/index.html.var) && !exists(${HTMLTOP}/index.html.var.original)
-               mv ${HTMLTOP}/index.html.var ${HTMLTOP}/index.html.var.original
+.if exists(${DOCUMENTROOT}/index.html.var) && !exists(${DOCUMENTROOT}/index.html.var.original)
+               mv ${DOCUMENTROOT}/index.html.var ${DOCUMENTROOT}/index.html.var.original
+.endif
+               mv ${INSTALLDOCPATH}/index.html.var ${DOCUMENTROOT}/index.html.var
+               #
+               # Remove favicon.ico
+.if exists(${DOCUMENTROOT}/favicon.ico)
+               mv ${DOCUMENTROOT}/favicon.ico ${DOCUMENTROOT}/favicon.ico.original
 .endif
-               mv ${DOCPATH}/index.html.var ${HTMLTOP}/index.html.var
                #
                # Remove index.html
-.if exists(${HTMLTOP}/index.html) && !exists(${HTMLTOP}/index.html.original)
-               mv ${HTMLTOP}/index.html ${HTMLTOP}/index.html.original
+.if exists(${DOCUMENTROOT}/index.html) && !exists(${DOCUMENTROOT}/index.html.original)
+               mv ${DOCUMENTROOT}/index.html ${DOCUMENTROOT}/index.html.original
 .endif
 
 install-conf:
-               ## Copy CGI program ##
+               ## Copy Config files ##
 .if !exists(${CONFIGPATH})
                mkdir ${CONFIGPATH}
 .endif
                cp  ../conf/opengatesrv.conf.sample ${CONFIGPATH}
                cp  ../conf/rc.firewall.sample ${CONFIGPATH}
-               cp  ../conf/rc.firewall6.sample ${CONFIGPATH}
-               #
-
-
-install-fwscript:
-               ## Copy firewall control script
-               cp ../conf/ipfwctrl.pl  ${CONFIGPATH}
+               cp ../conf/ipfwctrl.pl.sample  ${CONFIGPATH}
+               sed 's|<DocumentRoot>.*</DocumentRoot>|<DocumentRoot>${DOCUMENTROOT}</DocumentRoot>|' ../conf/opengatesrv.conf.sample | sed 's|<CgiDir>.*</CgiDir>|<CgiDir>${CGIDIR}</CgiDir>|' | sed 's|<OpengateDir>.*</OpengateDir>|<OpengateDir>${OPENGATEDIR}</OpengateDir>|' | sed 's|<LockFile>.*</LockFile>|<LockFile>${LOCKFILE}</LockFile>|'  > ${CONFIGPATH}/opengatesrv.conf.sample
                #
+               #------------------------------------------------------#
+               # COPY above x.sample to x and EDIT it, if you need.   #
+               #   Eg. 'cp opengatesrv.conf.sample  opengatesrv.conf' #
+               #------------------------------------------------------#
 
 
 main.o:                ${HDRS}
+               ${CC} ${CFLAGS} -DMAKEDIR='"${MAKEDIR}"' -c $<
 
 utilities.o:   ${HDRS}
 
@@ -116,13 +151,19 @@ comm-ipfw.o:      ${HDRS}
 
 comm-cgi.o:    ${HDRS}
 
-comm-java.o:   ${HDRS}
+watch-client.o:        ${HDRS}
 
 comm-arp.o:    ${HDRS}
 
 comm-ndp.o:    ${HDRS}
 
 comm-userdb.o: ${HDRS}
+.if !exists(/usr/local/include/sqlite3.h)
+               ${CC} ${CFLAGS} -DSQLITE3_NOT_INSTALLED -c $<
+.endif
+ctrl-firewall.o:       ${HDRS}
+
+ctrl-alarms.o: ${HDRS}
 
 auth-pam.o:    ${HDRS}
 
@@ -130,24 +171,42 @@ auth-rad.o:       ${HDRS}
 
 auth-pop3s.o:  ${HDRS}
 
+auth-ftps.o:   ${HDRS}
+
+auth-ldap.o:   ${HDRS}
+.if !exists(/usr/local/include/ldap.h)
+               ${CC} ${CFLAGS} -DLDAP_NOT_INSTALLED -c $<
+.endif
+
 get-param.o:   ${HDRS}
 
+get-mac.o:     ${HDRS}
+
 opengateauth.o:        ${HDRS}
+               ${CC} ${CFLAGS} -DMAKEDIR='"${MAKEDIR}"' -c $<
 
 opengatefwd.o: ${HDRS}
+               ${CC} ${CFLAGS} -DMAKEDIR='"${MAKEDIR}"' -c $<
 
 htmltemplate.o:        ${HDRS}
 
 addr-convert.o:        ${HDRS}
 
+udp-client.o:  ${HDRS}
+
 test-get-param.o:      ${HDRS}
 
 test-comm-auth.o:      ${HDRS}
 
 test-comm-ipfw.o:      ${HDRS}
 
-test-comm-java.o:      ${HDRS}
+test-watch-client.o:   ${HDRS}
 
 test-cgi.o:    ${HDRS}
 
+test-comm-userdb.o:    ${HDRS}
+
+
+
+