perl: fix not a Mach-O file on macOS
[feed/packages.git] / lang / perl / Makefile
1 #
2 # Copyright (C) 2006-2018 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 include perlver.mk
11
12 PKG_NAME:=perl
13 PKG_VERSION:=$(PERL_VERSION)
14 PKG_RELEASE:=2
15
16 PKG_SOURCE_URL:=https://www.cpan.org/src/5.0
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
18 PKG_HASH:=d91115e90b896520e83d4de6b52f8254ef2b70a8d545ffab33200ea9f1cf29e8
19
20 PKG_LICENSE:=GPL-1.0-or-later Artistic-1.0-Perl
21 PKG_LICENSE_FILES:=Copying Artistic README
22 PKG_MAINTAINER:=Marcel Denia <naoir@gmx.net>, Philip Prindeville <philipp@redfish-solutions.com>
23 PKG_CPE_ID:=cpe:/a:perl:perl
24
25 # Build settings
26 PKG_BUILD_DIR:=$(BUILD_DIR)/perl/$(PKG_NAME)-$(PKG_VERSION)
27 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/perl/$(PKG_NAME)-$(PKG_VERSION)
28 PKG_INSTALL:=1
29 PKG_BUILD_DEPENDS:=perl/host
30 PKG_BUILD_PARALLEL:=1
31 HOST_BUILD_PARALLEL:=1
32
33 # Variables used during configuration/build
34 HOST_PERL_PREFIX:=$(STAGING_DIR_HOSTPKG)/usr
35
36 ifneq ($(CONFIG_USE_MUSL),)
37 TARGET_CFLAGS += -D_LARGEFILE64_SOURCE
38 endif
39
40 # Filter -g3, it will break Compress-Raw-Zlib
41 TARGET_CFLAGS_PERL:=$(patsubst -g3,-g,$(TARGET_CFLAGS))
42 TARGET_CPPFLAGS_PERL:=$(patsubst -g3,-g,$(TARGET_CPPFLAGS))
43
44 # A list of disabled tests
45 # ExtUtils tests are disabled for now as we don't support building
46 # native extensions on the target machine at the moment
47 PERL_DISABLEDTESTS:=cpan/ExtUtils-Constant cpan/ExtUtils-MakeMaker
48 # We're on Linux, so don't even package them
49 PERL_DISABLEDTESTS+=cpan/Win32API-File cpan/Win32 ext/VMS-DCLsym ext/VMS-Filespec ext/VMS-Stdio ext/Win32CORE os2/
50 # NDBM and ODBM not supported
51 PERL_DISABLEDTESTS+=ext/NDBM_File ext/ODBM_File
52
53
54 include $(INCLUDE_DIR)/package.mk
55 include $(INCLUDE_DIR)/host-build.mk
56 include perlmod.mk
57
58 define Package/perl
59 SUBMENU:=Perl
60 SECTION:=lang
61 CATEGORY:=Languages
62 TITLE:=The Perl intepreter
63 URL:=http://www.perl.com/
64 DEPENDS:=+USE_GLIBC:libbsd +PERL_THREADS:libpthread @!arc
65 endef
66
67 define Package/perl/description
68 Perl is a stable, cross platform programming language.
69 It is used for mission critical projects in the public and private sectors
70 and is widely used to program web applications of all needs.
71 endef
72
73 define Package/perl/config
74 source "$(SOURCE)/Config.in"
75 endef
76
77 # Static host perl
78 define Host/Configure
79 ( cd $(HOST_BUILD_DIR); ./Configure -der -Uusedl -Duserelocatableinc -Dprefix=$(HOST_PERL_PREFIX) $(if $(CONFIG_PERL_THREADS),-Dusethreads,))
80 endef
81
82 define Host/Install
83 ( cd $(HOST_BUILD_DIR); ./miniperl installperl )
84 $(INSTALL_DIR) $(HOST_PERL_PREFIX)/bin/
85 $(CP) $(HOST_BUILD_DIR)/generate_uudmap $(HOST_PERL_PREFIX)/bin/
86
87 # Link any possibly installed static extension in
88 $(MAKE) -C $(HOST_BUILD_DIR)/relink clean || true
89 ( cd $(HOST_BUILD_DIR)/relink && $(HOST_PERL_PREFIX)/bin/perl Makefile.PL )
90 $(call perlmod/host/relink,$(HOST_BUILD_DIR)/relink)
91 endef
92
93 # Target perl
94 define Build/Configure
95 $(PERL_CMD) files/perlconfig.pl -Dowrt:target_cc='$(TARGET_CC)' \
96 -Dowrt:gccversion=$(CONFIG_GCC_VERSION) \
97 -Dowrt:target_cross='$(TARGET_CROSS)' \
98 -Dowrt:cflags='$(TARGET_CFLAGS_PERL) $(TARGET_CPPFLAGS_PERL)' \
99 -Dowrt:ldflags='$(TARGET_LDFLAGS)' \
100 -Dowrt:libc=$(subst uClibc,uclibc,$(CONFIG_LIBC)) \
101 -Dowrt:ipv6=$(if $($(CONFIG_IPV6)),define,undef) \
102 -Dowrt:threads=$(if $(CONFIG_PERL_THREADS),yes,no) \
103 -Dowrt:staging_dir='$(STAGING_DIR)' \
104 -Dowrt:host_perl_prefix='$(HOST_PERL_PREFIX)' \
105 -Dsysroot='$(TOOLCHAIN_DIR)' \
106 files/version.config \
107 files/base.config \
108 files/$(patsubst i386,i486,$(ARCH)).config \
109 files/architecture.config \
110 files/signal.config \
111 files/threads.config \
112 files/libc.config \
113 files/misc.config \
114 > $(PKG_BUILD_DIR)/config.sh
115 (cd $(PKG_BUILD_DIR) && ./Configure -S)
116 install -m 0644 $(PKG_BUILD_DIR)/config.h $(PKG_BUILD_DIR)/xconfig.h
117 endef
118
119 define Build/Compile
120 +$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)
121 endef
122
123 ifeq ($(CONFIG_arc),)
124 define Build/InstallDev
125 $(INSTALL_DIR) $(1)/usr/lib/perl5/$(PERL_VERSION)
126 $(CP) $(PKG_INSTALL_DIR)/usr/lib/perl5/$(PERL_VERSION) $(1)/usr/lib/perl5/
127 endef
128 endif
129
130 define Package/perl/install
131 $(INSTALL_DIR) $(1)/usr/bin
132 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/perl$(PKG_VERSION) $(1)/usr/bin
133 ln -nsf perl$(PKG_VERSION) $(1)/usr/bin/perl
134
135 $(INSTALL_DIR) $(1)/usr/lib/perl5/$(PERL_VERSION)/CORE
136 $(CP) $(PKG_INSTALL_DIR)/usr/lib/perl5/$(PERL_VERSION)/CORE/libperl.so $(1)/usr/lib/perl5/$(PERL_VERSION)/CORE/
137 endef
138
139
140 $(eval $(call RequireCommand,rsync, \
141 $(PKG_NAME) requires rsync installed on the host-system. \
142 ))
143
144 $(eval $(call BuildPackage,perl))
145 $(eval $(call HostBuild))
146
147 -include perlbase.mk
148
149 # A helper package that includes all sort of supplementary files for tests
150 define Package/perl-tests-common
151 $(call Package/perlbase-template)
152 TITLE:=Common test support files
153 DEPENDS:=@PERL_TESTS
154 endef
155
156 define Package/perl-tests-common/install
157 $(INSTALL_DIR) $(1)/$(PERL_TESTSDIR)
158 $(INSTALL_DIR) $(1)/$(PERL_TESTSDIR)/Porting
159 $(INSTALL_DIR) $(1)/$(PERL_TESTSDIR)/regen
160 $(INSTALL_DIR) $(1)/$(PERL_TESTSDIR)/lib
161 $(INSTALL_DIR) $(1)/usr/lib/perl5/$(PERL_VERSION)/XS
162 $(INSTALL_DIR) $(1)/usr/lib/perl5/$(PERL_VERSION)/auto/XS
163 $(INSTALL_DIR) $(1)/usr/lib/perl5/$(PERL_VERSION)/unicore
164
165 $(CP) $(PKG_BUILD_DIR)/t $(1)/$(PERL_TESTSDIR)
166 $(CP) $(PKG_BUILD_DIR)/Porting $(1)/$(PERL_TESTSDIR)
167 $(CP) $(PKG_BUILD_DIR)/regen $(1)/$(PERL_TESTSDIR)
168 $(CP) $(PKG_BUILD_DIR)/MANIFEST $(1)/$(PERL_TESTSDIR)
169 $(CP) $(PKG_BUILD_DIR)/TestInit.pm $(1)/$(PERL_TESTSDIR)
170 $(CP) $(PKG_BUILD_DIR)/vutil.c $(1)/$(PERL_TESTSDIR)
171 $(CP) $(PKG_BUILD_DIR)/vxs.inc $(1)/$(PERL_TESTSDIR)
172 $(CP) $(PKG_BUILD_DIR)/lib/XS $(1)/usr/lib/perl5/$(PERL_VERSION)/
173 $(CP) $(PKG_BUILD_DIR)/lib/auto/XS $(1)/usr/lib/perl5/$(PERL_VERSION)/auto
174 $(CP) $(PKG_BUILD_DIR)/lib/vmsish.pm $(1)/usr/lib/perl5/$(PERL_VERSION)/
175 $(CP) $(PKG_BUILD_DIR)/lib/vmsish.t $(1)/$(PERL_TESTSDIR)/lib
176 $(CP) $(PKG_BUILD_DIR)/lib/Internals.t $(1)/$(PERL_TESTSDIR)/lib
177 $(CP) $(PKG_BUILD_DIR)/lib/unicore/TestProp.pl $(1)/usr/lib/perl5/$(PERL_VERSION)/unicore
178 $(CP) files/perl-run_tests.sh $(1)/$(PERL_TESTSDIR)/run_tests.sh
179 sed \
180 -e 's!%%PERL_DISABLEDTESTS%%!$(PERL_DISABLEDTESTS)!' \
181 -e 's!%%PERL_VERSION%%!$(PERL_VERSION)!' \
182 -i $(1)/$(PERL_TESTSDIR)/run_tests.sh
183 $(CP) $(PKG_BUILD_DIR)/config_h.SH $(1)/$(PERL_TESTSDIR)
184 $(CP) $(PKG_BUILD_DIR)/perl.h $(1)/$(PERL_TESTSDIR)
185 endef
186
187 $(eval $(call BuildPackage,perl-tests-common))