From a11289de795de5c4bc119bfd648c8bd96e2acaa6 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Sat, 21 Mar 2015 18:33:51 +0100 Subject: [PATCH] Move makefile into root directory Requested by @mannol. --- INSTALL.md | 1 - build/Makefile => Makefile | 28 +++++++++++++++++----------- cfg/global_vars.mk | 1 + cfg/targets/install.mk | 4 ++-- 4 files changed, 20 insertions(+), 14 deletions(-) rename build/Makefile => Makefile (73%) diff --git a/INSTALL.md b/INSTALL.md index 88b87a9..4e96a30 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -36,7 +36,6 @@ You can omit `libnotify` if you intend to build without desktop notifications en ## Compiling ``` -cd build/ make PREFIX="/where/to/install" sudo make install PREFIX="/where/to/install" ``` diff --git a/build/Makefile b/Makefile similarity index 73% rename from build/Makefile rename to Makefile index 9d4b45d..3038ada 100644 --- a/build/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -BASE_DIR = $(shell cd .. && pwd -P) +BASE_DIR = $(shell pwd -P) CFG_DIR = $(BASE_DIR)/cfg -include $(CFG_DIR)/global_vars.mk @@ -49,22 +49,28 @@ endif # Include all needed checks -include $(CFG_DIR)/checks/check_features.mk +# Fix path for object files +OBJ := $(addprefix $(BUILD_DIR)/, $(OBJ)) + # Targets -all: toxic +all: $(BUILD_DIR)/toxic -toxic: $(OBJ) - @echo " LD $@" - @$(CC) $(CFLAGS) -o toxic $(OBJ) $(LDFLAGS) +$(BUILD_DIR)/toxic: $(OBJ) + @echo " LD $(@:$(BUILD_DIR)/%=%)" + @$(CC) $(CFLAGS) -o $(BUILD_DIR)/toxic $(OBJ) $(LDFLAGS) -%.o: $(SRC_DIR)/%.c - @echo " CC $@" - @$(CC) $(CFLAGS) -o $*.o -c $(SRC_DIR)/$*.c - @$(CC) -MM $(CFLAGS) $(SRC_DIR)/$*.c > $*.d +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c + @if [ ! -e $(BUILD_DIR) ]; then \ + mkdir -p $(BUILD_DIR) ;\ + fi + @echo " CC $(@:$(BUILD_DIR)/%=%)" + @$(CC) $(CFLAGS) -o $(BUILD_DIR)/$*.o -c $(SRC_DIR)/$*.c + @$(CC) -MM $(CFLAGS) $(SRC_DIR)/$*.c > $(BUILD_DIR)/$*.d clean: - rm -f *.d *.o toxic + rm -rf $(BUILD_DIR) --include $(OBJ:.o=.d) +-include $(BUILD_DIR)/$(OBJ:.o=.d) -include $(CFG_DIR)/targets/*.mk diff --git a/cfg/global_vars.mk b/cfg/global_vars.mk index 832ad49..52942fa 100644 --- a/cfg/global_vars.mk +++ b/cfg/global_vars.mk @@ -8,6 +8,7 @@ else endif # Project directories +BUILD_DIR = $(BASE_DIR)/build DOC_DIR = $(BASE_DIR)/doc SRC_DIR = $(BASE_DIR)/src SND_DIR = $(BASE_DIR)/sounds diff --git a/cfg/targets/install.mk b/cfg/targets/install.mk index 49155b2..cdc0067 100644 --- a/cfg/targets/install.mk +++ b/cfg/targets/install.mk @@ -1,8 +1,8 @@ # Install target -install: toxic +install: $(BUILD_DIR)/toxic @echo "Installing toxic executable" @mkdir -p $(abspath $(DESTDIR)/$(BINDIR)) - @install -m 0755 toxic $(abspath $(DESTDIR)/$(BINDIR)/toxic) + @install -m 0755 $(BUILD_DIR)/toxic $(abspath $(DESTDIR)/$(BINDIR)/toxic) @echo "Installing desktop file" @mkdir -p $(abspath $(DESTDIR)/$(APPDIR))