summaryrefslogtreecommitdiff
path: root/cross/i386-netbsdpe/Makefile
blob: 95f37fe87b58bc3b755e3f5e0c63aa8b5d9ff087 (plain)
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
# $NetBSD: Makefile,v 1.24 2006/07/06 17:04:42 rillig Exp $

DISTNAME=		cross-${TARGET_ARCH}-${DISTVERSION}
DISTVERSION=		3.3.6
CATEGORIES=		cross lang
MASTER_SITES=		http://chiharu.hauN.org/peace/dist/

MAINTAINER=		peace-sacrifice@hauN.org
HOMEPAGE=		http://chiharu.hauN.org/peace/
COMMENT=		Cross-compile environment for PEACE/i386

# Need NetBSD headers in /usr/include
ONLY_FOR_PLATFORM=	NetBSD-1.6[Q-Z]*-* NetBSD-[2-9]*-*
CONFLICTS=		pth-[0-9]* pth-current-[0-9]* pth-syscall-[0-9]*
USE_CROSSBASE=		yes

WRKSRC=			${WRKDIR}/${GCC_DISTNAME}
BU_WRKSRC=		${WRKDIR}/${BINUTILS_DISTNAME}
BINUTILS_GNUTARGET=	pe-i386
BINUTILS_LDEMULATION=	i386pe
TARGET_ARCH=		i386-netbsdpe
GCC_CONFIGURE_ARGS+=	--enable-threads
BINUTILS_EXTRAS=	dlltool dllwrap windres
INFO_FILES=		yes

# Mingw pathes
DISTFILES+=		gcc-3.3.3-20040217-1-src.diff.gz
GCC_WIN32_PATCH=	${WRKDIR}/gcc-3.3.3-20040217-1-src.diff
MASTER_SITES+=		${MASTER_SITE_SOURCEFORGE:=mingw/}

MESSAGE_SUBST+=		CROSSBASE=${CROSSBASE}
TARGET_DIR=		${PREFIX}/${TARGET_ARCH}

GCC_DISTNAME=		gcc-3.3.6
GCC_INTVERSION=		3.3.6
MASTER_SITES+=		${MASTER_SITE_GNU:=gcc/gcc-3.3.6/}
DISTFILES+=		${GCC_DISTNAME}.tar.bz2
USE_TOOLS+=		gmake makeinfo
GCC_LANGUAGES=		c,c++
CONFIGURE_ENV=		${SETENV} CC=${CC:Q} CFLAGS=${CFLAGS:M*:Q} \
		CXXFLAGS=${CXXFLAGS:M*:Q} LDFLAGS=${LDFLAGS:M*:Q}
GCC_CONFIGURE_ARGS=	--with-gnu-ld --with-gnu-as -disable-multilib \
		--enable-threads=posix --disable-shared --with-system-zlib \
		--enable-languages=${GCC_LANGUAGES} --with-headers=yes \
		--target=${TARGET_ARCH} --datadir=${TARGET_DIR}/share
GCC_MAKE_FLAGS=		AS_FOR_TARGET="${AS_FOR_TARGET}" \
			AR_FOR_TARGET="${AR_FOR_TARGET}" \
			NM_FOR_TARGET="${NM_FOR_TARGET}" \
			RANLIB_FOR_TARGET="${RANLIB_FOR_TARGET}"
#			INSTALL="${INSTALL} -c -o ${BINOWN} -g ${BINGRP}" \
#			INSTALL_PROGRAM="${INSTALL_PROGRAM}"
GCC_MAKE=		${SETENV} ${MAKE_ENV} \
	                ${MAKE_PROGRAM} ${MAKE_FLAGS} ${GCC_MAKE_FLAGS}
WRKOBJ=			${WRKDIR}/obj

BINUTILS_DISTNAME=	binutils-2.16.91-20060119-1
DISTFILES+=		${BINUTILS_DISTNAME}-src.tar.gz
MASTER_SITES+=		${MASTER_SITE_SOURCEFORGE:=mingw/}
#MASTER_SITES+=		${MASTER_SITE_GNU:=binutils/}
#MASTER_SITES+=		http://prdownloads.sourceforge.net/mingw/
#CONFIGURE_ARGS+=	--with-gnu-as --with-gnu-ld --data-dir=${TARGET_DIR}/share
BU_WRKSRC=		${WRKDIR}/${BINUTILS_DISTNAME}
AS_FOR_TARGET=		${WRKOBJ}/gas/as-new
AR_FOR_TARGET=		${WRKOBJ}/binutils/ar
NM_FOR_TARGET=		${WRKOBJ}/binutils/nm-new
RANLIB_FOR_TARGET=	${WRKOBJ}/binutils/ranlib
LD_FOR_TARGET=		${WRKOBJ}/ld/ld-new

