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
     1.1 --- a/configure	Sun Oct 01 12:53:35 2023 +0200
     1.2 +++ b/configure	Sun Oct 01 13:56:42 2023 +0200
     1.3 @@ -328,7 +328,6 @@
     1.4  
     1.5          cat >> "$TEMP_DIR/make.mk" << __EOF__
     1.6  LIB_EXT = .a
     1.7 -OBJ_EXT = .o
     1.8  
     1.9  __EOF__
    1.10          break
     2.1 --- a/make/cc.mk	Sun Oct 01 12:53:35 2023 +0200
     2.2 +++ b/make/cc.mk	Sun Oct 01 13:56:42 2023 +0200
     2.3 @@ -6,6 +6,3 @@
     2.4  DEBUG_CC_FLAGS = -g
     2.5  RELEASE_CC_FLAGS = -O3 -DNDEBUG
     2.6  LDFLAGS =
     2.7 -
     2.8 -SHLIB_CFLAGS = -fPIC
     2.9 -SHLIB_LDFLAGS = -shared
    2.10 \ No newline at end of file
     3.1 --- a/make/project.xml	Sun Oct 01 12:53:35 2023 +0200
     3.2 +++ b/make/project.xml	Sun Oct 01 13:56:42 2023 +0200
     3.3 @@ -5,10 +5,7 @@
     3.4  	</config>
     3.5  	<dependency>
     3.6  		<lang>c</lang>
     3.7 -		<make>
     3.8 -LIB_EXT = .a
     3.9 -OBJ_EXT = .o
    3.10 -		</make>
    3.11 +		<make>LIB_EXT = .a</make>
    3.12  	</dependency>
    3.13  	<dependency name="mkdir">
    3.14  		<test>command -v mkdir</test>
     4.1 --- a/src/Makefile	Sun Oct 01 12:53:35 2023 +0200
     4.2 +++ b/src/Makefile	Sun Oct 01 13:56:42 2023 +0200
     4.3 @@ -29,11 +29,9 @@
     4.4  include ../config.mk
     4.5  
     4.6  SRC  = main.c colors.c network.c input.c server.c client.c game.c
     4.7 -
     4.8 -OBJ = $(SRC:%.c=$(BUILDDIR)/%$(OBJ_EXT))
     4.9 +OBJ = $(SRC:%.c=$(BUILDDIR)/%.o)
    4.10  
    4.11  all: $(BUILDDIR)/terminal-chess FORCE
    4.12 -	@echo "Build complete."
    4.13  
    4.14  $(BUILDDIR)/terminal-chess: $(OBJ) $(BUILDDIR)/libchess$(LIB_EXT)
    4.15  	$(CC) -o $@ $(LDFLAGS) $^
    4.16 @@ -41,7 +39,37 @@
    4.17  $(BUILDDIR)/libchess$(LIB_EXT): FORCE
    4.18  	cd chess; $(MAKE)
    4.19  
    4.20 -$(BUILDDIR)/%$(OBJ_EXT): %.c
    4.21 +FORCE:
    4.22 +
    4.23 +
    4.24 +$(BUILDDIR)/client.o: client.c terminal-chess.h network.h chess/rules.h \
    4.25 + input.h game.h chess/chess.h chess/rules.h chess/pawn.h chess/rook.h \
    4.26 + chess/knight.h chess/bishop.h chess/queen.h chess/king.h chess/pgn.h
    4.27  	$(CC) -o $@ $(CFLAGS) -c $<
    4.28  
    4.29 -FORCE:
    4.30 +$(BUILDDIR)/colors.o: colors.c colors.h
    4.31 +	$(CC) -o $@ $(CFLAGS) -c $<
    4.32 +
    4.33 +$(BUILDDIR)/game.o: game.c game.h chess/chess.h chess/rules.h \
    4.34 + chess/pawn.h chess/rook.h chess/knight.h chess/bishop.h chess/queen.h \
    4.35 + chess/king.h chess/pgn.h terminal-chess.h network.h chess/rules.h \
    4.36 + input.h colors.h
    4.37 +	$(CC) -o $@ $(CFLAGS) -c $<
    4.38 +
    4.39 +$(BUILDDIR)/input.o: input.c input.h
    4.40 +	$(CC) -o $@ $(CFLAGS) -c $<
    4.41 +
    4.42 +$(BUILDDIR)/main.o: main.c terminal-chess.h network.h chess/rules.h \
    4.43 + game.h chess/chess.h chess/rules.h chess/pawn.h chess/rook.h \
    4.44 + chess/knight.h chess/bishop.h chess/queen.h chess/king.h chess/pgn.h \
    4.45 + input.h colors.h
    4.46 +	$(CC) -o $@ $(CFLAGS) -c $<
    4.47 +
    4.48 +$(BUILDDIR)/network.o: network.c network.h
    4.49 +	$(CC) -o $@ $(CFLAGS) -c $<
    4.50 +
    4.51 +$(BUILDDIR)/server.o: server.c terminal-chess.h network.h chess/rules.h \
    4.52 + game.h chess/chess.h chess/rules.h chess/pawn.h chess/rook.h \
    4.53 + chess/knight.h chess/bishop.h chess/queen.h chess/king.h chess/pgn.h
    4.54 +	$(CC) -o $@ $(CFLAGS) -c $<
    4.55 +
     5.1 --- a/src/chess/Makefile	Sun Oct 01 12:53:35 2023 +0200
     5.2 +++ b/src/chess/Makefile	Sun Oct 01 13:56:42 2023 +0200
     5.3 @@ -28,17 +28,37 @@
     5.4  
     5.5  include ../../config.mk
     5.6  
     5.7 -SRC = pawn.c rook.c knight.c bishop.c queen.c king.c \
     5.8 -      rules.c pgn.c
     5.9 +SRC = pawn.c rook.c knight.c bishop.c queen.c king.c rules.c pgn.c
    5.10 +OBJ = $(SRC:%.c=$(BUILDDIR)/%.o)
    5.11  
    5.12 -OBJ = $(SRC:%.c=$(BUILDDIR)/%$(OBJ_EXT))
    5.13 +all: $(BUILDDIR)/libchess$(LIB_EXT) FORCE
    5.14  
    5.15 -all: $(BUILDDIR) $(OBJ)
    5.16 -	$(AR) $(ARFLAGS) $(BUILDDIR)/libchess$(LIB_EXT) $(OBJ)
    5.17 +$(BUILDDIR)/libchess$(LIB_EXT): $(OBJ)
    5.18 +	$(AR) $(ARFLAGS) $@ $^
    5.19  
    5.20 -$(BUILDDIR)/%$(OBJ_EXT): %.c
    5.21 +FORCE:
    5.22 +
    5.23 +$(BUILDDIR)/pawn.o: pawn.c pawn.h rules.h
    5.24  	$(CC) -o $@ $(CFLAGS) -c $<
    5.25 -	
    5.26 -$(BUILDDIR):
    5.27 -	$(MKDIR) $(MKDIRFLAGS) $(BUILDDIR)
    5.28 -	
    5.29 +
    5.30 +$(BUILDDIR)/pgn.o: pgn.c pgn.h rules.h
    5.31 +	$(CC) -o $@ $(CFLAGS) -c $<
    5.32 +
    5.33 +$(BUILDDIR)/rules.o: rules.c rules.h chess.h pawn.h rook.h \
    5.34 + knight.h bishop.h queen.h king.h pgn.h
    5.35 +	$(CC) -o $@ $(CFLAGS) -c $<
    5.36 +
    5.37 +$(BUILDDIR)/bishop.o: bishop.c bishop.h rules.h
    5.38 +	$(CC) -o $@ $(CFLAGS) -c $<
    5.39 +
    5.40 +$(BUILDDIR)/knight.o: knight.c knight.h rules.h
    5.41 +	$(CC) -o $@ $(CFLAGS) -c $<
    5.42 +
    5.43 +$(BUILDDIR)/queen.o: queen.c rules.h rook.h bishop.h queen.h
    5.44 +	$(CC) -o $@ $(CFLAGS) -c $<
    5.45 +
    5.46 +$(BUILDDIR)/king.o: king.c rules.h king.h
    5.47 +	$(CC) -o $@ $(CFLAGS) -c $<
    5.48 +
    5.49 +$(BUILDDIR)/rook.o: rook.c rules.h rook.h
    5.50 +	$(CC) -o $@ $(CFLAGS) -c $<
     6.1 --- a/src/terminal-chess.h	Sun Oct 01 12:53:35 2023 +0200
     6.2 +++ b/src/terminal-chess.h	Sun Oct 01 13:56:42 2023 +0200
     6.3 @@ -36,7 +36,7 @@
     6.4  #ifndef TERMINAL_CHESS_H
     6.5  #define	TERMINAL_CHESS_H
     6.6  
     6.7 -#define PROGRAM_VERSION "0.9-r71"
     6.8 +#define PROGRAM_VERSION "0.9-r72"
     6.9  
    6.10  #ifdef	__cplusplus
    6.11  extern "C" {

mercurial