Skip to contentSkip to conversation

PATCH [1/2] make Makefile.autotools.in not to use hardcoded x11r7 name when patching

Buildroot Ivan Kuten 2 participants 5 messages Sep 28, 2007 Kbuild

lore
Share & tools
lore

Ivan Kuten

author
#0 lore raw

Hello,

Here are two patches addressing hardcoded x11r7 in Makefile.autotools.in:
The first patch removes "if test -d package/x11r7/$($(PKG)_NAME)/$(NAMEVER)" and adds optional additional parameter ($(PKG)_NAME_PREFIX) when calling AUTOTARGETS for example:
$(eval $(call AUTOTARGETS,xutil_util-macros,x11r7))

---------

Makefile.autotools.in +12 -17
Index: package/Makefile.autotools.in
===================================================================
@@ -58,6 +58,9 @@
 # FOO_SUBDIR [default empty]
 #	relative path in the package source from which to run configure and
 #	make
+# FOO_NAME_PREFIX [default empty]
+#	relative path from packages directory to package *.mk file and
+#	corresponding patches
 #
 ## The following variables contain hook target names
 ## by default they do nothing, they can be overriden in package makefiles
@@ -151,25 +154,15 @@
 	$(call MESSAGE,"Patching")
 	$(if $($(PKG)_PATCH),toolchain/patch-kernel.sh $(@D) $(DL_DIR) $($(PKG)_PATCH))
 	$(Q)(\
-	if test -d package/$($(PKG)_NAME) ; then \
-	  if test "$(wildcard package/$($(PKG)_NAME)/$(NAMEVER)*.patch)" ; then \
-	    toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME) $(NAMEVER)\*.patch || exit 1 ; \
+	if test -d package/$($(PKG)_NAME_PREFIX)/$($(PKG)_NAME) ; then \
+	  if test "$(wildcard package/$($(PKG)_NAME_PREFIX)/$($(PKG)_NAME)/$(NAMEVER)*.patch)" ; then \
+	    toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME_PREFIX)/$($(PKG)_NAME) $(NAMEVER)\*.patch || exit 1 ; \
 	  else \
-	    toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME) $($(PKG)_NAME)\*.patch || exit 1 ; \
-	    if test -d package/$($(PKG)_NAME)/$(NAMEVER) ; then \
-	      toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME)/$(NAMEVER) \*.patch || exit 1 ; \
+	    toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME_PREFIX)/$($(PKG)_NAME) $($(PKG)_NAME)\*.patch || exit 1 ; \
+	    if test -d package/$($(PKG)_NAME_PREFIX)/$($(PKG)_NAME)/$(NAMEVER) ; then \
+	      toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME_PREFIX)/$($(PKG)_NAME)/$(NAMEVER) \*.patch || exit 1 ; \
 	    fi; \
 	  fi; \
-	else \
-	  echo "This must be wrong. Why do you need to special-case _any_ package here? Skipping until this is resolved properly."; \
-	  if false && test "$(wildcard package/x11r7/$($(PKG)_NAME)/$(NAMEVER)*.patch)" ; then \
-	    toolchain/patch-kernel.sh $(@D) package/x11r7/$($(PKG)_NAME) $(NAMEVER)\*.patch || exit 1 ; \
-	  else \
-	    toolchain/patch-kernel.sh $(@D) package/x11r7/$($(PKG)_NAME) $($(PKG)_NAME)\*.patch || exit 1 ; \
-	    if test -d package/x11r7/$($(PKG)_NAME)/$(NAMEVER) ; then \
-	      toolchain/patch-kernel.sh $(@D) package/x11r7/$($(PKG)_NAME)/$(NAMEVER) \*.patch || exit 1 ; \
-	    fi; \
-	  fi; \
 	fi; \
 	)
 ifeq ($(strip $(BR2_UPDATE_CONFIG)),y)
@@ -259,10 +252,11 @@
 # AUTOTARGETS -- the target generator macro; define a set of human-readable
 # make targets, stamps, and default per-package variables.
 # Argument 1 is the (lowercase) package name.
+# Argument 2 is the optional package prefix name.
 ################################################################################
 
 define AUTOTARGETS
-$(call AUTOTARGETS_INNER,$(1),$(call UPPERCASE,$(1)))
+$(call AUTOTARGETS_INNER,$(1),$(call UPPERCASE,$(1)),$(2))
 endef
 
 # AUTOTARGETS_INNER -- does the job for AUTOTARGETS; argument 1 is the
@@ -290,6 +284,7 @@
 $(2)_UNINSTALL_STAGING_OPT	?= DESTDIR=$$(STAGING_DIR) uninstall
 $(2)_UNINSTALL_TARGET_OPT	?= DESTDIR=$$(TARGET_DIR)  uninstall
 $(2)_SUBDIR			?=
+$(2)_NAME_PREFIX		=$(3)
 
 
 # define sub-target stamps

---------------------

Best regards,
Ivan

--------------------------------
Embedded Linux engineer,
Promwad Company: http://www.promwad.com/
Homepage : http://www.ivankuten.com/
--------------------------------

