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