Hi - You should really send an email to the gnu make list. This list is for gcc questions. Brian On Mon, Sep 28, 2009 at 6:32 AM, mjk78 <shick3n@xxxxxxxxx> wrote: > > I've taken over someone else's project code which uses #defines to select > which region the code is being compiled for. Instead of hard-coding these > #defines, i would like to edit the makefile to specify the region at compile > time. > > ie. I would like to be able to enter "make USA" or "make Mexico" and have > that automatically define REG_UNITED STATES or REG_MEXICO when compiling. > > I've tried to check the MAKECMDGOALS variable, but I still get a "No rule to > make target "USA". Stop" error. > > my makefile currently is: > ---------------------------------------------------------------------------------------- > > > ################################################### > # Define Project name > ################################################### > PRJ_NAME=OTB > SVN_REV=0 > MODEL_NAME=EON-XCOM > SUBVERSION=0 > > OBJDIR=obj > SRCDIR=source > INCDIR=inc > LSTDIR=list > > ################################################### > ################################################### > START_OF_SRAM=0x800000 > #START_OF_SRAM=0x00814000 > SIZE_OF_SRAM=1024k > START_OF_FLASH=0x01100000 > > # Must be 6 HEX digit > START_OF_PROTECTED=000000 > #END_OF_PROTECTED=00FFFF > END_OF_PROTECTED=042400 > > ################################################### > # Source file list > ################################################### > C_SRC=$(notdir $(wildcard $(SRCDIR)/*.c)) > A_SRC=$(notdir $(wildcard $(SRCDIR)/*.s)) > > ################################################### > # Gen object file name automatically > ################################################### > C_OBJ=$(addprefix $(OBJDIR)/, $(C_SRC:.c=.o)) > A_OBJ=$(addprefix $(OBJDIR)/, $(A_SRC:.s=.o)) > > OUT_FILE=$(PRJ_NAME) > BIN_FILE=$(PRJ_NAME).bin > TMS_FILE=$(PRJ_NAME).tms > SCRIPT_FILE=$(PRJ_NAME).ld > > MAP_FILE=$(PRJ_NAME).map > > > ################################################### > # Tools setup > ################################################### > CROSS=arm-unknown-linux-gnu- > LIBCDIR=/opt/lib_arm > > LIBSYSDIR=../lib > > INCLUDES=-I $(INCDIR) -I $(LIBSYSDIR) > DEFINES=-D__NO_CTYPE -DSVN_REV=$(SVN_REC) -D__pcs= > > #-------------------------------------------------- > #Check for USA, RSA or MEX command line arguments...MK > #-------------------------------------------------- > ifeq ($(MAKECMDGOALS),USA) > REG_DEFINE=-DREG_UNITED_STATES > endif > ifeq ($(MAKECMDGOALS),Mexico) > REG_DEFINE=-DREG_MEXICO > endif > > > CC=$(CROSS)gcc > CFLAGS=-c -std=gnu89 -Os -Wall -msoft-float -mthumb -mthumb-interwork > -mcpu=arm7tdmi $(DEFINES) $(INCLUDES) $(REG_DEFINE) > > ASM=$(CROSS)gcc > ASFLAGS=$(CFLAGS) > > LINK=$(CROSS)ld > LFLAGS=-nostdlib -L $(LIBCDIR)/lib -L $(LIBSYSDIR) -static -T $(SCRIPT_FILE) > -Map $(MAP_FILE) > LIBS=-lgcc -lc -lm -lsyscall -lsysutil > > AR=$(CROSS)ar > ARFLAGS=-rc > > OBJCOPY=$(CROSS)objcopy > OCFLAGS=-S -O binary > > BIN2TMS=bin2tms > TMSFLAGS=-s$(SUBVERSION) -m$(MODEL_NAME) -n$(PRJ_NAME) -x XXXX XX XX > $(START_OF_PROTECTED) $(END_OF_PROTECTED) > > ############################################################################ > # Loader config > ############################################################################ > LOADER=ConLoader > LOADER_KEY=734EC4FF38F93130 > LOADER_COM=6 > LOADER_BAUD=115200 > LOADER_AID=COMM_EXP > > ############################################################################ > # Linker script > ############################################################################ > LD_SCRIPT=" ENTRY (cstartup) \ > SECTIONS { \ > _start_of_data = $(START_OF_SRAM); \ > _start_of_flash = $(START_OF_FLASH); \ > _end_of_sram = _start_of_data + $(SIZE_OF_SRAM); \ > _start_of_header = _start_of_flash + 0x20; \ > _start_of_app = _start_of_flash + 0x30; \ > . = _start_of_flash; \ > .startup : { *(sect_startup) } \ > . = _start_of_header; \ > .header : { *(sect_header) } \ > . = _start_of_app; \ > .text : { *(.text .glue*) } \ > .const : { *(.rodata*) } \ > _end_of_app = (. + 3) & ~ 3; \ > . = _start_of_data; \ > .data : AT (_end_of_app) { *(.data) } \ > _end_of_data = (. + 3) & ~ 3; \ > . = _end_of_data; \ > _start_of_bss = .; \ > .bss : { *(.bss) } \ > _end_of_bss = .; \ > _end_of_flash = _end_of_app + SIZEOF (.data); \ > }" > > ################################################### > # Link file > ################################################### > $(OUT_FILE) : $(A_OBJ) $(C_OBJ) > @echo . > @echo [$(OUT_FILE)] > @rm -f $(SCRIPT_FILE) > @echo $(LD_SCRIPT) > $(SCRIPT_FILE) > @$(LINK) $(LFLAGS) -o $(OUT_FILE) --start-group $(LIBS) $(A_OBJ) $(C_OBJ) > --end-group > @rm -f $(SCRIPT_FILE) > @$(OBJCOPY) $(OCFLAGS) $(OUT_FILE) $(BIN_FILE) > @$(BIN2TMS) $(TMSFLAGS) $(BIN_FILE) > > ################################################### > ################################################### > $(SRCDIR)/%.rc : $(INCDIR)/rc.h > @touch $(SRCDIR)/$(@F) > > $(SRCDIR)/%.cpp : $(INCDIR)/%.h > @touch $(SRCDIR)/$(@F) > > $(SRCDIR)/%.c : $(INCDIR)/%.h > @touch $(SRCDIR)/$(@F) > > ################################################### > # Compile C files > ################################################### > $(OBJDIR)/%.o : $(SRCDIR)/%.c > @echo [$<] > @$(CC) $(CFLAGS) $< -o $@ -Wa,-a=$(LSTDIR)/$(@F:.o=.lst) > > ################################################### > # Assembly ASM files > ################################################### > $(OBJDIR)/%.o : $(SRCDIR)/%.s > @echo [$<] > @$(ASM) $(ASFLAGS) $< -o $@ -Wa,-a=$(LSTDIR)/$(@F:.o=.lst) > > ################################################### > # Load > ################################################### > .PHONY : load > load : > @echo $(LOADER_AID) > uniload.inf > @$(LOADER) $(TMS_FILE) -s$(LOADER_BAUD) -K$(LOADER_KEY) -$(LOADER_COM) > @rm -f uniload.inf > > ################################################### > # Clear all object file and output file > ################################################### > .PHONY : clean > clean : > @echo Delete all object file. > @rm -f $(OBJDIR)/*.* > @rm -f $(LSTDIR)/*.* > @rm -f $(OUT_FILE) > @rm -f $(BIN_FILE) > @rm -f $(TMS_FILE) > @rm -f $(MAP_FILE) > @rm -f $(SCRIPT_FILE) > > -- > View this message in context: http://www.nabble.com/makefile-help-tp25645182p25645182.html > Sent from the gcc - Help mailing list archive at Nabble.com. > >