Hello,
I am trying to edit and existing Makefile. That's perl 5.8.7 Makefile by frol (see http://forum.openwrt.org/viewtopic.php?id=4122).
This is an old style Makefile which perfectly works on WhiteRussian SDK, but doesn't work on the OpenWrt Buildroot, because it lacks of some "define" directives.
I can't retrieve on the internet a good tutorial for this operation sad I tried to add define "Package/perl", "Package/perl/description", "Build/Configure", "Build/Compile" and "package/perl/install" directives, but depending of the order of them, the builder doesn't execute the makefile in the right order, or displays compilation errors. And that's not normal, because on WhiteRussian SDK it worked!
I am getting hopeless, I don't know where I have to put the hands to fix it sad
This is the original Makefile.

# $Id$
# 

include $(TOPDIR)/rules.mk

PKG_NAME:=perl
PKG_VERSION:=5.8.7
PKG_RELEASE:=1
PKG_MD5SUM:=9a175d6ccbb5d9b41ffac5073ff9cc3c

PKG_SOURCE_URL:=ftp://ftp.cpan.org/pub/CPAN/src/5.0 \
            ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/src/5.0 \
           ftp://ftp.gmd.de/mirrors/CPAN/src/5.0 \
        ftp://ftp.funet.fi/pub/languages/perl/CPAN/src/5.0
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_CAT:=bzcat

PKG_BUILD_DIR:=$(BUILD_DIR)/perl/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install

include $(TOPDIR)/package/rules.mk

$(eval $(call PKG_template,PERL,perl,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))

PKG_DIR:=${shell pwd}

$(PKG_BUILD_DIR)/.stage1:
    @echo ""
    @echo "===> Stage 1: Configure host perl"
    @echo ""
    mkdir -p $(PKG_BUILD_DIR)/host-perl
    (cd $(PKG_BUILD_DIR)/host-perl && sh ../Configure -der -Dmksymlinks)
    touch $@

$(PKG_BUILD_DIR)/.stage2: $(PKG_BUILD_DIR)/.stage1 $(PKG_BUILD_DIR)/.stage1
    @echo ""
    @echo "===> Stage 2: Build host miniperl binary"
    @echo ""
    $(MAKE) -C $(PKG_BUILD_DIR)/host-perl miniperl
    touch $@

$(PKG_BUILD_DIR)/.stage3: $(PKG_BUILD_DIR)/.stage2
    @echo ""
    @echo "===> Stage 3: Configure target perl"
    @echo ""
    -$(MAKE) -C $(PKG_BUILD_DIR) clean
    mkdir -p $(PKG_BUILD_DIR)/target-bin
    sed -e 's!%%CC%%!${TARGET_CC}!g' \
        -e 's!%%CFLAGS%%!${TARGET_CFLAGS} -DUSE_CROSS_COMPILE -I${STAGING_DIR}/include -I${STAGING_DIR}/usr/include!g' \
        -e 's!%%CPP%%!${TARGET_CROSS}gcc -E!g' \
        -e 's!%%AR%%!${TARGET_CROSS}ar!g' \
        -e 's!%%LD%%!${TARGET_CROSS}gcc!g' \
        -e 's!%%LDFLAGS%%!-rdynamic -L${STAGING_DIR}/lib -L${STAGING_DIR}/usr/lib!g' \
        -e 's!%%LIBDIRS%%!${STAGING_DIR}/lib ${STAGING_DIR}/usr/lib!g' \
        -e 's!%%INCDIRS%%!${STAGING_DIR}/include ${STAGING_DIR}/usr/include!g' \
        $(PKG_DIR)/files/config.sh-mipsel-linux-uclibc.in \
        > $(PKG_BUILD_DIR)/config.sh
    (cd $(PKG_BUILD_DIR) && ./Configure -S)
    touch $@

$(PKG_BUILD_DIR)/.stage4: $(PKG_BUILD_DIR)/.stage3
    @echo ""
    @echo "===> Stage 4: Build target miniperl binary"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/miniperl
    $(MAKE) -C $(PKG_BUILD_DIR) miniperl
    install -m 0755 $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/target-bin/
    touch $@

$(PKG_BUILD_DIR)/.stage5: $(PKG_BUILD_DIR)/.stage4
    @echo ""
    @echo "===> Stage 5: Build target perl binary"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/perl
    install -m 0755 $(PKG_BUILD_DIR)/host-perl/miniperl $(PKG_BUILD_DIR)/
    touch $(PKG_BUILD_DIR)/miniperl
    $(MAKE) -C $(PKG_BUILD_DIR) perl
    install -m 0755 $(PKG_BUILD_DIR)/perl $(PKG_BUILD_DIR)/target-bin/
    touch $@

