Changeset 927af3af in mainline


Ignore:
Timestamp:
2011-05-29T16:04:26Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
df56f5c
Parents:
d1671a8
Message:

Improved Makefile reentrancy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/binutils/Makefile

    rd1671a8 r927af3af  
    6161
    6262# AWK script which generates patched Makefile.common.
    63 PATCH_SCRIPT = ./patch.awk
     63MAKEFILE_PATCH = ./patch.awk
    6464
    6565# Compilers that can be used to build binutils.
     
    6868# Patched Makefile.common for ported user space applications.
    6969include $(COMMON_MAKEFILE_PATCHED)
     70
     71# Patch $PATH to intercept toolchain calls.
     72PATH := $(PWD):$(PATH)
     73
     74# Shell script for false toolchain generation.
     75TOOLCHAIN_SCRIPT = ./toolchain.sh
     76
     77# False toolchain.
     78TOOLCHAIN = ./gcc ./as ./ar ./ranlib ./ld ./objdump ./objcopy ./strip
     79
     80# Stamp indicating whether the binutils source tree is patched.
     81BINUTILS_PATCHED = ./done
     82
     83# Shell script for instrusive patches of binutils source tree.
     84BINUTILS_PATCH = ./intrusive.sh
     85
     86# Detection whether the binutils are already configured.
     87BINUTILS_CONFIGURED = $(REDIST_DIR)/Makefile
    7088
    7189# Map the HelenOS target to binutils target.
     
    99117MAKE_TARGETS = all-gas all-ld
    100118
    101 # Patch native Makefile.common.
    102 # Download and extract binutils.
    103119# Check presence of gcc compiler.
    104 # Patch $PATH to intercept toolchain calls.
    105 # Generate false toolchain.
    106 # Patch binutils.
    107 # Configure binutils for target architecture.
    108120# Make binutils.
    109121# Copy binaries.
    110 all: $(COMMON_MAKEFILE_PATCHED) all_ $(REDIST_FILENAME) $(REDIST_DETECT)
    111122ifeq ($(COMPILER),$(findstring $(COMPILER),$(SUPPORTED_COMPILERS)))
    112         OLDPATH = $(PATH)
    113         PATH = $(PWD):$(PATH)
     123all: $(COMMON_MAKEFILE_PATCHED) all_ $(TOOLCHAIN) $(BINUTILS_PATCHED) \
     124                $(BINUTILS_CONFIGURED) $(REDIST_DETECT)
    114125        export PATH
    115         ./toolchain.sh gcc $(CC) '$(CFLAGS)'
    116         ./toolchain.sh as $(AS)
    117         ./toolchain.sh ar $(AR)
    118         ./toolchain.sh ranlib
    119         ./toolchain.sh ld $(LD) '$(LFLAGS)' '$(LINKER_SCRIPT)' '$(LIBS) $(BASE_LIBS)'
    120         ./toolchain.sh objdump $(OBJDUMP)
    121         ./toolchain.sh objcopy $(OBJCOPY)
    122         ./toolchain.sh strip $(STRIP)
    123         ./intrusive.sh do $(REDIST_DIR)
    124         ORIG_DIR = $(subst $(space),\ ,$(PWD))
    125         cd $(REDIST_DIR)
    126         ./configure --target=$(TARGET) $(CONF_FLAGS)
    127         make $(MAKE_TARGETS)
    128         cd $(ORIG_DIR)
    129         cp $(REDIST_DIR)/gas/as-new ./as
    130         cp $(REDIST_DIR)/ld/ld-new ./ld
    131         PATH = $(OLDPATH)
    132         export PATH
     126        make -C $(REDIST_DIR) $(MAKE_TARGETS)
     127        cp -f $(REDIST_DIR)/gas/as-new ./as
     128        cp -f $(REDIST_DIR)/ld/ld-new ./ld
    133129else
    134         echo 'Skipped: Cannot build binutils with unsupported compiler.'
     130all:
     131        # Skipped: Cannot build binutils with unsupported compiler.
    135132endif
    136133
    137134# Create patched Makefile.common from native Makefile.common.
    138 $(COMMON_MAKEFILE_PATCHED): $(PATCH_SCRIPT) $(COMMON_MAKEFILE_NATIVE)
     135$(COMMON_MAKEFILE_PATCHED): $(MAKEFILE_PATCH) $(COMMON_MAKEFILE_NATIVE)
    139136        awk -f $^ > $@
    140137
     
    148145        mv -f $(REDIST_NAME) $(REDIST_DIR)
    149146
     147# Generate false toolchain scripts.
     148$(TOOLCHAIN): $(TOOLCHAIN_SCRIPT)
     149        $^ gcc $(CC) '$(CFLAGS)'
     150        $^ as $(AS)
     151        $^ ar $(AR)
     152        $^ ranlib
     153        $^ ld $(LD) '$(LFLAGS)' '$(LINKER_SCRIPT)' '$(LIBS) $(BASE_LIBS)'
     154        $^ objdump $(OBJDUMP)
     155        $^ objcopy $(OBJCOPY)
     156        $^ strip $(STRIP)
     157
     158# Patch binutils source tree.
     159$(BINUTILS_PATCHED): $(BINUTILS_PATCH) $(REDIST_DETECT)
     160        $^ do $(REDIST_DIR)
     161        touch $@
     162
     163# Configure binutils.
     164$(BINUTILS_CONFIGURED): $(REDIST_DIR)/configure $(REDIST_DETECT)
     165        $^ --target=$(TARGET) $(CONF_FLAGS)
     166
    150167# Delete binaries.
    151168# Clean binutils.
     
    154171clean:
    155172        rm -f as ld
    156         ORIG_DIR = $(subst $(space),\ ,$(PWD))
    157         cd $(REDIST_DIR)
    158         make distclean
    159         cd $(ORIG_DIR)
     173        make -C $(REDIST_DIR) distclean
    160174        ./intrusive.sh undo $(REDIST_DIR)
    161         rm -f gcc as ar ranlib ld objdump objcopy strip
     175        rm -f $(BINUTILS_PATCHED)
     176        rm -f $(TOOLCHAIN)
    162177        rm -f $(COMMON_MAKEFILE_PATCHED)
    163178
Note: See TracChangeset for help on using the changeset viewer.