#1 lore raw
Quoted 6 lines · Ivan Kuten

Hello,

Here are two patches addressing hardcoded x11r7 in Makefile.autotools.in:
The first patch removes "if test -d package/x11r7/$($(PKG)_NAME)/$(NAMEVER)" and adds optional additional parameter ($(PKG)_NAME_PREFIX) when calling AUTOTARGETS

What about renaming them to DIR_OFFSET or DIR_PREFIX instead of NAME_PREFIX to make it more obvious that those are ment to be dirs.

Quoted 2 lines

for example:
$(eval $(call AUTOTARGETS,xutil_util-macros,x11r7))

That sounds very good, yes. See below

Quoted 18 lines

---------

Index: package/Makefile.autotools.in
===================================================================

Makefile.autotools.in +3 -0
@@ -58,6 +58,9 @@
 # FOO_SUBDIR [default empty]
 #	relative path in the package source from which to run configure and
 #	make
+# FOO_NAME_PREFIX [default empty]
+#	relative path from packages directory to package *.mk file and
+#	corresponding patches
 #
 ## The following variables contain hook target names
 ## by default they do nothing, they can be overriden in package makefiles

Makefile.autotools.in line 159

Quoted 9 lines
Makefile.autotools.in +3 -3
@@ -151,25 +154,15 @@
 	$(call MESSAGE,"Patching")
 	$(if $($(PKG)_PATCH),toolchain/patch-kernel.sh $(@D) $(DL_DIR) $($(PKG)_PATCH))
 	$(Q)(\
-	if test -d package/$($(PKG)_NAME) ; then \
-	  if test "$(wildcard package/$($(PKG)_NAME)/$(NAMEVER)*.patch)" ; then \
-	    toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME) $(NAMEVER)\*.patch || exit 1 ; \
+	if test -d package/$($(PKG)_NAME_PREFIX)/$($(PKG)_NAME) ; then \
+	  if test "$(wildcard package/$($(PKG)_NAME_PREFIX)/$($(PKG)_NAME)/$(NAMEVER)*.patch)" ; then \
+	    toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME_PREFIX)/$($(PKG)_NAME) $(NAMEVER)\*.patch || exit 1 ; \

This may be obvious from the context, but is @D guaranteed to exist?

cheers,

author
#2 lore raw

[Buildroot] PATCH [1/2] try2: make Makefile.autotools.in not to use hardcoded x11r7 name when patching

Quoted 4 lines

What about renaming them to DIR_OFFSET or DIR_PREFIX instead of NAME_PREFIX to make it more obvious that those are ment to be dirs.

See below.

Quoted 3 lines

This may be obvious from the context, but is @D guaranteed to exist?

Not sure - need take a look.

2nd try, introducing DIR_PREFIX:

Makefile.autotools.in +14 -19
Index: package/Makefile.autotools.in
===================================================================
@@ -58,6 +58,8 @@
 # FOO_SUBDIR [default empty]
 #	relative path in the package source from which to run configure and
 #	make
+# FOO_DIR_PREFIX [default empty]
+#	relative path to package *.mk file and corresponding patches
 #
 ## The following variables contain hook target names
 ## by default they do nothing, they can be overriden in package makefiles
@@ -151,25 +153,15 @@
 	$(call MESSAGE,"Patching")
 	$(if $($(PKG)_PATCH),toolchain/patch-kernel.sh $(@D) $(DL_DIR) $($(PKG)_PATCH))
 	$(Q)(\
-	if test -d package/$($(PKG)_NAME) ; then \
-	  if test "$(wildcard package/$($(PKG)_NAME)/$(NAMEVER)*.patch)" ; then \
-	    toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME) $(NAMEVER)\*.patch || exit 1 ; \
+	if test -d $($(PKG)_DIR_PREFIX)/$($(PKG)_NAME) ; then \
+	  if test "$(wildcard $($(PKG)_DIR_PREFIX)/$($(PKG)_NAME)/$(NAMEVER)*.patch)" ; then \
+	    toolchain/patch-kernel.sh $(@D) $($(PKG)_DIR_PREFIX)/$($(PKG)_NAME) $(NAMEVER)\*.patch || exit 1 ; \
 	  else \
-	    toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME) $($(PKG)_NAME)\*.patch || exit 1 ; \
-	    if test -d package/$($(PKG)_NAME)/$(NAMEVER) ; then \
-	      toolchain/patch-kernel.sh $(@D) package/$($(PKG)_NAME)/$(NAMEVER) \*.patch || exit 1 ; \
+	    toolchain/patch-kernel.sh $(@D) $($(PKG)_DIR_PREFIX)/$($(PKG)_NAME) $($(PKG)_NAME)\*.patch || exit 1 ; \
+	    if test -d package/$($(PKG)_DIR_PREFIX)/$($(PKG)_NAME)/$(NAMEVER) ; then \
+	      toolchain/patch-kernel.sh $(@D) $($(PKG)_DIR_PREFIX)/$($(PKG)_NAME)/$(NAMEVER) \*.patch || exit 1 ; \
 	    fi; \
 	  fi; \
