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:
parent
7e1a94820d
commit
b5f2f44fcc
54
Makefile
54
Makefile
|
@ -1,30 +1,38 @@
|
||||||
CC = gcc
|
# Compiler and linker flags needed to link to the needed libraries:
|
||||||
clientsrc = $(wildcard src/*.c) \
|
|
||||||
src/client/SilverMUDClient.c
|
|
||||||
clientobj = $(clientsrc:.c=.o)
|
|
||||||
serversrc = $(wildcard src/*.c) \
|
|
||||||
src/server/SilverMUDServer.c
|
|
||||||
serverobj = $(serversrc:.c=.o)
|
|
||||||
CFLAGS = `pkg-config --cflags guile-3.0`
|
CFLAGS = `pkg-config --cflags guile-3.0`
|
||||||
CLIENTLDFLAGS= -lpthread -lncurses -lgnutls `pkg-config --libs guile-3.0`
|
LDFLAGS= -lpthread -lncurses -lgnutls `pkg-config --libs guile-3.0`
|
||||||
SERVERLDFLAGS= -lpthread -lncurses -lgnutls `pkg-config --libs guile-3.0`
|
|
||||||
SilverMUDClient: $(clientobj)
|
|
||||||
gcc -o $@ $^ $(CLIENTLDFLAGS)
|
|
||||||
|
|
||||||
SilverMUDServer: $(serverobj)
|
# Files needed to compile the client:
|
||||||
gcc -o $@ $^ $(SERVERLDFLAGS)
|
clientsrc = $(wildcard src/*.c) src/client/SilverMUDClient.c
|
||||||
|
clientobj = $(clientsrc:.c=.o)
|
||||||
|
|
||||||
SilverMUDClientDebug: $(clientobj)
|
# Files needed to compile the server:
|
||||||
gcc -pg $^ $(CLIENTLDFLAGS) -o $@
|
serversrc = $(wildcard src/*.c) src/server/SilverMUDServer.c
|
||||||
|
serverobj = $(serversrc:.c=.o)
|
||||||
SilverMUDServerDebug: $(serverobj)
|
|
||||||
gcc -pg $^ $(SERVERLDFLAGS) -o $@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
clean:
|
|
||||||
rm -f $(clientobj) $(serverobj) SilverMUDClient SilverMUDServer SilverMUDClientDebug SilverMUDServerDebug
|
|
||||||
|
|
||||||
|
# Default target: Compile the client and server with aggressive optimizations and a big stack of warnings:
|
||||||
all: clean SilverMUDClient SilverMUDServer
|
all: clean SilverMUDClient SilverMUDServer
|
||||||
all: CFLAGS += -Wall -Wextra -Ofast
|
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: CFLAGS += -Wall -Wextra -pg -ggdb -Og -D debug
|
||||||
debug: clean SilverMUDClientDebug SilverMUDServerDebug
|
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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue