1# $OpenBSD: Makefile.bsd-wrapper,v 1.85 2011/06/23 22:46:12 schwarze Exp $
2#
3# Build wrapper for Perl 5.10.0
4#
5
6# For ``NOMAN'' and ``COMPILER_VERSION''
7.include <bsd.own.mk>
8
9# There is no point in building a profiled libperl that is never used.
10NOPROFILE=
11
12TARGET_MACHINE_ARCH?=	$(MACHINE_ARCH)
13# To build a threaded perl, uncomment this.  Not stable on all platforms...
14#THREADED_PERL=true
15
16# Perl builds with -fno-strict-aliasing, we want libperl to do the same
17CFLAGS+= -fno-strict-aliasing
18.if ${COMPILER_VERSION:L} == "gcc3" || ${COMPILER_VERSION:L} == "gcc4"
19CFLAGS+= -fno-delete-null-pointer-checks
20.endif
21
22CONFIGURE_ARGS= -dsE -Dopenbsd_distribution=defined
23.if defined(THREADED_PERL) && ($(THREADED_PERL) == true)
24CONFIGURE_ARGS+= -Dusethreads
25CFLAGS+= -pthread
26LDFLAGS+= -pthread
27.endif
28.if !exists(${.OBJDIR}/config.over)
29CONFIGURE_ARGS+= -Dmksymlinks
30.endif
31
32H2PH=		/usr/bin/h2ph
33
34LIB=	perl
35
36SRCS1=	gv.c toke.c perly.c pad.c regcomp.c dump.c util.c mg.c reentr.c \
37	mro.c hv.c av.c run.c pp_hot.c sv.c pp.c scope.c pp_ctl.c \
38	pp_sys.c doop.c doio.c regexec.c utf8.c taint.c deb.c universal.c \
39	globals.c perlio.c perlapi.c numeric.c mathoms.c locale.c \
40	pp_pack.c pp_sort.c
41SRCS=	${SRCS1} op.c perl.c
42
43# We must not try to mkdep DynaLoader.c as it requires miniperl
44OBJS+=	DynaLoader.o
45
46# For generating DynaLoader.c
47.if defined(NOPIC)
48DYNALOADER=ext/DynaLoader/dl_none.xs
49.else
50DYNALOADER=ext/DynaLoader/dl_dlopen.xs
51.endif
52
53# Arguments passed to Configure...
54
55CPPFLAGS+= -DPERL_CORE -DPERL_RANDOM_DEVICE=\"/dev/arandom\" -I.
56
57.if defined (INSTALL_STRIP) && ${INSTALL_STRIP} == "-s"
58STRIPFLAGS='-s'
59.endif
60
61GEN_AFTER= 	bitcount.h config.h uudmap.h cflags makeaperl makedepend \
62		myconfig writemain Makefile Policy.sh pod/Makefile \
63		x2p/Makefile x2p/cflags
64
65GENERATED=	config.sh ${GEN_AFTER}
66
67${GEN_AFTER}: config.sh
68
69CLEANFILES=	config.sh Policy.sh DynaLoader.c
70
71all:	perl.build man.build
72
73man.build: perl.build
74	cd ${.CURDIR} && exec ${MAKE} -f Makefile.bsd-wrapper1 mansrc.build
75
76beforedepend: config.sh config.h bitcount.h uudmap.h Makefile makedepend x2p/Makefile writemain
77	cd ${.OBJDIR} && exec ${MAKE} depend
78
79perl.build:	perl.lib
80	cd ${.OBJDIR} && exec ${MAKE}
81
82config.sh:	${.CURDIR}/config.over
83	cd ${.OBJDIR} && PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
84	    exec /bin/sh ${.CURDIR}/Configure ${CONFIGURE_ARGS}
85
86Makefile cflags makeaperl makedepend makedir myconfig writemain:
87	cd ${.OBJDIR} && exec /bin/sh $@.SH
88
89Policy.sh:
90	cd ${.OBJDIR} && exec /bin/sh Policy_sh.SH
91
92config.h:
93	cd ${.OBJDIR} && exec /bin/sh config_h.SH
94
95uudmap.h: bitcount.h
96
97bitcount.h: generate_uudmap
98	./generate_uudmap uudmap.h bitcount.h
99
100generate_uudmap: generate_uudmap.o
101	${CC} -o generate_uudmap generate_uudmap.o
102
103pod/Makefile:
104	cd ${.OBJDIR}/pod && exec /bin/sh Makefile.SH
105
106x2p/Makefile:
107	cd ${.OBJDIR}/x2p && exec /bin/sh Makefile.SH
108
109x2p/cflags:
110	cd ${.OBJDIR}/x2p && exec /bin/sh cflags.SH
111
112# Never try to regenerate perly.c or perly.h
113perly.c perly.h: perly.y
114	-@true
115
116install: install.lib install.perl maninstall
117	-mkdir -p ${DESTDIR}/usr/libdata/perl5/site_perl/${MACHINE_ARCH}-openbsd
118	(cd ${DESTDIR}/usr/include; ${H2PH} \
119		-d ${DESTDIR}/usr/libdata/perl5/site_perl/${MACHINE_ARCH}-openbsd \
120		`find . -name '*.h'`; \
121		pax -rw `find . -type l \! -name '*.h' | sed 's/^..//'` \
122		${DESTDIR}/usr/libdata/perl5/site_perl/${MACHINE_ARCH}-openbsd)
123	-chmod -R a+rX ${DESTDIR}/usr/libdata/perl5
124
125install.perl:
126	cd ${.OBJDIR}; INSTALL=${INSTALL} INSTALL_COPY=${INSTALL_COPY} \
127	 STRIPFLAGS=${STRIPFLAGS} INSTALLFLAGS=-o NOLIBINSTALL=1 \
128	 LD_LIBRARY_PATH=${.OBJDIR} exec ./perl installperl --destdir=${DESTDIR} -o STRIPFLAGS=${STRIPFLAGS}
129
130test:
131	-@if [ -e Makefile ]; then ${MAKE} test; fi
132
133clean:
134	-@if [ -e Makefile ]; then ${MAKE} realclean; fi
135
136cleandir:
137	-@if [ ${.CURDIR} != ${.OBJDIR} ]; then \
138	    rm -rf *; \
139	else \
140	    test -e Makefile && ${MAKE} distclean; \
141	    rm -f ${CLEANFILES}; \
142	fi
143	@cd ${.CURDIR} && ${MAKE} -f Makefile.bsd-wrapper1 cleandir
144
145maninstall:
146.ifdef NOMAN
147	@echo NOMAN is set
148.else
149	@cd ${.CURDIR} && exec ${MAKE} -f Makefile.bsd-wrapper1 maninstall
150.endif
151
152.include <bsd.lib.mk>
153
154# These have to come after the inclusion of <bsd.lib.mk>
155
156# Need -fPIC, not -fpic on sparc
157.if ($(TARGET_MACHINE_ARCH) == sparc)
158PICFLAG=-fPIC
159.endif
160
161# The DynaLoader extension is now compiled statically into libperl
162miniperl: ${GENERATED} ${SRCS1:S/.c/.o/g} opmini.o miniperl.o miniperlmain.o
163	${CC} -o miniperl ${SRCS1:S/.c/.o/g} opmini.o miniperl.o miniperlmain.o ${LDFLAGS} -lm
164
165opmini.c: op.c
166	rm -f opmini.c
167	cp op.c opmini.c
168
169opmini.o: opmini.c
170	${CC} ${CPPFLAGS} ${CFLAGS} -DPERL_EXTERNAL_GLOB -c  $> -o $@
171
172miniperl.o: perl.c
173	${CC} ${CPPFLAGS} ${CFLAGS} -DPERL_EXTERNAL_GLOB -DPERL_IS_MINIPERL -c  $> -o $@
174
175lib/Config.pm: miniperl config.sh
176	cd ${.OBJDIR} && exec ${MAKE} preplibrary
177
178DynaLoader.c: miniperl ${DYNALOADER} lib/Config.pm
179	./miniperl -Ilib -Icpan/Cwd -Icpan/Cwd/lib -Icpan/ExtUtils-ParseXS/lib \
180	    -Icpan/Getopt-Long/lib -Idist/constant/lib \
181	    cpan/ExtUtils-ParseXS/lib/ExtUtils/xsubpp -noprototypes -typemap \
182	    ../../lib/ExtUtils/typemap ${DYNALOADER} | \
183	    sed -f ${.CURDIR}/DynaLoader.sed > $@
184
185perl.lib:	${GENERATED} ${_LIBS}
186
187install.lib:
188	${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 lib${LIB}.a \
189	    ${DESTDIR}${LIBDIR}
190.if (${INSTALL_COPY} != "-p")
191	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}.a
192.endif
193	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a
194.if !defined(NOPROFILE)
195	${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
196	    lib${LIB}_p.a ${DESTDIR}${LIBDIR}
197.if (${INSTALL_COPY} != "-p")
198	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
199.endif
200	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a
201.endif
202.if !defined(NOPIC) && (${MACHINE_CPU} != "mips64")
203	${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m 600 \
204	    lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
205.if (${INSTALL_COPY} != "-p")
206	${RANLIB} -t ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
207.endif
208	chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a
209.endif
210.if !defined(NOPIC) && defined(major) && defined(minor)
211	${INSTALL} ${INSTALL_COPY} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
212	    lib${LIB}.so.${major}.${minor} ${DESTDIR}${LIBDIR}
213.endif
214.PHONY: perl.lib install.lib perl.build install.perl man.build
215