Link to home
Start Free TrialLog in
Avatar of liaoo
liaoo

asked on

Compile and link when dependent header file changed in other directory...

Dear experts,
I have 3 questions about compiling and linking my project in fewer steps...

@ My project looks like: ( I use Watcom C to compile//link the project )

Directory 'MyProject' ( within it there are 3 sub directories for different modules )
- directory 'A' ( a.h and a.c included )
- directory 'B' ( b.h and b.c included )
- directory 'C' ( c.h and c.c included )
- my.c and my.h
- my.lnk file
- makefile

And within each sub directory there is one corresponding makefile...

[Q1] Assume I update a.h in directory A and a.h is referenced by b.c in directory B, then my original steps will be:

1. compile in directory A ( obj and lib generated...)
2. compile in directory B ( obj and lib generated...)
3. back to directory MyProject then compile and link

Is there any "faster" way ?

[Q2] If I want to ignore all existing obj/lib and rebuild all, how to do it ?
* I know this takes time but sometimes "kill and rebuild" will be better...

[Q3] If my.h is updated and it is referenced by a.c,b.c, and c.c...
Is there any faster way to compile and link ?

Notes:
* The makefile in sub directory(A,B,or C) looks like below:
INCLUDE1 = -ic:\watcom\h
OBJECTS1 = a.obj
CFLAGS   = -zq -mf -oxsbl $(INCLUDE1)
DEST     = a.exe
COMPILER = wpp386

.erase # special cmd, tell wmake to "erase" target if make is not successful

.cpp.obj: .AUTODEPEND
               $(COMPILER) $(CFLAGS) $<

$(DEST) : $(OBJECTS1) makefile

Open in new window


*  The makefile in main directory looks like below:
INCLUDE1 = -i=c:\myproj\my -i=c:\watcom\h 
OBJECTS1 = my.obj
CFLAGS   = -zq -fp6 -mf -6r -s -oxsbl $(INCLUDE1)
DEST     = my.exe
COMPILER = wpp386
LINKER   = wlink
LNK_FILE = my.lnk

.erase # special cmd, tell wmake to "erase" target if make is not successful

.cpp.obj: .AUTODEPEND
      $(COMPILER) $(CFLAGS) $<


$(DEST) : $(OBJECTS1) makefile my.lnk
      $(LINKER) @$(LNK_FILE) 

Open in new window


Note: My project works well and fine and I just want to find faster steps when compiling and linking...

Thanks !
liaoo
SOLUTION
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial