Skip to main content
Code Review

Return to Question

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

It's been pointed out been pointed out (see the first comment) that my makefile rebuilds all source files regardless of changes made.

# Variables #
TARGETS := libAurora.a libAurora.so
 # The names of targets that can be built.
 # This is used in the list of valid targets when no target is specified, and when building all targets.
TARGET_DIRECTORY := ./Binaries
 # The place to put the finished binaries.
CXX := g++
 # The compiler to use to compile the source code into object files.
CXXFLAGS := -I. -Wall -Wextra -fPIC -g -O4
 # Options passed to the compiler when compiling source files into object files.
AR := ar
 # The archiver to use to consolidate the object files into one library.
ARFLAGS := -rcs
 # Options to be passed to the archiver.
SOURCE_FILES := $(shell find Source -type f -name *.cpp)
 # Because it's inconvenient to maintain an up-to-date list of all the source files
 # that should be compiled, we just search for all .cpp files in the project
OBJECT_FILES := $(SOURCE_FILES:.cpp=.o)
.PHONY: Default
 # The default target, which doesn't actually do anything except give the user instructions,
 # can be called even if nothing needs to be updated.
.INTERMEDIATE: %.o
 # Specifying the object files as intermediates deletes them automatically after the build process.
# Rules #
Default:
 @echo "Please specify a target, or use \"All\" to build all targets. Valid targets:"
 @echo "$(TARGETS)"
 
All: $(TARGETS)
 
lib%.a: $(OBJECT_FILES)
 $(AR) $(ARFLAGS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)
lib%.so: $(OBJECT_FILES)
 $(AR) $(ARFLAGS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)

What can I do to improve it?

It's been pointed out (see the first comment) that my makefile rebuilds all source files regardless of changes made.

# Variables #
TARGETS := libAurora.a libAurora.so
 # The names of targets that can be built.
 # This is used in the list of valid targets when no target is specified, and when building all targets.
TARGET_DIRECTORY := ./Binaries
 # The place to put the finished binaries.
CXX := g++
 # The compiler to use to compile the source code into object files.
CXXFLAGS := -I. -Wall -Wextra -fPIC -g -O4
 # Options passed to the compiler when compiling source files into object files.
AR := ar
 # The archiver to use to consolidate the object files into one library.
ARFLAGS := -rcs
 # Options to be passed to the archiver.
SOURCE_FILES := $(shell find Source -type f -name *.cpp)
 # Because it's inconvenient to maintain an up-to-date list of all the source files
 # that should be compiled, we just search for all .cpp files in the project
OBJECT_FILES := $(SOURCE_FILES:.cpp=.o)
.PHONY: Default
 # The default target, which doesn't actually do anything except give the user instructions,
 # can be called even if nothing needs to be updated.
.INTERMEDIATE: %.o
 # Specifying the object files as intermediates deletes them automatically after the build process.
# Rules #
Default:
 @echo "Please specify a target, or use \"All\" to build all targets. Valid targets:"
 @echo "$(TARGETS)"
 
All: $(TARGETS)
 
lib%.a: $(OBJECT_FILES)
 $(AR) $(ARFLAGS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)
lib%.so: $(OBJECT_FILES)
 $(AR) $(ARFLAGS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)

What can I do to improve it?

It's been pointed out (see the first comment) that my makefile rebuilds all source files regardless of changes made.

# Variables #
TARGETS := libAurora.a libAurora.so
 # The names of targets that can be built.
 # This is used in the list of valid targets when no target is specified, and when building all targets.
TARGET_DIRECTORY := ./Binaries
 # The place to put the finished binaries.
CXX := g++
 # The compiler to use to compile the source code into object files.
CXXFLAGS := -I. -Wall -Wextra -fPIC -g -O4
 # Options passed to the compiler when compiling source files into object files.
AR := ar
 # The archiver to use to consolidate the object files into one library.
ARFLAGS := -rcs
 # Options to be passed to the archiver.
SOURCE_FILES := $(shell find Source -type f -name *.cpp)
 # Because it's inconvenient to maintain an up-to-date list of all the source files
 # that should be compiled, we just search for all .cpp files in the project
OBJECT_FILES := $(SOURCE_FILES:.cpp=.o)
.PHONY: Default
 # The default target, which doesn't actually do anything except give the user instructions,
 # can be called even if nothing needs to be updated.
.INTERMEDIATE: %.o
 # Specifying the object files as intermediates deletes them automatically after the build process.
# Rules #
Default:
 @echo "Please specify a target, or use \"All\" to build all targets. Valid targets:"
 @echo "$(TARGETS)"
 
All: $(TARGETS)
 
lib%.a: $(OBJECT_FILES)
 $(AR) $(ARFLAGS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)
lib%.so: $(OBJECT_FILES)
 $(AR) $(ARFLAGS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)

What can I do to improve it?

Tweeted twitter.com/#!/StackCodeReview/status/98281107715407872
Source Link
Maxpm
  • 405
  • 1
  • 3
  • 10

Optimizing a Makefile

It's been pointed out (see the first comment) that my makefile rebuilds all source files regardless of changes made.

# Variables #
TARGETS := libAurora.a libAurora.so
 # The names of targets that can be built.
 # This is used in the list of valid targets when no target is specified, and when building all targets.
TARGET_DIRECTORY := ./Binaries
 # The place to put the finished binaries.
CXX := g++
 # The compiler to use to compile the source code into object files.
CXXFLAGS := -I. -Wall -Wextra -fPIC -g -O4
 # Options passed to the compiler when compiling source files into object files.
AR := ar
 # The archiver to use to consolidate the object files into one library.
ARFLAGS := -rcs
 # Options to be passed to the archiver.
SOURCE_FILES := $(shell find Source -type f -name *.cpp)
 # Because it's inconvenient to maintain an up-to-date list of all the source files
 # that should be compiled, we just search for all .cpp files in the project
OBJECT_FILES := $(SOURCE_FILES:.cpp=.o)
.PHONY: Default
 # The default target, which doesn't actually do anything except give the user instructions,
 # can be called even if nothing needs to be updated.
.INTERMEDIATE: %.o
 # Specifying the object files as intermediates deletes them automatically after the build process.
# Rules #
Default:
 @echo "Please specify a target, or use \"All\" to build all targets. Valid targets:"
 @echo "$(TARGETS)"
 
All: $(TARGETS)
 
lib%.a: $(OBJECT_FILES)
 $(AR) $(ARFLAGS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)
lib%.so: $(OBJECT_FILES)
 $(AR) $(ARFLAGS) $(TARGET_DIRECTORY)/$@ $(OBJECT_FILES)

What can I do to improve it?

default

AltStyle によって変換されたページ (->オリジナル) /