aboutsummaryrefslogtreecommitdiffstats
path: root/devel/fossology/Makefile
blob: 6093b7f59982e57de809a59757e79038fc3fe108 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# New ports collection makefile for:    fossology
# Date created:             2008-06-21
# Whom:                 alepulver
#
# $FreeBSD$
#

# NOTES:
# - Possible deps alternatives (don't know if they work):
#   graphics/xpdf -> graphics/poppler-utils
#   archivers/rpm4 -> archivers/rpm2cpio
#
# TODO:
# - Add status command to rc.d script (run through "daemon -p ...")
# - Add crontab entry for postgres db optimizations?
#

PORTNAME=   fossology
PORTVERSION=    1.1.0
PORTREVISION=   1
CATEGORIES= devel
MASTER_SITES=   SF

MAINTAINER= ports@FreeBSD.org
COMMENT=    License analysis tool for Open Source software

BUILD_DEPENDS=  bash:${PORTSDIR}/shells/bash \
        ${SITE_PERL}/Text/Template.pm:${PORTSDIR}/textproc/p5-Text-Template \
        svn:${PORTSDIR}/devel/subversion
LIB_DEPENDS=    extractor.2:${PORTSDIR}/textproc/libextractor
RUN_DEPENDS=    cabextract:${PORTSDIR}/archivers/cabextract \
        icat:${PORTSDIR}/sysutils/sleuthkit \
        pdftotext:${PORTSDIR}/graphics/xpdf \
        rpm2cpio:${PORTSDIR}/archivers/rpm4 \
        upx:${PORTSDIR}/archivers/upx \
        unrar:${PORTSDIR}/archivers/unrar \
        unzip:${PORTSDIR}/archivers/unzip \
        bash:${PORTSDIR}/shells/bash \
        wget:${PORTSDIR}/ftp/wget

USE_APACHE= 2.0+
USE_CDRTOOLS=   yes
USE_GMAKE=  yes
USE_GNOME=  libxml2
USE_PERL5=  yes
USE_PGSQL=  yes
IGNORE_WITH_PGSQL=  73 74 80
USE_PHP=    pgsql session posix pcre
IGNORE_WITH_PHP=4
WANT_PHP_CLI=   yes
WANT_PHP_WEB=   yes
USE_RC_SUBR=    fossology
REINPLACE_ARGS= -i ''

CFLAGS+=    -I${LOCALBASE}/include -L${LOCALBASE}/lib

SUB_FILES=  pkg-message
SUB_LIST=   FOSS_DB="${FOSS_DB}"
PLIST_SUB=  FOSS_DB="${FOSS_DB:S/${PREFIX}\///}"

MAN1=       cp2foss.1 fo_notify.1 fossjobs.1 fosslic.1

FOSS_DB?=   ${DATADIR}/repository
LIBDIR=     ${PREFIX}/lib   # is /usr/lib by default, and affects build

.include <bsd.port.pre.mk>

.if ${OSVERSION} < 700000
IGNORE=     needs at least FreeBSD 7.x, because it uses librt
.endif

post-patch:
# Fix paths (respect PREFIX, etc)
    @${GREP} -Rl /bin/bash ${WRKSRC} | ${GREP} -v UnMagic.mime | \
        ${XARGS} ${REINPLACE_CMD} -e 's|/bin/bash|${LOCALBASE}/bin/bash|'
    @${GREP} -Rl /usr/bin/php ${WRKSRC} | ${XARGS} ${REINPLACE_CMD} -e \
        's|/usr/bin/php|${LOCALBASE}/bin/php|'
    @${REINPLACE_CMD} -Ee 's|^(PREFIX=).*|\1${PREFIX}|; \
        s|^(LIBDIR=).*|\1${LIBDIR}|; \
        s|^(REPODIR=).*|\1${FOSS_DB}|; \
        s|^(MANDIR=).*|\1${MANPREFIX}/man|; \
        s|^(CC=).*|\1${CC}|; \
        s|^(CFLAGS=)(.*)|\1${CFLAGS} \2|; \
        s|^(CFLAGS_DB=)(.*)|\1${CFLAGS} \2|; \
        s|^(CFLAGS_REPO=)(.*)|\1${CFLAGS} \2|; \
        s|^(INSTALL =).*|\1 ${INSTALL}|;' \
        ${WRKSRC}/Makefile.conf
# Fix build flags and source
    @${GREP} -ERl '(stat|fopen|mmap|lseek|off)64' ${WRKSRC} | \
        ${XARGS} ${REINPLACE_CMD} -Ee 's,(stat|fopen|mmap|lseek|off)64,\1,g'
# Fix PostgreSQL user name (postgres -> pgsql)
    @${REINPLACE_CMD} -e 's|su postgres|su pgsql|' \
        ${WRKSRC}/db/dbcreate.in
# Fix hostname invocation
    @${REINPLACE_CMD} -Ee 's|(hostname) --fqdn|\1|' \
        ${WRKSRC}/cli/fo_notify.php
# Add path to repository (might be hardcoded in other parts of FOSSology)
    @${ECHO_CMD} "${FOSS_DB}" > ${WRKSRC}/common/defconf/RepPath.conf
# Do not install init.d script (we use our own)
    @${REINPLACE_CMD} -Ee 's|^(install: all) install-init|\1|' \
        ${WRKSRC}/scheduler/Makefile

pre-install:
    @${MKDIR} ${PREFIX}/lib/fossology/agents ${DATADIR}/php

post-install:
.if !defined(NOPORTDOCS)
    ${MKDIR} ${DOCSDIR}
    ${INSTALL_DATA} ${WRKSRC}/README ${WRKSRC}/INSTALL* ${DOCSDIR}
.endif
# Copy .sample (defaults) to .conf when not present
.for f in Db Depth Hosts Proxy RepPath
    @cd ${PREFIX}/etc/fossology && test -f ${f}.conf || \
        ${CP} ${f}.conf.sample ${f}.conf
.endfor
    @${ECHO_CMD}; ${CAT} ${PKGMESSAGE}; ${ECHO_CMD}

.include <bsd.port.post.mk>