MAKEFILE response script

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Guys, I really need help including the response file in my MAKEFILE script.  I've included my script that hold the key to solving this.

Anyway, microchip told me they can't help me so I turning towards you freaks.

 

I've to change something like:

g++/${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

to:

@$(file >linkcl.rsp,${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS})python ../build/link_with_rsp_file.py linkcl.rsp ${COMMAND}

The Python Script is as follows:

import sys, subprocess

def cmd_exec(full_cmd):
    print(full_cmd)
    sys.stdout.flush(); sys.stderr.flush()
    p = subprocess.Popen(full_cmd.split(' '))
    p.communicate()
    return p.returncode == 0

rsp_file, cmd = sys.argv[1], sys.argv[2:]
cmd = ' '.join(cmd)

# First replace all '\' with '/' in the response file (bash doesn't deal well with '\')
with open(rsp_file, "r") as f: linkcl = f.read()
linkcl = linkcl.replace('\\', '/')
with open(rsp_file, "w") as f: f.write(linkcl)

# Call the linker
cmd_exec("{cmd} @{rsp_file}".format(cmd=cmd, rsp_file=rsp_file))

 

 

MAKEFILE

VERSION = 2.15
DEFAULT_AVAILABLE_TARGETS = sama5d4-generic sama5d4-xplained sama5d4-ek \
		   sama5d2-generic sama5d2-xplained \
		   sama5d2-vb-bga196 sama5d2-vb-bga289 \
		   sama5d27-som1-ek sama5d2-ptc-ek \
		   sama5d3-generic sama5d3-xplained sama5d3-ek \
		   sam9g15-generic sam9g25-generic sam9g35-generic \
		   sam9x25-generic sam9x35-generic \
		   sam9g15-ek sam9g25-ek sam9g35-ek \
		   sam9x25-ek sam9x35-ek \
		   sam9x60-generic \
		   sam9x60-ek \
		   samv71-generic same70-xplained samv71-xplained
AVAILABLE_TARGETS ?= $(DEFAULT_AVAILABLE_TARGETS)
AVAILABLE_VARIANTS ?= sram ddram qspi0 qspi1 flash
VARIANT ?= ddram

eq = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))

ifndef TARGET
$(error "No TARGET specified.")
endif

ifndef $(or RELEASE,DEBUG)
DEBUG = 5
endif


### Expand '*' available targets from example makefiles
TARGETS := $(subst *,%,$(filter %*,$(AVAILABLE_TARGETS)))
AVAILABLE_TARGETS := $(filter-out %*,$(AVAILABLE_TARGETS))
TARGETS := $(foreach target,$(TARGETS),$(filter $(TARGETS),$(DEFAULT_AVAILABLE_TARGETS)))
AVAILABLE_TARGETS += $(TARGETS)
AVAILABLE_TARGETS := $(sort $(AVAILABLE_TARGETS))
SELECTED_TARGET = $(strip $(foreach target,$(AVAILABLE_TARGETS),$(if $(call eq,$(TARGET),$(target)),$(target))))
###

ifeq ($(SELECTED_TARGET),)
$(info The selected target "$(TARGET)" is not supported or not available)
$(error Please set TARGET to one value from the list above: $(AVAILABLE_TARGETS))
endif

ifeq ($(V),1)
Q :=
ECHO := @true
else
Q := @
ECHO := @echo
endif

#-------------------------------------------------------------------------------
#		Create version string using git if possible
#-------------------------------------------------------------------------------
GIT_VERSION = $(shell if git rev-parse --show-toplevel >/dev/null 2>&1 ; \
	then git describe --tags --dirty; fi)
ifneq ($(GIT_VERSION),)
SOFTPACK_VERSION := $(VERSION) ($(GIT_VERSION))
else
SOFTPACK_VERSION := $(VERSION)
endif

#-------------------------------------------------------------------------------
#		Setup cross-compilation tools
#-------------------------------------------------------------------------------
# Tool suffix when cross-compiling
CROSS_COMPILE ?= arm-none-eabi-

# Compilation tools
CC = $(CROSS_COMPILE)gcc
CPP = $(CROSS_COMPILE)g++
LD = $(CROSS_COMPILE)ld
SIZE = $(CROSS_COMPILE)size
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
GDB = $(CROSS_COMPILE)gdb
NM = $(CROSS_COMPILE)nm
AR = $(CROSS_COMPILE)ar

#-------------------------------------------------------------------------------
#		Setup compilation params
#-------------------------------------------------------------------------------


CFLAGS_OPT ?= -Os