$(PKG_BUILD_DIR)/.stage6: $(PKG_BUILD_DIR)/.stage5
    @echo ""
    @echo "===> Stage 6: Build target extensions and utils"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/perl
    install -m 0755 $(PKG_BUILD_DIR)/host-perl/miniperl \
        $(PKG_BUILD_DIR)/
    ln -sf miniperl $(PKG_BUILD_DIR)/perl
    touch $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/perl
    $(MAKE) -C $(PKG_BUILD_DIR)
    touch $@

$(PKG_BUILD_DIR)/.stage7: $(PKG_BUILD_DIR)/.stage6
    @echo ""
    @echo "===> Stage 7: Install Perl into staging dir"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/perl
    install -m 0755 $(PKG_BUILD_DIR)/host-perl/miniperl \
        $(PKG_BUILD_DIR)/perl
    (cd $(PKG_BUILD_DIR) && ./perl installperl \
        --destdir=$(STAGING_DIR))
    touch $@

$(PKG_BUILD_DIR)/.stage8: $(PKG_BUILD_DIR)/.stage7
    @echo ""
    @echo "===> Stage 8: Install Perl into a temporary root"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/perl
    install -m 0755 $(PKG_BUILD_DIR)/target-bin/perl \
        $(PKG_BUILD_DIR)/
    -rm -rf $(PKG_INSTALL_DIR)
    mkdir -p $(PKG_INSTALL_DIR)
    (cd $(PKG_BUILD_DIR) && host-perl/miniperl installperl \
        --destdir=$(PKG_INSTALL_DIR))
    chmod -R +w $(PKG_INSTALL_DIR)
    sh $(PKG_DIR)/files/deletepod.sh $(PKG_INSTALL_DIR)
    sh $(PKG_DIR)/files/strippm.sh $(PKG_INSTALL_DIR)
    $(RSTRIP) $(PKG_INSTALL_DIR)
    touch $@

