diff --git a/Makefile b/Makefile index 668118db..ebb4d6d0 100644 --- a/Makefile +++ b/Makefile @@ -227,3 +227,4 @@ plugins: for f in plugins/*; do (cd "$$f" && ${CMD}); done .PHONY: all dep run debug clean dist allplugins cleanplugins distplugins plugins +.DEFAULT_GOAL := all diff --git a/compile.mk b/compile.mk index 0a0381a3..31f9707c 100644 --- a/compile.mk +++ b/compile.mk @@ -43,29 +43,33 @@ CXXFLAGS += $(FLAGS) # Derive object files from sources and place them before user-defined objects -SOURCE_OBJECTS += $(patsubst %, build/%.o, $(SOURCES)) +OBJECTS += $(patsubst %, build/%.o, $(SOURCES)) DEPENDENCIES := $(patsubst %, build/%.d, $(SOURCES)) - # Final targets -$(TARGET): $(RESOURCES) $(OBJECTS) $(SOURCE_OBJECTS) - $(CXX) -o $@ $(SOURCE_OBJECTS) $(OBJECTS) $(LDFLAGS) +$(TARGET): $(OBJECTS) + $(CXX) -o $@ $(OBJECTS) $(LDFLAGS) -include $(DEPENDENCIES) -build/%.c.o: %.c +build/%.c.o: %.c | dep @mkdir -p $(@D) $(CC) $(CFLAGS) -c -o $@ $< -build/%.cpp.o: %.cpp +build/%.cpp.o: %.cpp | dep @mkdir -p $(@D) $(CXX) $(CXXFLAGS) -c -o $@ $< -build/%.cc.o: %.cc +build/%.cc.o: %.cc | dep @mkdir -p $(@D) $(CXX) $(CXXFLAGS) -c -o $@ $< -build/%.m.o: %.m +build/%.m.o: %.m | dep @mkdir -p $(@D) $(CC) $(CFLAGS) -c -o $@ $< + +# Do nothing by default +dep: + +.PHONY: dep diff --git a/dep.mk b/dep.mk index 1ee1c7b4..13d93c07 100644 --- a/dep.mk +++ b/dep.mk @@ -1,5 +1,6 @@ include $(RACK_DIR)/arch.mk +# The install location for `make install` DEP_LOCAL ?= . DEP_FLAGS += -g -O3 -march=nocona @@ -28,10 +29,5 @@ $(DEPS): export CXXFLAGS = $(DEP_CXXFLAGS) $(DEPS): export LDFLAGS = $(DEP_LDFLAGS) dep: $(DEPS) - @echo - @echo "#######################################" - @echo "# All dependencies built successfully #" - @echo "#######################################" - @echo .PHONY: dep diff --git a/plugin.mk b/plugin.mk index e1b78bcb..bd2f53b5 100644 --- a/plugin.mk +++ b/plugin.mk @@ -29,6 +29,10 @@ ifeq ($(ARCH), win) endif +DEP_FLAGS += -fPIC +include $(RACK_DIR)/dep.mk + + all: $(TARGET) include $(RACK_DIR)/compile.mk