-	else \
-	  echo "This must be wrong. Why do you need to special-case _any_ package here? Skipping until this is resolved properly."; \
-	  if false && test "$(wildcard package/x11r7/$($(PKG)_NAME)/$(NAMEVER)*.patch)" ; then \
-	    toolchain/patch-kernel.sh $(@D) package/x11r7/$($(PKG)_NAME) $(NAMEVER)\*.patch || exit 1 ; \
-	  else \
-	    toolchain/patch-kernel.sh $(@D) package/x11r7/$($(PKG)_NAME) $($(PKG)_NAME)\*.patch || exit 1 ; \
-	    if test -d package/x11r7/$($(PKG)_NAME)/$(NAMEVER) ; then \
-	      toolchain/patch-kernel.sh $(@D) package/x11r7/$($(PKG)_NAME)/$(NAMEVER) \*.patch || exit 1 ; \
-	    fi; \
-	  fi; \
 	fi; \
 	)
 ifeq ($(strip $(BR2_UPDATE_CONFIG)),y)
@@ -258,15 +250,17 @@
 ################################################################################
 # AUTOTARGETS -- the target generator macro; define a set of human-readable
 # make targets, stamps, and default per-package variables.
-# Argument 1 is the (lowercase) package name.
+# Argument 1 is the package dir prefix.
+# Argument 2 is the (lowercase) package name.
 ################################################################################
 
 define AUTOTARGETS
-$(call AUTOTARGETS_INNER,$(1),$(call UPPERCASE,$(1)))
+$(call AUTOTARGETS_INNER,$(2),$(call UPPERCASE,$(2)),$(1))
 endef
 
 # AUTOTARGETS_INNER -- does the job for AUTOTARGETS; argument 1 is the
-# lowercase package name, argument 2 the uppercase package name
+# lowercase package name, argument 2 the uppercase package name,
+# argument 3 the package dir prefix
 define AUTOTARGETS_INNER
 
 # define package-specific variables to default values
@@ -290,6 +284,7 @@
 $(2)_UNINSTALL_STAGING_OPT	?= DESTDIR=$$(STAGING_DIR) uninstall
 $(2)_UNINSTALL_TARGET_OPT	?= DESTDIR=$$(TARGET_DIR)  uninstall
 $(2)_SUBDIR			?=
+$(2)_DIR_PREFIX			=$(3)
 
 
 # define sub-target stamps

--
Best regards,
Ivan
--------------------------------
Embedded Linux engineer,
Promwad Company: http://www.promwad.com/
Homepage : http://www.ivankuten.com/
--------------------------------

#3 lore raw

[Buildroot] PATCH [1/2] try2: make Makefile.autotools.in not to use hardcoded x11r7 name when patching

Quoted 5 lines · Ivan Kuten
Quoted 1 line

This may be obvious from the context, but is @D guaranteed to exist?

Not sure - need take a look.

2nd try, introducing DIR_PREFIX:

Excellent, thanks!

I come to think that a _DIR_SUFFIX for the patch-dir may
be needed also (if we have an occurrance in the tree already, that is. No need to introduce this prematurely). I'm currently not aware of such packages, though.

One nice example that, if it is handled properly by the autotools.in is package/gmp or mpfr for that matter.

This package shows nicely what the autotools.in should provide in the long run:
- downloading a PATCH_FILE to the dl/
- patching package/$name/$name$version
or
patching package/$name/$version
or
patching package/$name/$($(name)_patch_regex)
or the like
- in configure, honor PREFERRED_LIB_FLAGS et al
- $(STRIP) the target, perhaps. Distinguish between binaries and libs
- optionally install headers if BR2_HAVE_HEADERS
- package-specific additional {C,LD,CPP,...}FLAGS
- package-specific additional configure-opts
- knowledge if both staging and target or only one of these should be populated with libs/binaries

author
#4 lore raw

[Buildroot] PATCH [1/2] try2: make Makefile.autotools.in not to use hardcoded x11r7 name when patching

Bernhard Fischer ?????:

Quoted 4 lines

One nice example that, if it is handled properly by the autotools.in is package/gmp or mpfr for that matter.

Quoted 17 lines

This package shows nicely what the autotools.in should provide in the long run:
- downloading a PATCH_FILE to the dl/
- patching package/$name/$name$version
or
patching package/$name/$version
or
patching package/$name/$($(name)_patch_regex)
or the like
- in configure, honor PREFERRED_LIB_FLAGS et al
- $(STRIP) the target, perhaps. Distinguish between binaries and libs
- optionally install headers if BR2_HAVE_HEADERS
- package-specific additional {C,LD,CPP,...}FLAGS
- package-specific additional configure-opts
- knowledge if both staging and target or only one of these should be populated with libs/binaries

I'll try to follow this but a bit later, now my priority is directfb/x11r7/gtk+ running on ARM. I'll post a bunch of patches related to selecting gtk+ depends on directfb or on x11r7.

Best regards,
Ivan
--------------------------------
Embedded Linux engineer,
Promwad Company: http://www.promwad.com/
Homepage : http://www.ivankuten.com/
--------------------------------