H
HT-Lab
Hi All,
Not strictly a C++ question but I am sure this is a common compile issue
I have a generic makefile (see below) that I would like update such that if
I make some changes to a header file the associated cpp file is recompiled.
I tried using constructs like:
..h.cpp:
touch $<
thinking that if make detects a change in file.h it will touch file.cpp
which will then result in .cpp.o rule being executed. I tried this and some
other permutations but they all failed.
Any idea how I can fix this issue?
Thanks,
Hans.
# Specify all source
SRCS = sc_main.cpp
# Target file
TARGET = run
# Variable that points to SystemC installation path
SYSTEMC = /usr/local/systemc-2.2
INCDIR = -I. -I.. -I$(SYSTEMC)/include
LIBDIR = -L. -L.. -L$(SYSTEMC)/lib-cygwin
LIBS = -lsystemc -lm
CC = g++
CFLAGS = -g -Wno-deprecated -Wall
OBJS = $(SRCS:.cpp=.o)
EXE = $(TARGET).exe
..SUFFIXES: .cpp .o
$(EXE): $(OBJS)
$(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) -o $@ $(OBJS) $(LIBS) 2>&1 | c++filt
all: $(EXE)
..cpp.o:
$(CC) $(CFLAGS) $(INCDIR) -c $<
clean:
rm -f $(OBJS) *~ $(EXE) *.bak $(TARGET).exe.stackdump
Not strictly a C++ question but I am sure this is a common compile issue
I have a generic makefile (see below) that I would like update such that if
I make some changes to a header file the associated cpp file is recompiled.
I tried using constructs like:
..h.cpp:
touch $<
thinking that if make detects a change in file.h it will touch file.cpp
which will then result in .cpp.o rule being executed. I tried this and some
other permutations but they all failed.
Any idea how I can fix this issue?
Thanks,
Hans.
# Specify all source
SRCS = sc_main.cpp
# Target file
TARGET = run
# Variable that points to SystemC installation path
SYSTEMC = /usr/local/systemc-2.2
INCDIR = -I. -I.. -I$(SYSTEMC)/include
LIBDIR = -L. -L.. -L$(SYSTEMC)/lib-cygwin
LIBS = -lsystemc -lm
CC = g++
CFLAGS = -g -Wno-deprecated -Wall
OBJS = $(SRCS:.cpp=.o)
EXE = $(TARGET).exe
..SUFFIXES: .cpp .o
$(EXE): $(OBJS)
$(CC) $(CFLAGS) $(INCDIR) $(LIBDIR) -o $@ $(OBJS) $(LIBS) 2>&1 | c++filt
all: $(EXE)
..cpp.o:
$(CC) $(CFLAGS) $(INCDIR) -c $<
clean:
rm -f $(OBJS) *~ $(EXE) *.bak $(TARGET).exe.stackdump