post-extract:
	${PATCH} -d ${WRKSRC} -p1 --forward --quiet -E < ${GCC_WIN32_PATCH} \
	|| ${WARNING_MSG} "[${.TARGET}] The patch command failed with exitcode $$?"
	${CP} ${WRKSRC}/gcc/config/i386/mingw32.h ${WRKSRC}/gcc/config/i386/netbsdpe.h
	${CP} ${WRKSRC}/gcc/config/i386/t-cygming ${WRKSRC}/gcc/config/i386/t-netbsdpe

post-patch:
	for i in patches/binutils-??; do \
		${PATCH} -d ${BU_WRKSRC} --forward --quiet -E < $$i; \
	done

CFLAGS_FOR_TARGET+=	-I${WRKDIR}
post-configure:
	${SED} "s/^extern FILE/__declspec(dllimport) FILE/" /usr/include/stdio.h > ${WRKDIR}/stdio.h

do-configure:
#	@-mkdir -p ${WRKOBJ}/libiberty
#	@cd ${WRKOBJ}/libiberty && ${SETENV} CC="${CC}" CFLAGS="${CFLAGS}" \
#		CXXFLAGS="${CXXFLAGS}" LDFLAGS="${LDFLAGS}" \
#		${WRKSRC}/libiberty/configure --prefix=${PREFIX}
	${MKDIR} ${WRKOBJ} ${WRKOBJ}/binutils ${WRKOBJ}/gas ${WRKOBJ}/ld
	cd ${WRKOBJ} && ${CONFIGURE_ENV} ${BU_WRKSRC}/configure \
		--prefix=${PREFIX} ${GCC_CONFIGURE_ARGS} --disable-nls
	cd ${WRKOBJ}/binutils && ${CONFIGURE_ENV} ${BU_WRKSRC}/binutils/configure \
		--prefix=${PREFIX} ${GCC_CONFIGURE_ARGS} --disable-nls
	cd ${WRKOBJ}/gas && ${CONFIGURE_ENV} ${BU_WRKSRC}/gas/configure \
		--prefix=${PREFIX} ${GCC_CONFIGURE_ARGS} --disable-nls
	cd ${WRKOBJ}/ld && ${CONFIGURE_ENV} ${BU_WRKSRC}/ld/configure \
		--prefix=${PREFIX} ${GCC_CONFIGURE_ARGS} --disable-nls
# Build binutils before configuring gcc so that gcc's configure works correctly
	cd ${WRKOBJ} && ${GCC_MAKE}
	${MKDIR} ${WRKOBJ}/gcc
	cd ${WRKOBJ}/gcc && ${CONFIGURE_ENV} ${WRKSRC}/gcc/configure \
		--prefix=${PREFIX} ${GCC_CONFIGURE_ARGS}

do-build:
	${LN} -sf ${AS_FOR_TARGET} ${WRKOBJ}/gcc/as
	${LN} -sf ${LD_FOR_TARGET} ${WRKOBJ}/gcc/ld
	cd ${WRKOBJ}/gcc && ${GCC_MAKE}

do-install:
	cd ${WRKOBJ} && ${GCC_MAKE} installdirs install-binutils \
		install-gas install-ld
	cd ${WRKOBJ}/gas/doc && ${GCC_MAKE} install-man1
	cd ${WRKOBJ}/gcc && ${GCC_MAKE} install-common \
		install-libgcc install-cpp install-po \
		lang.install-normal install-driver
	${INSTALL_DATA_DIR} ${PREFIX}/lib/gcc-lib/${TARGET_ARCH}/${GCC_INTVERSION}/include
	${INSTALL_DATA} ${WRKOBJ}/gcc/include/mmintrin.h \
		${PREFIX}/lib/gcc-lib/${TARGET_ARCH}/${GCC_INTVERSION}/include
	${INSTALL_DATA} ${WRKOBJ}/gcc/include/xmmintrin.h \
		${PREFIX}/lib/gcc-lib/${TARGET_ARCH}/${GCC_INTVERSION}/include
	${INSTALL_DATA_DIR} ${TARGET_DIR}/include
	cd ${PREFIX}/bin && ${LN} -sf ${TARGET_ARCH}-gcc ${TARGET_ARCH}-cc
	cd ${TARGET_DIR}/bin && ${LN} -sf gcc cc

.include "../../mk/bsd.pkg.mk"