src/chess/Makefile

changeset 72
7e58e0f74e50
parent 71
0bdb910478cc
--- 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 $<

mercurial