[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
auto-dependencies problem
From: |
Manu |
Subject: |
auto-dependencies problem |
Date: |
Thu, 1 May 2003 21:23:01 +0200 |
I have a problem with automatic dependencies generation when objects
are placed in an "OBJDIR" subdirectory.
The attached zip contains a simple makefile which demonstrates the problem.
While DEPDIR works fine, OBJDIR cause sources not to be rebuild as they
should. In my example, the preprocessor should output
"$(OBJDIR)/file1.o: file1.cpp file1.h" instead of "file1.o: file1.cpp file1.h".
I'd like that Makefile to run both from a Dirty OS box and an Unix shell.
I'd like it to work either with make 3.79 / 3.80 and gcc 2.95 / 3.
$(CC) -MT would work, but only if using gcc 3:
"-MT target
By default CPP uses the main file name, including any path, and appends the
object suffix, normally ".o", to it to obtain the name of the target for
dependency
generation. With `-MT' you can specify a target yourself, overriding the default
one."
I could use sed, but it wouldn't work from a DOS box.
That problem seems unresolvable, but I'm asking in case a make guru would
know a workaround.
Any idea ?
Manu.
----
<Makefile>
# Generated automatically by Visual-MinGW.
# http://visual-mingw.sourceforge.net/
top_srcdir = ..
VPATH = ../lib:../src
DEPDIR = _deps
OBJDIR = ../obj
MWINDOWS =
# Configuration 1
#
# define tools
CC = gcc
CXX = g++
WRES = windres
AR = ar
ARFLAGS = -cru
RANLIB = ranlib
DLLWRAP = dllwrap
RM = rm -f
# compiler flags
INCLUDES =
SYMBOLS =
OPTIMIZE = -O2
WARNINGS = -W -Wall
CFLAGS = $(SYMBOLS) $(OPTIMIZE)
CPPFLAGS =
CCFLAGS = $(WARNINGS) $(CFLAGS)
# linker flags
STRIP = -s
LIBDIRS =
LIBS =
LDFLAGS = $(STRIP) $(MWINDOWS)
# target
target = $(top_srcdir)/./new.exe
# Source Files
#
SOURCES = \
file2.cpp \
file1.cpp
OBJECTS = \
file2.o \
file1.o
# Explicit rules
#
.SUFFIXES:
.SUFFIXES: .c .cpp .rc .o
CC = $(CXX)
MAKEDEPEND = $(CC) -MM $(INCLUDES) $(CPPFLAGS)
COMPILE = $(CC) $(INCLUDES) $(CPPFLAGS) $(CCFLAGS)
LINK = $(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) $(LIBDIRS) $^ -o $@
$(OBJDIR)/%.o : %.c
$(MAKEDEPEND) $< > $(DEPDIR)/$*.Po
$(COMPILE) -c $< -o $@
$(OBJDIR)/%.o : %.cpp
$(MAKEDEPEND) $< > $(DEPDIR)/$*.Po
$(COMPILE) -c $< -o $@
$(OBJDIR)/%.o : %.rc
$(WRES) $(CPPFLAGS) $< $@
# Targets
#
all: $(target)
debug:
$(target)
clean:
$(RM) $(target) $(addprefix $(OBJDIR)/, $(OBJECTS))
$(target): $(addprefix $(OBJDIR)/, $(OBJECTS))
$(LINK) $(LIBS)
# Automatic Dependencies
#
-include $(DEPDIR)/file2.Po
-include $(DEPDIR)/file1.Po
</Makefile>
20030501-src.zip
Description: Zip compressed data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- auto-dependencies problem,
Manu <=