aboutsummaryrefslogtreecommitdiff
path: root/lang/Sather/Makefile
blob: 319ad360f0e207bf4d7ea6aea25b7d29fe8af69b (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# ex:ts=8
# Ports collection makefile for:  Sather
# Date created:			  Mon Oct 31 22:04:12 PST 1994
# Whom:				  hsu
#
# $FreeBSD$
#

PORTNAME=	sather
PORTVERSION=	1.2.2
PORTREVISION=	1
CATEGORIES=	lang
MASTER_SITES=	${MASTER_SITE_GNU}
MASTER_SITE_SUBDIR=	${PORTNAME}

MAINTAINER=	stas@FreeBSD.org
COMMENT=	Sather compiler

#
# NOTE: currently build fails with threaded Tk
#
LIB_DEPENDS=	tk84.1:${PORTSDIR}/x11-toolkits/tk84
BUILD_DEPENDS=	${LOCALBASE}/bin/libtool:${PORTSDIR}/devel/libtool15

USE_BZIP2=	yes
USE_GMAKE=	yes
ALL_TARGET=	full optional
MAN1=		sabrowse.1 sacomp.1

INFO=		sather sather-mode sather-tutorial

SAT_CFLAGS=	${CFLAGS} -I. -I${BC_DIR}/include \
		-I../System/Common \
		-I${LOCALBASE}/include \
		-I${LOCALBASE}/include/tcl8.4 -I${LOCALBASE}/include/tk8.4
SAT_LIBS=	-L${BC_DIR}/.libs -L${LOCALBASE}/lib -lgc -lm
SAT_LIBDIR=	${PREFIX}/lib/sather

OPTIONS=	EMACS "Install Emacs syntax files" off

.if !defined(NOPORTDOCS)
PORTDOCS=	*
.endif

.include <bsd.port.pre.mk>

.if ${ARCH} == "ia64"
BROKEN=		boehm-gc is broken on ia64
.endif

BC_DIR!=	cd ${PORTSDIR}/devel/boehm-gc && ${MAKE} -V WRKSRC

post-extract:
#
#	Precompiled binaries are for Linux only
#
	${RM} -f ${WRKSRC}/Boot/sacomp.code/*.o

post-patch:
	@${REINPLACE_CMD} -E \
		-e "s,/usr/lib/sather,${SAT_LIBDIR}," \
		-e "s,/usr/X11R6,${LOCALBASE}," \
		-e "s,/usr/X11R6,${LOCALBASE}," \
		${WRKSRC}/Boot/sacomp.code/strings.c \
		${WRKSRC}/Doc/Installation.html \
		${WRKSRC}/Doc/man/man1/sabrowse.1 \
		${WRKSRC}/Doc/man/man1/sacomp.1 \
		${WRKSRC}/Library/System/unix.sa \
		${WRKSRC}/System/Platforms/X/Platform.module \
		${WRKSRC}/System/Platforms/tcltk/startup.tcl \
		${WRKSRC}/debian/bin-wrapper

	@${REINPLACE_CMD} -E \
		-e "s,(TK_LIB_NAME[[:space:]]*=[[:space:]]*).*,\1tk84," \
		-e "s,(TCL_LIB_NAME[[:space:]]*=[[:space:]]*).*,\1tcl84," \
		${WRKSRC}/System/Platforms/tcltk/Make.target.inc

	@${REINPLACE_CMD} -E \
		-e 's,(VERSION:[[:space:]]*).*,\1"${PORTVERSION}";,' \
		-e 's,(C_COMPILER:[[:space:]]*).*,\1"${CC}";,' \
		-e 's,(CC_OPTIONS:[[:space:]]*).*,\1"${SAT_CFLAGS}";,' \
		-e 's,(GC_LINK:[[:space:]]*).*,\1"${SAT_LIBS}";,' \
		-e 's,(CC_OPTIMIZE_FLAG:[[:space:]]*).*,\1""\,"${CFLAGS}";,' \
		-e 's,(MAKE_COMMAND:[[:space:]]*).*,\1"${GMAKE}";,' \
		-e 's,(FORTRAN_APPEND_UNDERSCORE:[[:space:]]*).*,\1"true";,' \
		-e 's,CONFIG_PLATFORMS,unix,' \
		-e 's,CONFIG_DEFAULT_PLATFORM,freebsd,' \
		${WRKSRC}/System/Common/CONFIG.proto \
		${WRKSRC}/System/Platforms/freebsd/CONFIG

	@${REINPLACE_CMD} -E \
		-e "s,(DEFAULT_PLATFORM[[:space:]]*=[[:space:]]*).*,\1freebsd,"\
		-e "s,(CPP[[:space:]]*=[[:space:]]*).*,\1/usr/bin/cpp -P," \
		-e "s,(CC[[:space:]]*=[[:space:]]*).*,\1${CC}," \
		-e "s,(CFLAGS[[:space:]]*=[[:space:]]*).*,\1${SAT_CFLAGS}," \
		-e "s,(LIBS[[:space:]]*=[[:space:]]*).*,\1${SAT_LIBS}," \
		${WRKSRC}/Makefile ${WRKSRC}/Boot/sacomp.code/Makefile

	@${REINPLACE_CMD} -E \
		-e 's,/usr/bin/tclsh,${LOCALBASE}/bin/tclsh8.4,' \
			${WRKSRC}/Browser/Web/*
#
# Don't generate cpp comments - Sather won't like it
#
	@${REINPLACE_CMD} -E \
		-e 's,#(CPP[[:space:]]*=[[:space:]]*).*,\1/usr/bin/cpp -P,' \
		${WRKSRC}/System/Common/Makefile
#
# We have this function in stdlib
#
	@${ECHO_CMD} \"abort2\" >> ${WRKSRC}/System/FORBID

pre-build:
#
# We need to clean since REDIRECT is required
#
	@(cd ${PORTSDIR}/devel/boehm-gc && \
		${MAKE} BATCH=yes WITH_REDIRECT=yes clean all)
#
# We're wanting static linking
#
	@${RM} -f ${BC_DIR}/.libs/*.so*

post-build:
.for file in sather-tutorial.texinfo sather-mode.texinfo sather.texinfo
	cd ${WRKSRC}/Emacs && makeinfo --no-split ${file}
.endfor

do-install:
	@${MKDIR} ${SAT_LIBDIR}/Bin
.for file in sabrowse sacomp
	${INSTALL_PROGRAM} ${WRKSRC}/Bin/${file} ${SAT_LIBDIR}/Bin
.endfor
.for file in PP gen_html saprep
	${INSTALL_SCRIPT} ${WRKSRC}/Bin/${file} ${SAT_LIBDIR}/Bin
.endfor
	${INSTALL_SCRIPT} ${WRKSRC}/debian/bin-wrapper ${SAT_LIBDIR}/Bin
.for link in sabrowse sacomp
	${LN} -sf ${SAT_LIBDIR}/Bin/bin-wrapper ${PREFIX}/bin/${link}
.endfor
.for obj in Browser Library System/Common System/Debug System/FORBID \
	System/Platforms/X System/Platforms/dualgui System/Platforms/f77 \
	System/Platforms/freebsd System/Platforms/gui System/Platforms/tcltk
	${TAR} -C ${WRKSRC} -cf - \
		--exclude "ActiveThreads" --exclude "Brahma" \
		--exclude "CONFIG.proto" --exclude "Siva" \
		--exclude "dual_gui_server.code" --exclude "*.bak" \
		--exclude "*.config" --exclude "*.orig" \
		--exclude "*Makefile*" ${obj} | \
		${TAR} -C ${SAT_LIBDIR} --unlink -xf -
.endfor

#
# Permissions safety
#
	@${CHOWN} -R ${SHAREOWN}:${SHAREGRP} ${SAT_LIBDIR}
	@${FIND} ${SAT_LIBDIR}/ -type f ! -perm +111 -exec ${CHMOD} \
		${SHAREMODE} {} \;
	@${FIND} ${SAT_LIBDIR}/ -type f -perm +111 -exec ${CHMOD} \
		${BINMODE} {} \;
	@${FIND} ${SAT_LIBDIR}/ -type d -exec ${CHMOD} 755 {} \;

#
# Generate PLIST
#
	@${FIND} -d ${SAT_LIBDIR}/ -type f | \
		${SED} 's,^${PREFIX}/,,' >> ${TMPPLIST}
	@${FIND} -d ${SAT_LIBDIR}/ -type d | \
		${SED} 's,^${PREFIX}/,@dirrm ,' >> ${TMPPLIST}
.for FILE in sabrowse sacomp
	@${ECHO_CMD} \
		"@exec ${LN} -sf %D/lib/sather/Bin/bin-wrapper %D/bin/${FILE}"\
		>> ${TMPPLIST}
	@${ECHO_CMD} "bin/${FILE}" >> ${TMPPLIST}
.endfor

.for file in sabrowse.1 sacomp.1
	${INSTALL_MAN} ${WRKSRC}/Doc/man/man1/${file} ${MANPREFIX}/man/man1
.endfor
.for file in ${INFO}
	${INSTALL_DATA} ${WRKSRC}/Emacs/${file}.info ${PREFIX}/info
.endfor
.if defined(WITH_EMACS)
. for file in hl319.el sather-lib.el sather-module.el sather.el
	${INSTALL_DATA} ${WRKSRC}/Emacs/${file} ${PREFIX}/share/emacs/site-lisp
	@${ECHO_CMD} "share/emacs/site-lisp/${file}" >> ${TMPPLIST}
. endfor
.endif
.if !defined(NOPORTDOCS)
	@${MKDIR} ${DOCSDIR}
	@(cd ${WRKSRC}/Doc && ${COPYTREE_SHARE} "*" ${DOCSDIR} \
		"! -regex .*man.* ! -regex .*GPL ! -regex .*\.bak")
.endif

.include <bsd.port.post.mk>