# compiler flags
CFLAGS = -Wall -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int
CFLAGS += -Werror-implicit-function-declaration -Wmain -Wparentheses
CFLAGS += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs
CFLAGS += -Wuninitialized -Wunknown-pragmas -Wundef
CFLAGS += -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings
CFLAGS += -Waggregate-return -Wstrict-prototypes
CFLAGS += -Wmissing-prototypes -Wmissing-declarations
CFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations
CFLAGS += -Wredundant-decls -Wnested-externs -Winline
CFLAGS += -Wunreachable-code -Wno-aggregate-return -Wall -Dprintf=iprintf
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -std=gnu99
CFLAGS += $(CFLAGS_OPT)

CPPFLAGS = -Wall -std=c++11 -fexceptions
CPPFLAGS += $(CFLAGS_OPT)


CFLAGS_ASM = -Wall -D__ASSEMBLY__

CFLAGS_DEFS += -DSOFTPACK_VERSION="\"$(SOFTPACK_VERSION)\""

# Trace level used for compilation
# (can be overriden by adding TRACE_LEVEL=#number to the command-line)
# TRACE_LEVEL_DEBUG      5
# TRACE_LEVEL_INFO       4
# TRACE_LEVEL_WARNING    3
# TRACE_LEVEL_ERROR      2
# TRACE_LEVEL_FATAL      1
# TRACE_LEVEL_NO_TRACE   0
ifdef DEBUG
TRACE_LEVEL ?= 2
CFLAGS_DEFS += -DTRACE_LEVEL=$(TRACE_LEVEL)
CFLAGS += -g3
CFLAGS_ASM += -g3
else
TRACE_LEVEL ?= 2
CFLAGS_DEFS += -DNDEBUG -DTRACE_LEVEL=$(TRACE_LEVEL)
endif

# append variant define
CFLAGS_DEFS += -DVARIANT_$(shell echo $(VARIANT) | tr '[:lower:]' '[:upper:]')

# linker flags
LDFLAGS = -Wall -Wl,-lstdc++ -fexceptions -specs=nosys.specs -Wl,--cref -Wl,--check-sections -Wl,--gc-sections
LDFLAGS += -Wl,--unresolved-symbols=report-all -Wl,--warn-common
LDFLAGS += -Wl,--sort-section=alignment








# include target-specific config
include $(TOP)/scripts/Makefile.vars.sam9xx5
include $(TOP)/scripts/Makefile.vars.sam9x60
include $(TOP)/scripts/Makefile.vars.sama5d2
include $(TOP)/scripts/Makefile.vars.sama5d3
include $(TOP)/scripts/Makefile.vars.sama5d4
include $(TOP)/scripts/Makefile.vars.samv71

# check if variant is compatible with example (AVAILABLE_VARIANTS) and SoC (COMPATIBLE_VARIANTS)
ALL_VARIANTS := $(filter $(AVAILABLE_VARIANTS), $(COMPATIBLE_VARIANTS))
SELECTED_VARIANT := $(strip $(foreach variant,$(ALL_VARIANTS),$(if $(call eq,$(VARIANT),$(variant)),$(variant))))
ifeq ($(SELECTED_VARIANT),)
$(info The selected variant "$(VARIANT)" is not supported or not available)
$(error Please set VARIANT to one value from the list above: $(ALL_VARIANTS))
endif

 

This topic has a solution.
Last Edited: Wed. Jul 21, 2021 - 06:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there a question in there? - haven't a clue what it is you are asking??

 

Try to consider that no one here has the first idea what your project is about or what you are trying to achieve so you need to put us in the picture about that first.

 

It *looks* like it might be something about switching between Windows and Linux style paths and perhaps something to do with the linker phase - but who knows??

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's more likely the edited file is here.  I want to run a response file to stop the files from being truncated.


# default target
all::

include $(TOP)/scripts/Makefile.vars

BUILDDIR ?= ./build/$(TARGET)/$(VARIANT)

#-------------------------------------------------------------------------------
#		Rules
#-------------------------------------------------------------------------------

include $(TOP)/samba_applets/common/Makefile.inc
include $(TOP)/flash_loaders/applets/common/Makefile.inc
include $(TOP)/scripts/Makefile.config
include $(TOP)/arch/Makefile.inc
include $(TOP)/utils/Makefile.inc
include $(TOP)/target/Makefile.inc
include $(TOP)/drivers/Makefile.inc
include $(TOP)/lib/Makefile.inc
include $(TOP)/scripts/Makefile.freertos


vpath %.cpp $(TOP)
vpath %.c $(TOP)
vpath %.S $(TOP)

OBJS := $(addprefix $(BUILDDIR)/, $(gnu-cstartup-y) $(obj-y))
LIBS := $(addprefix $(BUILDDIR)/,$(lib-y))

-include $(OBJS:.o=.d)

.PHONY: all build clean size debug

all:: build

build: $(BUILDDIR)/$(BINNAME).elf \
	$(BUILDDIR)/$(BINNAME).symbols \
	$(BUILDDIR)/$(BINNAME).bin