$(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.stage1 $(PKG_BUILD_DIR)/.stage3
    touch $@

$(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.stage8
    touch $@

$(IPKG_PERL):
    install -d -m0755 $(IDIR_PERL)/usr/bin
    install -m0755 $(PKG_INSTALL_DIR)/usr/bin/perl$(PKG_VERSION) \
        $(IDIR_PERL)/usr/bin/
    ln -f $(IDIR_PERL)/usr/bin/perl$(PKG_VERSION) $(IDIR_PERL)/usr/bin/perl
    $(IPKG_BUILD) $(IDIR_PERL) $(PACKAGE_DIR)

# module package template
define ipkg_pm

$$(eval $$(call PKG_template,$(1),$(2),$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))

$$(IPKG_$(1)):
    sh $(PKG_DIR)/files/install-module.sh \
        $(PKG_INSTALL_DIR)/usr/lib/perl5/5.8 \
        $$(IDIR_$(1))/usr/lib/perl5/5.8 \
        $(3)
    $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
endef

include $(PKG_DIR)/Makefile.modules

I also tried toboz's Makefile (see http://forum.openwrt.org/viewtopic.php?id=10117) for Perl 5.8.8 (next version). It compiles, but some modules functionalities doesn't work. (Time::HiRes)
Your help would be much appreciated. I am getting confused! sad
Thank you
----
I past my Makefile. Maybe it can be useful

include $(TOPDIR)/rules.mk

PKG_NAME:=perl
PKG_VERSION:=5.8.7
PKG_RELEASE:=1

PKG_DIR:=$(TOPDIR)/package/$(PKG_NAME)

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=ftp://ftp.cpan.org/pub/CPAN/src/5.0 \
            ftp://ftp.mpi-sb.mpg.de/pub/perl/CPAN/src/5.0 \
           ftp://ftp.gmd.de/mirrors/CPAN/src/5.0 \
        ftp://ftp.funet.fi/pub/languages/perl/CPAN/src/5.0
PKG_MD5SUM:=9a175d6ccbb5d9b41ffac5073ff9cc3c
PKG_CAT:=bzcat

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)
PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install

include $(INCLUDE_DIR)/package.mk
include perlmod.mk

define Package/perl
  SECTION:=lang
  CATEGORY:=Languages
  URL:=http://www.cpan.org/
  MAINTAINER:=Dmitry Frolov <frol@nov.net>
  TITLE:=Perl language
endef

define Package/perl/description
Perl language for OpenWrt
endef

$(PKG_BUILD_DIR)/.stage1:
    @echo ""
    @echo "===> Stage 1: Configure host perl"
    @echo ""
    mkdir -p $(PKG_BUILD_DIR)/host-perl
    (cd $(PKG_BUILD_DIR)/host-perl && sh ../Configure -der -Dmksymlinks)
    touch $@

$(PKG_BUILD_DIR)/.stage2: $(PKG_BUILD_DIR)/.stage1 $(PKG_BUILD_DIR)/.stage1
    @echo ""
    @echo "===> Stage 2: Build host miniperl binary"
    @echo ""
    $(MAKE) -C $(PKG_BUILD_DIR)/host-perl miniperl
    touch $@

$(PKG_BUILD_DIR)/.stage3: $(PKG_BUILD_DIR)/.stage2
    @echo ""
    @echo "===> Stage 3: Configure target perl"
    @echo ""
    -$(MAKE) -C $(PKG_BUILD_DIR) clean
    mkdir -p $(PKG_BUILD_DIR)/target-bin
    sed -e 's!%%CC%%!${TARGET_CC}!g' \
        -e 's!%%CFLAGS%%!${TARGET_CFLAGS} -DUSE_CROSS_COMPILE -I${STAGING_DIR}/include -I${STAGING_DIR}/usr/include!g' \
        -e 's!%%CPP%%!${TARGET_CROSS}gcc -E!g' \
        -e 's!%%AR%%!${TARGET_CROSS}ar!g' \
        -e 's!%%LD%%!${TARGET_CROSS}gcc!g' \
        -e 's!%%LDFLAGS%%!-rdynamic -L${STAGING_DIR}/lib -L${STAGING_DIR}/usr/lib!g' \
        -e 's!%%LIBDIRS%%!${STAGING_DIR}/lib ${STAGING_DIR}/usr/lib!g' \
        -e 's!%%INCDIRS%%!${STAGING_DIR}/include ${STAGING_DIR}/usr/include!g' \
        $(PKG_DIR)/files/config.sh-mipsel-linux-uclibc.in \
        > $(PKG_BUILD_DIR)/config.sh
    (cd $(PKG_BUILD_DIR) && ./Configure -S)
    touch $@

$(PKG_BUILD_DIR)/.stage4: $(PKG_BUILD_DIR)/.stage3
    @echo ""
    @echo "===> Stage 4: Build target miniperl binary"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/miniperl
    $(MAKE) -C $(PKG_BUILD_DIR) miniperl
    install -m 0755 $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/target-bin/
    touch $@

$(PKG_BUILD_DIR)/.stage5: $(PKG_BUILD_DIR)/.stage4
    @echo ""
    @echo "===> Stage 5: Build target perl binary"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/perl
    install -m 0755 $(PKG_BUILD_DIR)/host-perl/miniperl $(PKG_BUILD_DIR)/
    touch $(PKG_BUILD_DIR)/miniperl
    $(MAKE) -C $(PKG_BUILD_DIR) perl
    install -m 0755 $(PKG_BUILD_DIR)/perl $(PKG_BUILD_DIR)/target-bin/
    touch $@

$(PKG_BUILD_DIR)/.stage6: $(PKG_BUILD_DIR)/.stage5
    @echo ""
    @echo "===> Stage 6: Build target extensions and utils"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/perl
    install -m 0755 $(PKG_BUILD_DIR)/host-perl/miniperl \
        $(PKG_BUILD_DIR)/
    ln -sf miniperl $(PKG_BUILD_DIR)/perl
    touch $(PKG_BUILD_DIR)/miniperl $(PKG_BUILD_DIR)/perl
    $(MAKE) -C $(PKG_BUILD_DIR)
    touch $@

$(PKG_BUILD_DIR)/.stage7: $(PKG_BUILD_DIR)/.stage6
    @echo ""
    @echo "===> Stage 7: Install Perl into staging dir"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/perl
    install -m 0755 $(PKG_BUILD_DIR)/host-perl/miniperl \
        $(PKG_BUILD_DIR)/perl
    (cd $(PKG_BUILD_DIR) && ./perl installperl \
        --destdir=$(STAGING_DIR))
    touch $@

$(PKG_BUILD_DIR)/.stage8: $(PKG_BUILD_DIR)/.stage7
    @echo ""
    @echo "===> Stage 8: Install Perl into a temporary root"
    @echo ""
    -rm -f $(PKG_BUILD_DIR)/perl
    install -m 0755 $(PKG_BUILD_DIR)/target-bin/perl \
        $(PKG_BUILD_DIR)/
    -rm -rf $(PKG_INSTALL_DIR)
    mkdir -p $(PKG_INSTALL_DIR)
    (cd $(PKG_BUILD_DIR) && host-perl/miniperl installperl \
        --destdir=$(PKG_INSTALL_DIR))
    chmod -R +w $(PKG_INSTALL_DIR)
    sh $(PKG_DIR)/files/deletepod.sh $(PKG_INSTALL_DIR)
    sh $(PKG_DIR)/files/strippm.sh $(PKG_INSTALL_DIR)
    $(RSTRIP) $(PKG_INSTALL_DIR)
    touch $@

$(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.stage1 $(PKG_BUILD_DIR)/.stage3
    touch $@

$(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.stage8
    touch $@

$(IPKG_PERL):
    install -d -m0755 $(IDIR_PERL)/usr/bin
    install -m0755 $(PKG_INSTALL_DIR)/usr/bin/perl$(PKG_VERSION) \
        $(IDIR_PERL)/usr/bin/
    ln -f $(IDIR_PERL)/usr/bin/perl$(PKG_VERSION) $(IDIR_PERL)/usr/bin/perl
    $(IPKG_BUILD) $(IDIR_PERL) $(PACKAGE_DIR)

# module package template
define ipkg_pm

$$(eval $$(call PKG_template,$(1),$(2),$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))

$$(IPKG_$(1)):
    sh $(PKG_DIR)/files/install-module.sh \
        $(PKG_INSTALL_DIR)/usr/lib/perl5/5.8 \
        $$(IDIR_$(1))/usr/lib/perl5/5.8 \
        $(3)
    $(IPKG_BUILD) $$(IDIR_$(1)) $(PACKAGE_DIR)
endef

-include perlbase.mk

and my error

===> Stage 4: Build target miniperl binary

rm -f /home/gabriele/buildroot_r7118_p587/build_mipsel/perl/perl-5.8.7/miniperl
make -C /home/gabriele/buildroot_r7118_p587/build_mipsel/perl/perl-5.8.7 miniperl
make[3]: Entering directory `/home/gabriele/buildroot_r7118_p587/build_mipsel/perl/perl-5.8.7'
`sh  cflags "optimize=''" miniperlmain.o`  miniperlmain.c
      CCCMD =  mipsel-linux-uclibc-gcc -DPERL_CORE -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -DUSE_CROSS_COMPILE -I/home/gabriele/buildroot_r7118_p587/staging_dir_mipsel/include -I/home/gabriele/buildroot_r7118_p587/staging_dir_mipsel/usr/include   -Wall
In file included from perl.h:37,
                 from miniperlmain.c:36:
config.h:3702:3: error: invalid preprocessing directive #HASATTRIBUTE
make[3]: *** [miniperlmain.o] Error 1
make[3]: Leaving directory `/home/gabriele/buildroot_r7118_p587/build_mipsel/perl/perl-5.8.7'
make[2]: *** [/home/gabriele/buildroot_r7118_p587/build_mipsel/perl/perl-5.8.7/.stage4] Error 2
make[2]: Leaving directory `/home/gabriele/buildroot_r7118_p587/package/perl'
make[1]: *** [perl-compile] Error 2
make[1]: Leaving directory `/home/gabriele/buildroot_r7118_p587/package'
make: *** [package/perl-compile] Error 2

On the SDK the command which gives the error is:

      CCCMD =  mipsel-linux-uclibc-gcc -DPERL_CORE -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -DUSE_CROSS_COMPILE -I/home/gabriele/buildroot_r7118_p587/staging_dir_mipsel/include -I/home/gabriele/buildroot_r7118_p587/staging_dir_mipsel/usr/include -O -Wall

instead of

      CCCMD =  mipsel-linux-uclibc-gcc -DPERL_CORE -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -DUSE_CROSS_COMPILE -I/home/gabriele/buildroot_r7118_p587/staging_dir_mipsel/include -I/home/gabriele/buildroot_r7118_p587/staging_dir_mipsel/usr/include   -Wall

But I don't think that is the problem sad

(Last edited by ggp81 on 28 May 2007, 12:25)