Jump to content
  • Advertisement
Sign in to follow this  
Edgar Reynaldo

makefile always builds everything - why?

This topic is 2591 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

SOLVED : See solution below

I can't get the makefile for my software library Eagle to only build the files that are out of date. Can anyone see why this makefile always builds everything? Does it have anything to do with implicit rules?

It should only rebuild the .d files when the source files or their dependencies are newer than they are.
It should only rebuild the object files when the .d files or their .c or .cpp file dependencies are newer than they are.
It should only rebuild the libraries when the object files are newer than they are.

However, it rebuilds all the .d files, all the .o files, and the library every time I run make and I don't understand why.

Any makefile gurus out there who can help me?

If you want to try building the library yourself, you can download the latest SVN code from sourceforge :
svn checkout "http://svn.code.sf.net/p/eaglegui/code/trunk eaglegui-code"

Here's the current makefile :

#/*
# *
# * _______ ___ ____ __ _______
# * /\ ____\ /| \ / __\ /\ \ /\ ____\
# * \ \ \___/_ || _ \ | /__/____\ \ \ \ \ \___/_
# * \ \ ____\ || |_\ \ |\ \ /\_ _\\ \ \ \ \ ____\
# * \ \ \___/_ || ___ \ \ \ \\//\ \/ \ \ \____\ \ \___/_
# * \ \______\||_|__/\_\ \ \ \_\/ | \ \_____\\ \______\
# * \/______/|/_/ \/_/ \_\_____/ \/_____/ \/______/
# *
# *
# * EAGLE
# * Edgar's Allegro Gui Library and Extensions
# *
# * Copyright 2009-2011 by Edgar Reynaldo
# *
# * See EagleLicense.txt for allowed uses of this library.
# *
# */

# Must include makefile.version before makefile.platform!
include makefile.version

# Platform specific shiznit goes here
# makefile.platform is generated by fix.*

include makefile.platform



ifndef STATICLINK
DYNAMICLINK = 1
endif

ifndef DEBUGMODE
ifndef PROFILEMODE
RELEASEMODE = 1
endif
else
PROFILEMODE=
RELEASEMODE=
endif

ifndef PROFILEMODE
ifndef DEBUGMODE
RELEASEMODE = 1
endif
else
DEBUGMODE=
RELEASEMODE=
endif

ifndef BUILDDIR
BUILDDIR = testbuild
endif

WFLAGS = -Wall -Wshadow
CC = g++

ifeq (WINDOWS,$(PLATFORM))
LIBALLEGROPROFILE := -lalleg44-profile.dll
LIBALLEGRODEBUG := -lalleg44-debug.dll
LIBALLEGRORELEASE := -lalleg44.dll
endif
ifeq (NIX,$(PLATFORM))
LIBALLEGROPROFILE := -lalleg-profile
LIBALLEGRODEBUG := -lalleg-debug
LIBALLEGRORELEASE := -lalleg
endif

ifdef STATICLINK
ifdef PROFILEMODE
OBJDIR := $(BUILDDIR)/obj/Static/Profiling
LIBSUFFIX := _ps
CFLAGS := -pg
LFLAGS := -pg $(GMON)
MODE := Static Profiling mode
endif
ifdef DEBUGMODE
OBJDIR := $(BUILDDIR)/obj/Static/Debug
LIBSUFFIX := _ds
CFLAGS := -g -DDEBUGMODE -DEAGLE_ASSERT_EXCEPTION
LFLAGS :=
MODE := Static Debugging mode
endif
ifdef RELEASEMODE
OBJDIR := $(BUILDDIR)/obj/Static/Release
LIBSUFFIX := _rs
CFLAGS := -O2
LFLAGS :=
MODE := Static Release mode
endif
CFLAGS := $(CFLAGS) -c -DALLEGRO_STATICLINK
endif
ifdef DYNAMICLINK
ifdef PROFILEMODE
OBJDIR := $(BUILDDIR)/obj/Dynamic/Profiling
LIBSUFFIX := _p
CFLAGS := -pg
LFLAGS := -pg $(GMON) $(LIBALLEGROPROFILE)
MODE := Dynamic Profiling mode
endif
ifdef DEBUGMODE
OBJDIR := $(BUILDDIR)/obj/Dynamic/Debug
LIBSUFFIX := _d
CFLAGS := -g -DDEBUGMODE -DEAGLE_ASSERT_EXCEPTION
LFLAGS := $(LIBALLEGRODEBUG)
MODE := Dynamic Debugging mode
endif
ifdef RELEASEMODE
OBJDIR := $(BUILDDIR)/obj/Dynamic/Release
LIBSUFFIX := _r
CFLAGS := -O2
LFLAGS := $(LIBALLEGRORELEASE) -s
MODE := Dynamic Release mode
endif
CFLAGS := $(CFLAGS) -c
CFLAGS := $(CFLAGS) $(EXTRACFLAGS)
endif

COMPILEFLAGS = $(WFLAGS) $(CFLAGS)
LINKFLAGS = $(LFLAGS)

CPPSRCS = $(notdir $(wildcard src/*.cpp))
CSRCS = $(notdir $(wildcard src/*.c))
CPPGUISRCS = $(notdir $(wildcard src/GuiCode/*.cpp))
CGUISRCS = $(notdir $(wildcard src/GuiCode/*.c))

CPPOBJS = $(addsuffix .o , $(basename $(CPPSRCS)))
COBJS = $(addsuffix .o , $(basename $(CSRCS)))
CPPGUIOBJS = $(addsuffix .o , $(basename $(CPPGUISRCS)))
CGUIOBJS = $(addsuffix .o , $(basename $(CGUISRCS)))

CPPOBJS := $(addprefix $(OBJDIR)/,$(CPPOBJS))
COBJS := $(addprefix $(OBJDIR)/,$(COBJS))
CPPGUIOBJS := $(addprefix $(OBJDIR)/,$(CPPGUIOBJS))
CGUIOBJS := $(addprefix $(OBJDIR)/,$(CGUIOBJS))

CPPSRCS := $(addprefix src/,$(CPPSRCS))
CSRCS := $(addprefix src/,$(CSRCS))
CPPGUISRCS := $(addprefix src/GuiCode/,$(CPPGUISRCS))
CGUISRCS := $(addprefix src/GuiCode/,$(CGUISRCS))

ALLCSRCS := $(CSRCS) $(CGUISRCS)
ALLCPPSRCS := $(CPPSRCS) $(CPPGUISRCS)
ALLSRCS := $(ALLCSRCS) $(ALLCPPSRCS)

ALLCOBJS := $(COBJS) $(CGUIOBJS)
ALLCPPOBJS := $(CPPOBJS) $(CPPGUIOBJS)
ALLOBJS := $(ALLCOBJS) $(ALLCPPOBJS)

$(warning Including *.d files...)
include $(ALLOBJS:%.c:$(OBJDIR)$(SLASH)%.d)
include $(ALLOBJS:%.cpp:$(OBJDIR)$(SLASH)%.d)

#CHDRS = $(notdir $(wildcard include/*.h))
#CPPHDRS = $(notdir $(wildcard include/*.hpp))
#CGUIHDRS = $(notdir $(wildcard include/GuiCode/*.h))
#CPPGUIHDRS = $(notdir $(wildcard include/GuiCode/*.hpp))

EAGLEHDR = include/Eagle.hpp
CHDRS = $(wildcard include/Eagle/*.h)
CPPHDRS = $(wildcard include/Eagle/*.hpp)
CGUIHDRS = $(wildcard include/Eagle/GuiCode/*.h)
CPPGUIHDRS = $(wildcard include/Eagle/GuiCode/*.hpp)

HDRS := $(CHDRS) $(CPPHDRS)
GUIHDRS := $(CGUIHDRS) $(CPPGUIHDRS)
ALLHDRS := $(EAGLEHDR) $(HDRS) $(GUIHDRS)

LIBDIR := $(BUILDDIR)$(SLASH)lib
LIBNAME = eagle
# eagle_*
FULLLIBNAME := $(LIBNAME)$(LIBSUFFIX)

# WIN = eagle_*.dll NIX = eagle_*.so.1
DLLNAME := $(FULLLIBNAME)$(SHAREDLIBEXT)

#soname = dll , -o = .a
#static libs on *NIX are .a files

ifdef STATICLINK
# libeagle_*.a
ARCHIVENAME := lib$(FULLLIBNAME).a
else
# libeagle_*.so on unix , libeagle_*.dll.a on MinGW
ifeq (WINDOWS,$(PLATFORM))
# WIN = libeagle_*.dll.a
ARCHIVENAME := lib$(DLLNAME).a
endif
ifeq (NIX,$(PLATFORM))
# NIX libeagle_*.so
ARCHIVENAME := lib$(FULLLIBNAME).so
SONAME = $(ARCHIVENAME).$(MAJORVERSION).$(MINORVERSION)
DLLNAME := lib$(DLLNAME).$(FULLVERSION)
endif
endif

BINDIR = $(INSTALLDIR)$(SLASH)bin

OUTPUTLIB := $(LIBDIR)$(SLASH)$(ARCHIVENAME)
OUTPUTDLL := $(LIBDIR)$(SLASH)$(DLLNAME)

#fake :
ifeq (WINDOWS,$(PLATFORM))
# $(ECHO) Platform is WINDOWS!
OUTPUTDEF = $(LIBDIR)$(SLASH)$(DLLNAME).def
CREATEDEF = -Wl,--output-def=$(OUTPUTDEF)
CREATEIMPLIB = -Wl,--out-implib=$(OUTPUTLIB)
MAKEDLL = -Wl,--dll
endif
ifeq (NIX,$(PLATFORM))
# $(ECHO) Platform is NIX!
CREATEIMPLIB = -Wl,-soname,$(SONAME)
endif





# Targets begin here



#$(OUTPUTLIB) $(OUTPUTDLL) $(OUTPUTDEF) : $(ALLOBJS)
# $(ECHO) Building lib $(OUTPUTLIB) in $(MODE)
#ifdef STATICLINK
# $(TEST) ar.exe -rcs $(OUTPUTLIB) $(ALLOBJS)
#endif
#ifdef DYNAMICLINK
# mingw32-g++.exe -shared -Wl,--output-def=build\lib\libeagle_r.dll.def -Wl,--out-implib=build\lib\libeagle_r.dll.a -Wl,--dll
# $(TEST) $(CC) -shared -Wl,--output-def=$(OUTPUTDEF) -Wl,--out-implib=$(OUTPUTLIB) -Wl,--dll $(ALLOBJS) -o $(OUTPUTDLL) $(LINKFLAGS)
#endif


ifdef STATICLINK
$(OUTPUTLIB) : $(ALLOBJS)
$(ECHO) Building lib $(OUTPUTLIB) in $(MODE)
$(TEST) ar.exe -rcs $(OUTPUTLIB) $(ALLOBJS)
endif
ifdef DYNAMICLINK
$(OUTPUTLIB) $(OUTPUTDLL) $(OUTPUTDEF) : $(ALLOBJS)
# Windows
# mingw32-g++.exe -shared -Wl,--output-def=build\lib\libeagle_r.dll.def -Wl,--out-implib=build\lib\libeagle_r.dll.a -Wl,--dll
# *NIX
# g++ -shared -Wl,-soname,libprint.so.1 -o libprint.so.1.0 $(OBJS)
$(ECHO) Building lib $(OUTPUTLIB) in $(MODE)
$(TEST) $(CC) -shared $(CREATEDEF) $(CREATEIMPLIB) $(MAKEDLL) $(ALLOBJS) -o $(OUTPUTDLL) $(LINKFLAGS)
endif

$(FIXDFILES) : Fixdfiles.cpp
$(CC) -Wall -O2 -o $(FIXDFILES) Fixdfiles.cpp
ifeq (NIX,$(PLATFORM))
chmod +x $(FIXDFILES)
endif

.PRECIOUS : $(OBJDIR)/%.d

$(OBJDIR)/%.d : src/%.c makebuilddirs $(FIXDFILES)
$(TEST) $(CC) -MM $< -Iinclude > $@
# $(FIXDFILES) $(OBJDIR) $(@F) > $@
$(FIXDFILES) $(OBJDIR) $(@F)

$(OBJDIR)/%.d : src/%.cpp makebuilddirs $(FIXDFILES)
$(TEST) $(CC) -MM $< -Iinclude > $@
# $(FIXDFILES) $(OBJDIR) $(@F) > $@
$(FIXDFILES) $(OBJDIR) $(@F)

$(OBJDIR)/%.d : src/GuiCode/%.c makebuilddirs $(FIXDFILES)
$(TEST) $(CC) -MM $< -Iinclude > $@
# $(FIXDFILES) $(OBJDIR) $(@F) > $@
$(FIXDFILES) $(OBJDIR) $(@F)

$(OBJDIR)/%.d : src/GuiCode/%.cpp makebuilddirs $(FIXDFILES)
$(TEST) $(CC) -MM $< -Iinclude > $@
# $(FIXDFILES) $(OBJDIR) $(@F) > $@
$(FIXDFILES) $(OBJDIR) $(@F)

#$(warning Including d files!)
#include $(COBJS:%.o:%.d)
#include $(CPPOBJS:%.o:%.d)
#include $(CGUIOBJS:%.o:%.d)
#include $(CPPGUIOBJS:%.o:%.d)

$(OBJDIR)/%.o : src/%.c $(OBJDIR)/%.d
$(TEST) $(CC) $(COMPILEFLAGS) -Iinclude -o $@ $<

$(OBJDIR)/%.o : src/%.cpp $(OBJDIR)/%.d
$(TEST) $(CC) $(COMPILEFLAGS) -Iinclude -o $<

$(OBJDIR)/%.o : src/GuiCode/%.c $(OBJDIR)/%.d
$(TEST) $(CC) $(COMPILEFLAGS) -Iinclude -o $@ $<

$(OBJDIR)/%.o : src/GuiCode/%.cpp $(OBJDIR)/%.d
$(TEST) $(CC) $(COMPILEFLAGS) -Iinclude -o $@ $<

.PHONY : makefile.platform
makefile.platform :
ifeq (,$(findstring makefile.platform,$(wildcard makefile.platform)))
$(error Please run fix.bat for Windows or ./fix.sh for *nix to generate makefile.platform)
endif

makebuilddirs :
-$(MKDIR) $(LIBDIR)
-$(MKDIR) $(subst /,$(SLASH),$(OBJDIR))

makeinstalldirs :
-$(MKDIR) $(BINDIR)
-$(MKDIR) $(INSTALLDIR)$(SLASH)lib
# -$(MKDIR) $(INSTALLDIR)$(SLASH)include
# -$(MKDIR) $(INSTALLDIR)$(SLASH)include$(SLASH)Eagle
# This should take care of creating include and Eagle as well
-$(MKDIR) $(INSTALLDIR)$(SLASH)include$(SLASH)Eagle$(SLASH)GuiCode

all :
$(MAKE) DEBUGMODE=1
$(MAKE) PROFILEMODE=1
$(MAKE)
$(MAKE) DEBUGMODE=1 STATICLINK=1
$(MAKE) PROFILEMODE=1 STATICLINK=1
$(MAKE) STATICLINK=1


install : $(OUTPUTLIB) $(OUTPUTDLL) $(OUTPUTDEF) makeinstalldirs installheaders
ifeq (WINDOWS,$(PLATFORM))
$(COPY) $(OUTPUTDLL) $(INSTALLDIR)$(SLASH)bin
$(COPY) $(OUTPUTLIB) $(INSTALLDIR)$(SLASH)lib
endif
ifeq (NIX,$(PLATFORM))
$(COPY) $(OUTPUTDLL) $(INSTALLDIR)$(SLASH)lib
ln -sf $(INSTALLDIR)$(SLASH)lib$(SLASH)$(DLLNAME) $(INSTALLDIR)$(SLASH)lib$(SLASH)$(SONAME)
ln -sf $(INSTALLDIR)$(SLASH)lib$(SLASH)$(SONAME) $(INSTALLDIR)$(SLASH)lib$(SLASH)$(ARCHIVEAME)
endif

installheaders : $(ALLHDRS)
$(COPY) include$(SLASH)Eagle$(SLASH)*.* $(INSTALLDIR)$(SLASH)include$(SLASH)Eagle
$(COPY) include$(SLASH)Eagle$(SLASH)GuiCode$(SLASH)*.* $(INSTALLDIR)$(SLASH)include$(SLASH)Eagle$(SLASH)GuiCode
$(COPY) include$(SLASH)Eagle.hpp $(INSTALLDIR)$(SLASH)include

uninstall :
-$(REMOVE) $(INSTALLDIR)$(SLASH)bin$(SLASH)$(DLLNAME)
-$(REMOVE) $(INSTALLDIR)$(SLASH)lib$(SLASH)$(ARCHIVENAME)
-$(REMDIR) $(INSTALLDIR)$(SLASH)include$(SLASH)Eagle
-$(REMOVE) $(INSTALLDIR)$(SLASH)include$(SLASH)Eagle.hpp

installall : all
$(MAKE) DEBUGMODE=1 install INSTALLDIR=$(INSTALLDIR)
$(MAKE) PROFILEMODE=1 install INSTALLDIR=$(INSTALLDIR)
$(MAKE) install INSTALLDIR=$(INSTALLDIR)
$(MAKE) DEBUGMODE=1 STATICLINK=1 install INSTALLDIR=$(INSTALLDIR)
$(MAKE) PROFILEMODE=1 STATICLINK=1 install INSTALLDIR=$(INSTALLDIR)
$(MAKE) STATICLINK=1 install INSTALLDIR=$(INSTALLDIR)

uninstallall :
$(MAKE) DEBUGMODE=1 uninstall INSTALLDIR=$(INSTALLDIR)
$(MAKE) PROFILEMODE=1 uninstall INSTALLDIR=$(INSTALLDIR)
$(MAKE) uninstall INSTALLDIR=$(INSTALLDIR)
$(MAKE) DEBUGMODE=1 STATICLINK=1 uninstall INSTALLDIR=$(INSTALLDIR)
$(MAKE) PROFILEMODE=1 STATICLINK=1 uninstall INSTALLDIR=$(INSTALLDIR)
$(MAKE) STATICLINK=1 uninstall INSTALLDIR=$(INSTALLDIR)

.PHONY : clean cleanobj cleanlib

clean : cleanobj cleanlib

cleanobj :
$(REMOVE) $(subst /,$(SLASH),$(OBJDIR))$(SLASH)*.*

cleanlib :
$(REMOVE) $(subst /,$(SLASH),$(OUTPUTLIB))

cleanall :
$(MAKE) DEBUGMODE=1 clean
$(MAKE) PROFILEMODE=1 clean
$(MAKE) clean
$(MAKE) DEBUGMODE=1 STATICLINK=1 clean
$(MAKE) PROFILEMODE=1 STATICLINK=1 clean
$(MAKE) STATICLINK=1 clean

help :
$(ECHO) Available options : (Default build is dynamic release mode)
$(ECHO) DEBUGMODE=1
$(ECHO) PROFILEMODE=1
$(ECHO) STATICLINK=1
$(ECHO) on
$(ECHO) Available targets : (Default target is dynamic release library)
$(ECHO) all
$(ECHO) install
$(ECHO) uninstall
$(ECHO) installall
$(ECHO) uninstallall
$(ECHO) clean
$(ECHO) cleanall
$(ECHO) on
$(ECHO) Default installation directory is $MINGDIR$ for Windows and /usr for *nix
$(ECHO) Set using INSTALLDIR=install/directory/path



The rules for building the *.d and *.o and the *.dll / *.so / *.a files are here :

# Targets begin here



#$(OUTPUTLIB) $(OUTPUTDLL) $(OUTPUTDEF) : $(ALLOBJS)
# $(ECHO) Building lib $(OUTPUTLIB) in $(MODE)
#ifdef STATICLINK
# $(TEST) ar.exe -rcs $(OUTPUTLIB) $(ALLOBJS)
#endif
#ifdef DYNAMICLINK
# mingw32-g++.exe -shared -Wl,--output-def=build\lib\libeagle_r.dll.def -Wl,--out-implib=build\lib\libeagle_r.dll.a -Wl,--dll
# $(TEST) $(CC) -shared -Wl,--output-def=$(OUTPUTDEF) -Wl,--out-implib=$(OUTPUTLIB) -Wl,--dll $(ALLOBJS) -o $(OUTPUTDLL) $(LINKFLAGS)
#endif


ifdef STATICLINK
$(OUTPUTLIB) : $(ALLOBJS)
$(ECHO) Building lib $(OUTPUTLIB) in $(MODE)
$(TEST) ar.exe -rcs $(OUTPUTLIB) $(ALLOBJS)
endif
ifdef DYNAMICLINK
$(OUTPUTLIB) $(OUTPUTDLL) $(OUTPUTDEF) : $(ALLOBJS)
# Windows
# mingw32-g++.exe -shared -Wl,--output-def=build\lib\libeagle_r.dll.def -Wl,--out-implib=build\lib\libeagle_r.dll.a -Wl,--dll
# *NIX
# g++ -shared -Wl,-soname,libprint.so.1 -o libprint.so.1.0 $(OBJS)
$(ECHO) Building lib $(OUTPUTLIB) in $(MODE)
$(TEST) $(CC) -shared $(CREATEDEF) $(CREATEIMPLIB) $(MAKEDLL) $(ALLOBJS) -o $(OUTPUTDLL) $(LINKFLAGS)
endif

$(FIXDFILES) : Fixdfiles.cpp
$(CC) -Wall -O2 -o $(FIXDFILES) Fixdfiles.cpp
ifeq (NIX,$(PLATFORM))
chmod +x $(FIXDFILES)
endif

.PRECIOUS : $(OBJDIR)/%.d

$(OBJDIR)/%.d : src/%.c makebuilddirs $(FIXDFILES)
$(TEST) $(CC) -MM $< -Iinclude > $@
# $(FIXDFILES) $(OBJDIR) $(@F) > $@
$(FIXDFILES) $(OBJDIR) $(@F)

$(OBJDIR)/%.d : src/%.cpp makebuilddirs $(FIXDFILES)
$(TEST) $(CC) -MM $< -Iinclude > $@
# $(FIXDFILES) $(OBJDIR) $(@F) > $@
$(FIXDFILES) $(OBJDIR) $(@F)

$(OBJDIR)/%.d : src/GuiCode/%.c makebuilddirs $(FIXDFILES)
$(TEST) $(CC) -MM $< -Iinclude > $@
# $(FIXDFILES) $(OBJDIR) $(@F) > $@
$(FIXDFILES) $(OBJDIR) $(@F)

$(OBJDIR)/%.d : src/GuiCode/%.cpp makebuilddirs $(FIXDFILES)
$(TEST) $(CC) -MM $< -Iinclude > $@
# $(FIXDFILES) $(OBJDIR) $(@F) > $@
$(FIXDFILES) $(OBJDIR) $(@F)

#$(warning Including d files!)
#include $(COBJS:%.o:%.d)
#include $(CPPOBJS:%.o:%.d)
#include $(CGUIOBJS:%.o:%.d)
#include $(CPPGUIOBJS:%.o:%.d)

$(OBJDIR)/%.o : src/%.c $(OBJDIR)/%.d
$(TEST) $(CC) $(COMPILEFLAGS) -Iinclude -o $@ $<

$(OBJDIR)/%.o : src/%.cpp $(OBJDIR)/%.d
$(TEST) $(CC) $(COMPILEFLAGS) -Iinclude -o $@ $<

$(OBJDIR)/%.o : src/GuiCode/%.c $(OBJDIR)/%.d
$(TEST) $(CC) $(COMPILEFLAGS) -Iinclude -o $@ $<

$(OBJDIR)/%.o : src/GuiCode/%.cpp $(OBJDIR)/%.d
$(TEST) $(CC) $(COMPILEFLAGS) -Iinclude -o $@ $<



To build the library, run
(fix.bat on Windows or ./fix.sh on *NIX) and then
make [DEBUGMODE=1 | PROFILEMODE=1] [STATICLINK=1] [install | clean | installall | cleanall | help] [BUILDDIR=build/directory] [INSTALLDIR=install/directory]

SOLUTION :
These solutions were kindly given by the folks on the help-make mailing list.
All your rules have extra prerequisites on them: $(OBJDIR)/%.d : src/%.c makebuilddirs $(FIXDFILES) ... $(OBJDIR)/%.o : src/%.c $(OBJDIR)/%.d ... makebuilddirs : -$(MKDIR) $(LIBDIR) -$(MKDIR) $(subst /,$(SLASH),$(OBJDIR)) Here we see that all .o's depend on the .d files and all .d files depend on a target "makebuilddirs". That target creates directories, but the target itself (a file named "makebuilddirs") is never created. That means that the target "makebuilddirs" is never up to date, and that means that the .d target is always out of date, and that means that the .o target is always out of date, and that means make will always rebuild it. Every time you run make it "rebuilds" the makebuilddirs target and that causes every other target in your makefile which depends on it (or depends on something that depends on it) to be rebuilt. [/quote]

Also, a further solution for creating directories was to make them an 'order only prerequisite' by placing them in the prerequisites after a pipe symbol. This way they are only run once before the target's recipe is executed.

BUILDDIR = obj/$(LINKTYPE)/$(BUILDTYPE)

//...

%.d : %.cpp | $(BUILDDIR)
$(GCC) -MM -o $@ $<

$(BUILDDIR) :
$(MKDIR) $(BUILDDIR)

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!