Hi ,
This is my "makefile" :
--------------------------------------------------------------------------------------------
# # configurable options# - set DEBUG = 1 to turn on debugging support#
DEBUG = 1
PROJ_NAME = myapp
INSTALL_DIR =
PROGS := $(PROJ_NAME).exe# CFLAGS +=
cflags += -o0 -g # # You should not need to modify anything beyond this point#
TOPDIR = .
include $(TOPDIR)/Rules.mak
ifeq '$(DEBUG)' '1'
PROGS += $(PROGS:.exe=.gdb)
endif
# all: $(PROGS)
all: myapp.exe myapp.gdb .PHONY: clean
clean:
-rm -f *.[oad] *.elf *.gdb *.bin *.exe
.PHONY: install
install: all
ifeq "$(INSTALL_DIR)" ""
$(error No installation directory specified)
endif
mkdir -p $(INSTALL_DIR)/bin
install -v $(filter %.exe, $(PROGS)) $(INSTALL_DIR)/bin
----------------------------------------------------------------------------------------------
I can easily create a gdb and debug my HelloWorld application with this makefile, but when I use this for a bigger one of mine , I cannot create it.
I tried to remove ".PHONY: clean ... " but things are not better
This is "Rules.mak" :
----------------------------------------------------------------------------------------------
# ########################################################################## Variables and Rules for building Nios II Linux applications# # This file is a "template" that is copied over from the Nios II Linux# Application plug-in. This file should be included within your top-level# Makefile.#
ifeq "$(origin TOPDIR)" "undefined"
TOPDIR := $(shell pwd)
endif
# # The Settings.mak file is automatically generated by Eclipse. It# contains values for all external variables used by this Makefile# fragment.# # The "dash" in front of the include statement indicates that the Make# process will not terminate if it cannot find the Settings.mak file.#
-include $(TOPDIR)/Settings.mak
# This turns on various levels of hardware multiply support# Set the following option to none, mul, or mulx# none := no hardware multiplication support at all# mul := supports use of the mul assembler instruction# mulx := supports use of the mul and mulx assembler instruction
ifeq "$(HW_MUL_SUPPORT)" ""
HW_MUL_SUPPORT := mulx
endif
# # Warn users if external variables have not yet been defined.#
ifeq "$(origin UTILSDIR)" "undefined"
$(warning The location of the utiltiies directory is undefined)
endif
ifeq "$(origin LIBCDIR)" "undefined"
$(warning The location of uClibc is undefined)
endif
# # Path + Name of necessary executables#
EXECSUFFIX := .exe
CROSS := nios2-elf-
CC := $(CROSS)gcc
AR := $(CROSS)ar
LD := $(CROSS)ld
NM := $(CROSS)nm
RANLIB := $(CROSS)ranlib
STRIPTOOL := $(CROSS)strip
ELF2FLT := $(UTILSDIR)/bin/elf2flt
# # Location of important files#
CRT0 := $(LIBCDIR)/lib/crt0.o
LIBC := $(LIBCDIR)/lib/libc.a
LIBGCC := $(shell $(CC) -print-file-name=libgcc.a)
LIBM := $(shell $(CC) -print-file-name=libm.a)
LIBGCCDIR := $(dir $(LIBGCC))
LINKSCRIPT := $(UTILSDIR)/scripts/elf2flt.ld
# # Various flags, modifications are not recommended and not necessarily# supported.# # DEPFLAGS:# -MM : ignore system includes, # -M : include system includes in the dependency#
WARNING_FLAGS := -Wall
# basic C flags to pass to the compiler
CFLAGS += -nostdinc -D__linux__
# if DEBUG is turned on, then turn off optimizations and turn on symbol# generation, else turn on level 2 optimizations
ifeq ($(DEBUG),1)
CFLAGS += -O0 -g
else
CFLAGS += -O2
endif
# pass any additional include directories to the compiler while building the# application
CFLAGS += -I$(LIBCDIR)/include -I$(LIBGCCDIR)/include
# Temporary workaround for nios2-elf-gcc bug# First noticed in v3.4.1 (Altera Nios II 1.1 b131)# To be removed at a later date when bug is resolved.
CFLAGS += -fno-optimize-sibling-calls
# Turn on the various levels of hardware multiplication support.
ifeq ($(strip $(HW_MUL_SUPPORT)),none)
CFLAGS += -mno-hw-mul -mno-hw-mulx
endif
ifeq ($(strip $(HW_MUL_SUPPORT)),mul)
CFLAGS += -mhw-mul -mno-hw-mulx
endif
ifeq ($(strip $(HW_MUL_SUPPORT)),mulx)
CFLAGS += -mhw-mul -mhw-mulx
endif
mulx_help_text := $(shell $(CC) --target-help | grep mulx)
ifeq "$(mulx_help_text)" ""
CFLAGS := $(filter-out -mhw-mulx -mno-hw-mulx, $(CFLAGS))
endif
DEPFLAGS = -E -MM
LDFLAGS := -msys-crt0=$(CRT0) -r -d -L$(LIBCDIR)/lib
LDLIBS := $(LIBM) $(LIBGCC) $(LIBC)
# relocate the absolute elf file if requested
ifneq ($(TEXT),)
TEXT_LOC_OPT := -Ttext $(TEXT)
endif
ifneq ($(DATA),)
DATA_LOC_OPT := -Tdata $(DATA)
endif
ifneq ($(BSS),)
BSS_LOC_OPT := -Tbss $(BSS)
endif
# default stack size is 4K
FLTFLAGS:=
%.exe : %.flt
cp -f $< $@
# # Make a relocatable flat file from an ELF file.# STACKSIZE is defined by individual makefiles.#
%.flt : %.elf
$(ELF2FLT) $(FLTFLAGS) -o $@ $<
# # Make a bound-address ELF file required by GDB for debugging the application.#
%.gdb : %.bin FORCE
$(LD) -T $(LINKSCRIPT) $(TEXT_LOC_OPT) $(DATA_LOC_OPT) $(BSS_LOC_OPT) -o $@ $<
# # Make a relocatable ELF file.#
%.elf : %.bin
$(LD) -T $(LINKSCRIPT) -Ur -o $@ $<
# # Standard stuff: The object file is dependent on the C source and Makefile timestamps#
%.o : %.c Makefile
$(CC) $(CFLAGS) $(WARNING_FLAGS) -c -o $@ $<
%.o : %.cpp Makefile
$(CC) $(CFLAGS) $(WARNING_FLAGS) -o $@ $<
%.bin : %.o
$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
# # Automatically generate dependencies for the .c source files.# Be sure to omitt debug-level flags as this can produce macro def'n output.# The sed "script" makes the .d (in addition to the .c) file a# target of the dependencies so that the .d file is rebuild if required.# e.g. "X.o: <dependency-list>" gets transformed into "X.o X.d: <dependency-list>"#
%.d: %.c
$(SHELL) -ec '$(CC) $(DEPFLAGS) $(CFLAGS) -c $< | sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' >$@; [ -s $@ ] ||
rm -f $@'
FORCE: ;
----------------------------------------------------------------------------------------------
I tried to remove "rm -f ..." (letters in bold) but *.gdb is still not made.
It seems to me that *.gdb has made but was removed somewhere before makefile & Rules.mak complete.
What do you think ?
Quan