Improved makefile.

- Makefile now doesn't hardcode gcc. (Whether SilverMUD is compiler agnostic remains to be seen.)
- The first target is now all, which compiles a "release" build.
- General cleanup, removal of duplicate variables, and commenting.
This commit is contained in:
Barra Ó Catháin 2023-04-11 11:33:36 +01:00
parent 7e1a94820d
commit b5f2f44fcc
1 changed files with 31 additions and 23 deletions

View File

@ -1,30 +1,38 @@
CC = gcc
clientsrc = $(wildcard src/*.c) \
src/client/SilverMUDClient.c
clientobj = $(clientsrc:.c=.o)
serversrc = $(wildcard src/*.c) \
src/server/SilverMUDServer.c
serverobj = $(serversrc:.c=.o)
# Compiler and linker flags needed to link to the needed libraries:
CFLAGS = `pkg-config --cflags guile-3.0`
CLIENTLDFLAGS= -lpthread -lncurses -lgnutls `pkg-config --libs guile-3.0`
SERVERLDFLAGS= -lpthread -lncurses -lgnutls `pkg-config --libs guile-3.0`
SilverMUDClient: $(clientobj)
gcc -o $@ $^ $(CLIENTLDFLAGS)
LDFLAGS= -lpthread -lncurses -lgnutls `pkg-config --libs guile-3.0`
SilverMUDServer: $(serverobj)
gcc -o $@ $^ $(SERVERLDFLAGS)
# Files needed to compile the client:
clientsrc = $(wildcard src/*.c) src/client/SilverMUDClient.c
clientobj = $(clientsrc:.c=.o)
SilverMUDClientDebug: $(clientobj)
gcc -pg $^ $(CLIENTLDFLAGS) -o $@
SilverMUDServerDebug: $(serverobj)
gcc -pg $^ $(SERVERLDFLAGS) -o $@
.PHONY: clean
clean:
rm -f $(clientobj) $(serverobj) SilverMUDClient SilverMUDServer SilverMUDClientDebug SilverMUDServerDebug
# Files needed to compile the server:
serversrc = $(wildcard src/*.c) src/server/SilverMUDServer.c
serverobj = $(serversrc:.c=.o)
# Default target: Compile the client and server with aggressive optimizations and a big stack of warnings:
all: clean SilverMUDClient SilverMUDServer
all: CFLAGS += -Wall -Wextra -Ofast
# Debug target: Compile the client and server with profiling, debug information, debug optimization, and the
# preprocessor flag "debug" set.
debug: CFLAGS += -Wall -Wextra -pg -ggdb -Og -D debug
debug: clean SilverMUDClientDebug SilverMUDServerDebug
SilverMUDClient: $(clientobj)
cc $^ $(LDFLAGS) -o $@
SilverMUDServer: $(serverobj)
cc $^ $(LDFLAGS) -o $@
SilverMUDClientDebug: $(clientobj)
cc -pg $^ $(LDFLAGS) -o $@
SilverMUDServerDebug: $(serverobj)
cc -pg $^ $(LDFLAGS) -o $@
# Start from a clean slate:
.PHONY: clean
clean:
rm -f $(clientobj) $(serverobj) SilverMUDClient SilverMUDServer SilverMUDClientDebug SilverMUDServerDebug gmon.out