Article View: gnu.gcc.help
Article #41594Re: GNU make help (help!!!)
From: Matthew H. Gerlach
Date: Thu, 14 Mar 1996 00:00
Date: Thu, 14 Mar 1996 00:00
323 lines
10641 bytes
10641 bytes
Hi, Sorry to hear you are having trouble with GNU make. I use it very successfully in situations you describe. First of all you did not mention which directory your makefiles and dependency files exist nor did you mention from which directory you actually type "gmake". I generally type "gmake" from the obj directory in your example. In addition my dependencies have the full, relative path of the C and H files in it. On occasion I even use the VPATH directive to tell gmake where to look for stuff. Matthew In article <4i6sej$816@phcoms4.seri.philips.nl> "D. Emilio Grimaldo T." <grimaldo@sce.philips.nl> writes: >This is a multi-part message in MIME format. > >---------------------------------34962120928773 >Content-Transfer-Encoding: 7bit >Content-Type: text/plain; charset=us-ascii > >Well, I have been struggling for hours with that hellish make program and >still can't get it to recompile/link when a C source file has changed. This >is my directory structure: > proj > +----------+-------------+ > | | | > inc bsp demo > +-----+ +------+ > | | > obj obj > >In the `inc' directory I have include files that are shared among projects. >The `bsp' directory is one of those projects (there are more like `demo' etc). >Under the `bsp' directory (immediately below) I have all source files and >include files that are unique to this project (bsp) and one directory below >is the `obj' dir where I place all generated object files. > >The dependancies are generated automatically looking like: >power.o : power.c ../inc this.h that.h > >even if I add obj/ as a prefix to power.o it makes no difference. The problem >is as I said that when I touch proj/bsp/power.c gmake fails to detect this >and therefore proj/bsp/obj/power.o is not remade. >If I touch the power.o file then it proceeds to link. > >Can some kind soul out there spare me from this misery and terrible waste >of time by pointing what I am doing wrong? doing gmake clean everytime I >update something (only to force compilation, otherwise it says 'target up to >date'!) defeats the purpose. I am attaching the makefile. > > Best Regards, > Emilio >ps. Please reply to my address > > >-- >NAME: D. Emilio Grimaldo T. | Communication Multimedia | _/_/_/_/ >EMAIL: grimaldo@sce.philips.nl | Senior Software Engineer | _/_/ >ADDRESS: Eindhoven,The Netherlands | ph. +31 40 2722099 | _/_/_/_/ >-----------------------------------+--------------------------| _/_/ > * * http://www.iaehv.nl/users/grimaldo/index.html :) * * | _/_/_/_/ >---------------------------------------------------------- \\v// ------- >Limited choice & Monopoly foster mediocrity & incompetence (o o) > -------------------------------------------------------ooO-(_)-Ooo---- > >---------------------------------34962120928773 >Content-Transfer-Encoding: 7bit >Content-Type: text/plain > >#!/user/grimaldo/bin/gmake ># $Header: makefile,v 1.1 95/12/04 13:12:32 grimaldo Rel $ ># AUTHOR: D. Emilio Grimaldo T. ># Makefile for Organizer & Games Demonstrator on Target System (OCP) ># ># HISTORY: ># 08-12-95 DE Grimaldo T. Can configure which modules use Symbolic Info ># 21-12-95 DE Grimalto T. Can retrieve from RCS directories ># 28-02-96 DE Grimaldo T. Adapted for Nucleus OCP driver BSP package ># 29-02-96 DE Grimaldo T. Use filename without path for DOS Xview (source ># level debugging possible from DOS ># 06-03-96 DE Grimaldo T. Added SPECIAL for end.o (XView call a function) ># 06-03-96 DE Grimaldo T. Added SELECT_TEST and BSP_TEST > >PHONY: depend > ># ># Cross-development tools & libraries ># >R3000 = /cadappl/packages/tsk/r3000 >LIB = $(R3000)/lib >STDLIB = $(LIB)/libcssb.a $(LIB)/libfntb.a >CC = c3 >AS = as3 >LK = lk3 >LD = lc3 > ># ># Project root and other directories ># >PROJECT = $(HOME)/proj >XVIEW = $(HOME)/xview >BSP = . >BSP_DSC = /user/p_multim/rtos/nucleus/bsp >SPECIAL = /user/p_multim/rtos/nucleus/obj >BSPOBJ = $(BSP)/obj >VPATH = $(BSP):$(BSPOBJ):$(HOME)/proj/inc >vpath %.c ./ > ># ># Target specific libraries ># >DEBUGGER= $(HOME)/proj/lib/dbt.o $(HOME)/proj/lib/dbc.o >NUCLEUS = $(HOME)/proj/lib/nucleus.a >DRIVERS = $(BSPOBJ)/ocpdrv.a > ># ># Area: CACHED or UNCACHED ># >KSEG=CACHED > ># ># Platform: OCP or DINO ># >PLATFORM=OCP > ># ># Test: T_LCD T_RTC T_SND T_PWR ># T_DAC T_TSC ># >SELECT_TEST=T_PWR > ># ># Locator's Descriptor files (for appropriate memory model) ># without the .dsc extension ># >ifeq ($(KSEG),UNCACHED) >LOADDSC = $(BSP_DSC)/ocp-uncached >endif >ifeq ($(KSEG),CACHED) >LOADDSC = $(BSP_DSC)/ocp >endif > ># ># Now select the appropriate source file for the test ># >ifeq ($(SELECT_TEST),T_LCD) > BSP_TEST = tdrv_lcd >endif >ifeq ($(SELECT_TEST),T_RTC) > BSP_TEST = tdrv_rtc >endif >ifeq ($(SELECT_TEST),T_SND) > BSP_TEST = tdrv_snd >endif >ifeq ($(SELECT_TEST),T_TSC) > BSP_TEST = tdrv_tch >endif >ifeq ($(SELECT_TEST),T_DAC) > BSP_TEST = tdrv_dac >endif >ifeq ($(SELECT_TEST),T_PWR) > BSP_TEST = tdrv_pwr >endif > ># ># Compiler/Assembler/Linker/Locator flags & Conditionals (defines) ># SYMFLAG is the 'include symbolic info' flag of the compiler/assembler ># SYMCOND includes SYMFLAG if and only if the module is in the SYM_MODS group! ># >DEFINES = -D$(PLATFORM) >INCLUDES = -I../inc -I$(BSP)/inc >CFLAGS = -EB -flib -O0 $(INCLUDES) $(DEFINES) -m -C -c >ASFLAGS = -EB -e >LKFLAGS = -M -L$(LIB) >LDFLAGS = -M -f1 >SYMFLAG = -g >SYMCOND = $(patsubst %,$(SYMFLAG),$(findstring $(subst .o,,$(notdir $@)),$(SYM_MODS))) > ># ># Modules ># >MODS_APP = $(BSP_TEST) util >MODS_BSP_S = init diagnost >MODS_BSP_C = sys_init cpu_ocp clock isr onchpref lcd sound touchscr power > ># Add all modules for which you want symbolic info in the next variable! >SYM_MODS = $(MODS_APP) $(MODS_BSP_C) $(MODS_BSP_S) > >MODS = $(MODS_BSP_S) $(MODS_BSP_C) $(MODS_APP) > ># ># Objects used for linking (library modules excluded!) ># >#C_BSP_OBJS = $(addprefix $(ITCL)/obj/, $(addsuffix .o, $(MODS_BSP_C))) >S_BSP_OBJS = $(addprefix $(BSPOBJ)/, $(addsuffix .o, $(MODS_BSP_S))) >C_BSP_OBJS = $(addprefix $(BSPOBJ)/, $(addsuffix .o, $(MODS_BSP_C))) >C_APP_OBJS = $(addprefix $(BSPOBJ)/, $(addsuffix .o, $(MODS_APP))) > >OBJS = $(S_BSP_OBJS) $(C_BSP_OBJS) $(C_APP_OBJS) > ># ># Sources per unit so that we can put the objects in their appropriate obj dir. ># >S_BSP_SRCS = $(addprefix $(BSP)/, $(addsuffix .s, $(MODS_BSP_S))) >C_BSP_SRCS = $(addprefix $(BSP)/, $(addsuffix .c, $(MODS_BSP_C))) >A_SRCS = $(addprefix $(BSP)/, $(addsuffix .c, $(MODS_APP))) > >SRCS = $(S_BSP_SRCS) $(C_BSP_SRCS) $(A_SRCS) > > >all: testdrv xview > @echo $@ up to date > @echo $(C_BSP_OBJS) > @echo $(C_BSP_SRCS) > showconf.pl > >testdrv: testdrv.abs > @echo $@ up to date > >testdrv.out: $(OBJS) > @echo "* * * L I N K I N G * * *" > @$(LK) $(LKFLAGS) $(OBJS) $(SPECIAL)/end.o $(STDLIB) $(NUCLEUS) -o $@ > >testdrv.abs: testdrv.out > @echo "* * * L O C A T I N G * * *" > @$(LD) $(LDFLAGS) -g$(subst .abs,.out,$@) $(LOADDSC).dsc -o$@ > >testdrv.s3: testdrv.out > @$(LD) -M -f2b32 $(subst .s3,.out,$@) $(LOADDSC).dsc -o$@ > >xview: > @$(foreach fil, $(A_SRCS), ux2dos $(fil) >$(XVIEW)/$(notdir $(fil));) > @$(foreach fil, $(C_BSP_SRCS), ux2dos $(fil) >$(XVIEW)/$(notdir $(fil));) > @$(foreach fil, $(S_BSP_SRCS), ux2dos $(fil) >$(XVIEW)/$(notdir $(fil));) > > >#--------------------------------------------------------- ># Rule(s) for Assembler sources of Drivers (BSP tree) ># >$(S_BSP_OBJS): %.o:$(filter $@,$(S_BSP_SRCS)) > @$(AS) $(ASFLAGS) $(SYMCOND) $(subst .o,.s,$(notdir $@)) -o $@ ># @$(AS) $(ASFLAGS) $(SYMCOND) $(subst .o,.s,$(subst /obj/,/,$@)) -o $@ > > >#--------------------------------------------------------- ># Rule(s) for C sources of Drivers (BSP tree) ># >#$(C_BSP_OBJS): %.o:$(filter $@,$(C_BSP_SRCS)) >$(C_BSP_OBJS): $(subst obj/,,%.o):$(filter $(subst obj/,,$@),$(C_BSP_SRCS)) > $(CC) $(CFLAGS) $(SYMCOND) $(subst .o,.c,$(notdir $@)) -o $@ ># $(CC) $(CFLAGS) $(SYMCOND) $(subst .o,.c,$(subst /obj/,/,$@)) -o $@ > > >#---------------------------------------------------------- ># Rule(s) for C sources of Target Application (Target tree) ># >$(C_APP_OBJS): %.o:$(filter $@,$(A_SRCS)) > @$(CC) $(CFLAGS) $(SYMCOND) $(subst .o,.c,$(notdir $@)) -o $@ ># @$(CC) $(CFLAGS) $(SYMCOND) $(subst .o,.c,$(subst /obj/,/,$@)) -o $@ ># @ux2dos $(subst .o,.c,$(subst /obj/,/src/,$@)) > $(XVIEW)/$(*F).c > > ># ># Dependencies ># >include depends > ># ># Sources used for dependencies (excludes assembler files!) ># >DEPS = $(addsuffix .c, $(MODS_BSP_C)) $(addsuffix .c, $(MODS_APP)) > >#---------------------------------------------------------- ># Misc. Targets ># > >depend: > @echo \\n"Project Directory :" $(BSP) > @echo "BSP modules :" $(MODS_BSP_C) > @echo "Application modules:" $(MODS_APP)\\n > @$(foreach fil, $(DEPS), /lib/cpp -M $(INCLUDES) $(fil) >/dev/null;) ># sed '/ : \\/s/\/src\//\/obj\//' depends > dep.tmp ># sed '/ : \\/s/code\/obj\//target\/obj\//' dep.tmp > dep1.tmp ># rm -f depends ># mv dep.tmp depends > >clean: > rm -f $(BSPOBJ)/*.o testdrv* $(XVIEW)/* > >cleanall: > rm -f $(BSPOBJ)/* testdrv* > rm -f $(XVIEW)/* > ># ># Versions ># >VER_init_s = 1.1 >VER_diagnost_s = 1.1 > >VER_sys_init_c = 1.1 >VER_sys_init_h = 1.1 >VER_ocp_h = 1.1 >VER_cpu_ocp_c = 1.1 >VER_cpu_h = 1.1 >VER_drv_conf_h = 1.1 >VER_sys_conf_h = 1.1 >VER_lcd_c = 1.1 > >VER_tdrv_lcd_c = 1.1 >VER_tdrv_rtc_c = 1.1 > ># ># Retrieve ># >DEFAULT: > cd $(dir $@) ; \ > co -q -r$($(addprefix VER_,$(subst .,_,$(notdir $@)))) $(notdir $@) ; \ > cd $(BSP) > > >---------------------------------34962120928773--
Technical Details
Message-ID:
<gerlachDo9Lq8.KB5@netcom.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<4i6sej$816@phcoms4.seri.philips.nl>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,5b610a3cd8648ee7,start X-Google-Attributes: gid11318c,public From: gerlach@netcom.com (Matthew H. Gerlach) Subject: Re: GNU make help (help!!!) Date: 1996/03/14 Message-ID: <gerlachDo9Lq8.KB5@netcom.com> X-Deja-AN: 142637843 sender: gerlach@netcom7.netcom.com references: <4i6sej$816@phcoms4.seri.philips.nl> organization: Netcom Online Communications Services (408-241-9760 login: guest) newsgroups: gnu.gcc.help