improve Makefiles default tip

Sun, 01 Oct 2023 13:56:42 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 01 Oct 2023 13:56:42 +0200
changeset 72
7e58e0f74e50
parent 71
0bdb910478cc

improve Makefiles

configure file | annotate | diff | comparison | revisions
make/cc.mk file | annotate | diff | comparison | revisions
make/project.xml file | annotate | diff | comparison | revisions
src/Makefile file | annotate | diff | comparison | revisions
src/chess/Makefile file | annotate | diff | comparison | revisions
src/terminal-chess.h file | annotate | diff | comparison | revisions
--- a/configure	Sun Oct 01 12:53:35 2023 +0200
+++ b/configure	Sun Oct 01 13:56:42 2023 +0200
@@ -328,7 +328,6 @@
 
         cat >> "$TEMP_DIR/make.mk" << __EOF__
 LIB_EXT = .a
-OBJ_EXT = .o
 
 __EOF__
         break
--- a/make/cc.mk	Sun Oct 01 12:53:35 2023 +0200
+++ b/make/cc.mk	Sun Oct 01 13:56:42 2023 +0200
@@ -6,6 +6,3 @@
 DEBUG_CC_FLAGS = -g
 RELEASE_CC_FLAGS = -O3 -DNDEBUG
 LDFLAGS =
-
-SHLIB_CFLAGS = -fPIC
-SHLIB_LDFLAGS = -shared
\ No newline at end of file
--- a/make/project.xml	Sun Oct 01 12:53:35 2023 +0200
+++ b/make/project.xml	Sun Oct 01 13:56:42 2023 +0200
@@ -5,10 +5,7 @@
 	</config>
 	<dependency>
 		<lang>c</lang>
-		<make>
-LIB_EXT = .a
-OBJ_EXT = .o
-		</make>
+		<make>LIB_EXT = .a</make>
 	</dependency>
 	<dependency name="mkdir">
 		<test>command -v mkdir</test>
--- a/src/Makefile	Sun Oct 01 12:53:35 2023 +0200
+++ b/src/Makefile	Sun Oct 01 13:56:42 2023 +0200
@@ -29,11 +29,9 @@
 include ../config.mk
 
 SRC  = main.c colors.c network.c input.c server.c client.c game.c
-
-OBJ = $(SRC:%.c=$(BUILDDIR)/%$(OBJ_EXT))
+OBJ = $(SRC:%.c=$(BUILDDIR)/%.o)
 
 all: $(BUILDDIR)/terminal-chess FORCE
-	@echo "Build complete."
 
 $(BUILDDIR)/terminal-chess: $(OBJ) $(BUILDDIR)/libchess$(LIB_EXT)
 	$(CC) -o $@ $(LDFLAGS) $^
@@ -41,7 +39,37 @@
 $(BUILDDIR)/libchess$(LIB_EXT): FORCE
 	cd chess; $(MAKE)
 
-$(BUILDDIR)/%$(OBJ_EXT): %.c
+FORCE:
+
+
+$(BUILDDIR)/client.o: client.c terminal-chess.h network.h chess/rules.h \
+ input.h game.h chess/chess.h chess/rules.h chess/pawn.h chess/rook.h \
+ chess/knight.h chess/bishop.h chess/queen.h chess/king.h chess/pgn.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+$(BUILDDIR)/colors.o: colors.c colors.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+$(BUILDDIR)/game.o: game.c game.h chess/chess.h chess/rules.h \
+ chess/pawn.h chess/rook.h chess/knight.h chess/bishop.h chess/queen.h \
+ chess/king.h chess/pgn.h terminal-chess.h network.h chess/rules.h \
+ input.h colors.h
 	$(CC) -o $@ $(CFLAGS) -c $<
 
-FORCE:
+$(BUILDDIR)/input.o: input.c input.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+$(BUILDDIR)/main.o: main.c terminal-chess.h network.h chess/rules.h \
+ game.h chess/chess.h chess/rules.h chess/pawn.h chess/rook.h \
+ chess/knight.h chess/bishop.h chess/queen.h chess/king.h chess/pgn.h \
+ input.h colors.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+$(BUILDDIR)/network.o: network.c network.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+$(BUILDDIR)/server.o: server.c terminal-chess.h network.h chess/rules.h \
+ game.h chess/chess.h chess/rules.h chess/pawn.h chess/rook.h \
+ chess/knight.h chess/bishop.h chess/queen.h chess/king.h chess/pgn.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
--- a/src/chess/Makefile	Sun Oct 01 12:53:35 2023 +0200
+++ b/src/chess/Makefile	Sun Oct 01 13:56:42 2023 +0200
@@ -28,17 +28,37 @@
 
 include ../../config.mk
 
-SRC = pawn.c rook.c knight.c bishop.c queen.c king.c \
-      rules.c pgn.c
+SRC = pawn.c rook.c knight.c bishop.c queen.c king.c rules.c pgn.c
+OBJ = $(SRC:%.c=$(BUILDDIR)/%.o)
+
+all: $(BUILDDIR)/libchess$(LIB_EXT) FORCE
+
+$(BUILDDIR)/libchess$(LIB_EXT): $(OBJ)
+	$(AR) $(ARFLAGS) $@ $^
 
-OBJ = $(SRC:%.c=$(BUILDDIR)/%$(OBJ_EXT))
+FORCE:
+
+$(BUILDDIR)/pawn.o: pawn.c pawn.h rules.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+$(BUILDDIR)/pgn.o: pgn.c pgn.h rules.h
+	$(CC) -o $@ $(CFLAGS) -c $<
 
-all: $(BUILDDIR) $(OBJ)
-	$(AR) $(ARFLAGS) $(BUILDDIR)/libchess$(LIB_EXT) $(OBJ)
+$(BUILDDIR)/rules.o: rules.c rules.h chess.h pawn.h rook.h \
+ knight.h bishop.h queen.h king.h pgn.h
+	$(CC) -o $@ $(CFLAGS) -c $<
 
-$(BUILDDIR)/%$(OBJ_EXT): %.c
+$(BUILDDIR)/bishop.o: bishop.c bishop.h rules.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+$(BUILDDIR)/knight.o: knight.c knight.h rules.h
 	$(CC) -o $@ $(CFLAGS) -c $<
-	
-$(BUILDDIR):
-	$(MKDIR) $(MKDIRFLAGS) $(BUILDDIR)
-	
+
+$(BUILDDIR)/queen.o: queen.c rules.h rook.h bishop.h queen.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+$(BUILDDIR)/king.o: king.c rules.h king.h
+	$(CC) -o $@ $(CFLAGS) -c $<
+
+$(BUILDDIR)/rook.o: rook.c rules.h rook.h
+	$(CC) -o $@ $(CFLAGS) -c $<
--- a/src/terminal-chess.h	Sun Oct 01 12:53:35 2023 +0200
+++ b/src/terminal-chess.h	Sun Oct 01 13:56:42 2023 +0200
@@ -36,7 +36,7 @@
 #ifndef TERMINAL_CHESS_H
 #define	TERMINAL_CHESS_H
 
-#define PROGRAM_VERSION "0.9-r71"
+#define PROGRAM_VERSION "0.9-r72"
 
 #ifdef	__cplusplus
 extern "C" {

mercurial