From 895881896db9cd9eb895b334ec1898ec26568254 Mon Sep 17 00:00:00 2001 From: Judro Date: Mon, 21 Nov 2022 15:06:22 +0100 Subject: [PATCH] rearranged project structure --- Makefile | 25 ++++++++++++------------- controls.c => src/controls.c | 0 controls.h => src/controls.h | 0 display.c => src/display.c | 0 display.h => src/display.h | 0 game.c => src/game.c | 0 game.h => src/game.h | 0 menu.c => src/menu.c | 0 menu.h => src/menu.h | 0 mines.c => src/mines.c | 0 10 files changed, 12 insertions(+), 13 deletions(-) rename controls.c => src/controls.c (100%) rename controls.h => src/controls.h (100%) rename display.c => src/display.c (100%) rename display.h => src/display.h (100%) rename game.c => src/game.c (100%) rename game.h => src/game.h (100%) rename menu.c => src/menu.c (100%) rename menu.h => src/menu.h (100%) rename mines.c => src/mines.c (100%) diff --git a/Makefile b/Makefile index 6e60a17..3f26ccf 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,19 @@ -OBJS = mines.o game.o display.o controls.o menu.o -SOURCE = mines.c game.c display.c controls.c menu.c -HEADER = -OUT = mines +SRCS =$(wildcard src/*.c) +OBJS = $(patsubst src/%.c, obj/%.o, $(SRCS)) CC = gcc -FLAGS = -g -c -Wall -LFLAGS = -lbsd -lncurses +FLAGS = -Wall -O2 +LFLAGS = -lncurses +BIN = bin/mines -all: $(OBJS) - $(CC) -g $(OBJS) -o $(OUT) $(LFLAGS) - -mines.o: mines.c - $(CC) $(FLAGS) mines.c +all:$(BIN) +$(BIN): $(OBJS) + $(CC) $(FLAGS) $(OBJS) -o $@ $(LFLAGS) +obj/%.o: src/%.c + $(CC) $(FLAGS) -c $< -o $@ clean: - rm -f $(OBJS) $(OUT) + $(RM) -r bin/* obj/* install: - cp mines /usr/local/bin + cp bin/mines /usr/local/bin diff --git a/controls.c b/src/controls.c similarity index 100% rename from controls.c rename to src/controls.c diff --git a/controls.h b/src/controls.h similarity index 100% rename from controls.h rename to src/controls.h diff --git a/display.c b/src/display.c similarity index 100% rename from display.c rename to src/display.c diff --git a/display.h b/src/display.h similarity index 100% rename from display.h rename to src/display.h diff --git a/game.c b/src/game.c similarity index 100% rename from game.c rename to src/game.c diff --git a/game.h b/src/game.h similarity index 100% rename from game.h rename to src/game.h diff --git a/menu.c b/src/menu.c similarity index 100% rename from menu.c rename to src/menu.c diff --git a/menu.h b/src/menu.h similarity index 100% rename from menu.h rename to src/menu.h diff --git a/mines.c b/src/mines.c similarity index 100% rename from mines.c rename to src/mines.c