ifeq ($(VARIANT),ddram)
CONFIG_BOOTSTRAP ?= y
ifeq ($(CONFIG_BOOTSTRAP),y)
$(BUILDDIR)/$(BINNAME).elf: $(BUILDDIR)/target/bootstrap.elf

$(BUILDDIR)/target/bootstrap.elf: $(BOOTSTRAP_OBJS) $(LIBS)
	@mkdir -p $(dir $@)
	$(ECHO) LINK $@
	$(Q)$(CC) $(LDFLAGS) $(CFLAGS_CPU) $(CFLAGS_DEFS) -T$(bootstrap-linker-script-y) -Wl,-Map,$(BUILDDIR)/bootstrap.map -o $@ $(BOOTSTRAP_OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group
endif
endif 

$(BUILDDIR):
	@mkdir -p $(BUILDDIR)


$(BUILDDIR)/%.d: %.cpp
	@mkdir -p $(dir $@)printf
	$(ECHO) DEP $<
	$(Q)$(CPP) $(CPPFLAGS) $(CFLAGS_CPU) $() $(CFLAGS_DEFS) -MM $< -MT $(basename $@).o -o $(basename $@).d

$(BUILDDIR)/%.o: %.cpp
	@mkdir -p $(dir $@)
	$(ECHO) CC $<
	$(Q)$(CPP) $(CPPFLAGS) $(CFLAGS_CPU) $() $(CFLAGS_DEFS) -c $< -o $@

$(BUILDDIR)/%.d: %.c
	@mkdir -p $(dir $@)printf
	$(ECHO) DEP $<
	$(Q)$(CC) $(CFLAGS) $(CFLAGS_CPU) $(CFLAGS_INC) $(CFLAGS_DEFS) -MM $< -MT $(basename $@).o -o $(basename $@).d

$(BUILDDIR)/%.o: %.c
	@mkdir -p $(dir $@)
	$(ECHO) CC $<
	$(Q)$(CC) $(CFLAGS) $(CFLAGS_CPU) $(CFLAGS_INC) $(CFLAGS_DEFS) -c $< -o $@

$(BUILDDIR)/%.d: %.S
	@mkdir -p $(dir $@)
	$(ECHO) DEP $<
	$(Q)$(CC) $(CFLAGS_ASM) $(CFLAGS_CPU) $(CFLAGS_INC) $(CFLAGS_DEFS) -MM $< -MT $(basename $@).o -o $(basename $@).d

$(BUILDDIR)/%.o: %.S
	@mkdir -p $(dir $@)
	$(ECHO) CC $<
	$(Q)$(CC) $(CFLAGS_ASM) $(CFLAGS_CPU) $(CFLAGS_INC) $(CFLAGS_DEFS) -c $< -o $@



$(BUILDDIR)/$(BINNAME).elf: $(OBJS) $(LIBS) $(gnu-debug-lib-y) $(gnu-linker-script-y)
	@cp $(gnu-debug-lib-y) $(BUILDDIR)/target/
	$(ECHO) LINK $@
	$(Q)$(CPP) $(LDFLAGS) $(CFLAGS_CPU) $(CFLAGS_DEFS) -T$(gnu-linker-script-y) -Wl,-Map,$(BUILDDIR)/$(BINNAME).map -o $@ $(OBJS) -Wl,--start-group $(LIBS) -Wl,--end-group -Wl,--no-undefined
$(BUILDDIR)/$(BINNAME).symbols: $(BUILDDIR)/$(BINNAME).elf
	$(Q)$(NM) $< >$@

$(BUILDDIR)/$(BINNAME).bin: $(BUILDDIR)/$(BINNAME).elf
	$(ECHO) OBJCOPY $@
	$(Q)$(OBJCOPY) -O binary $< $@

clean:
	@rm -rf $(BUILDDIR) settings
	@rm -f $(BINNAME).eww $(BINNAME)_$(TARGET).ewp $(BINNAME)_$(TARGET).ewd $(BINNAME)_$(TARGET).ewt $(BINNAME)_$(TARGET).dep

size: $(BUILDDIR)/$(BINNAME).elf
	@$(SIZE) $(OBJECTS) $(BUILDDIR)/$(BINNAME).elf

debug: $(BUILDDIR)/$(BINNAME).elf
	$(Q)$(GDB) -cd $(BUILDDIR) -x "$(realpath $(gnu-debug-script-y))" -ex "reset" -readnow -se $(realpath $(BUILDDIR)/$(BINNAME).elf)

include $(TOP)/scripts/Makefile.iar

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is a ridiculous command-line limit. Back when I worked with some embedded "experts" for a few years, they built everything on Solaris and Linux. I guess they did not trust ether completely. But their disgust with the limitations of Windows got seared into my brain. Afterward, I have steered away from Windows for building things other than VB (and ilk) in Visual Studio, which I have not used in years.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At the start I was already thinking that there was a limit on the size of the object source file address.  And I was right!