Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update configure file #55

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ CFLAGS="--std=gnu99 -pedantic -Wall -Wextra -Werror -ggdb3 -I$LIBDIR"
LDFLAGS=''

# Calculate protocol version
PROTO="-DPROTOCOL_VERSION="'`perl -lne '"'\
"'$$a+=$$_+$$. for split//;END{print$$a}'"'"' src/*`'
# Get contents of all sources files sum each symbol and file's lines count
PROTO_CALC_RUNNER="perl -lne '\$\$a += \$\$_ + \$\$. for split//; END{print \$\$a}' src/*"

case $OS in
SunOS)
Expand All @@ -54,6 +54,8 @@ case $OS in
;;
Linux)
CFLAGS="$CFLAGS -lncursesw -pthread -I /usr/include/ncursesw"
# need to be linked after object files that uses this library
# see '3.14 Options for Linking' in latest gcc manual
CFLAGS_END="-lncursesw"
;;
*)
Expand Down Expand Up @@ -139,12 +141,22 @@ rm -f bin/style.o bin/ncursesw.c bin/ncursesw

cat >Makefile <<EOF
# Makefile for ITMMORGUE
CC=$CC
SOURCES=$SRC
CC = $CC
SOURCES = $SRC
LDFLAGS = $LDFLAGS
CFLAGS = $CFLAGS
OBJECTS = $OBJECTS
HEADERS = $HEADERS
LIBS = $LIBS

all: $EXECUTABLE
@echo "Run 'make run' now to start the game! "

env:
@echo "[env] setting environment variable"
\$(eval PROTO := \$(shell $PROTO_CALC_RUNNER))
@echo "[env] PROTOCOL_VERSION = \$(PROTO)"

run: run_client
@echo "Running the game..."

Expand All @@ -167,19 +179,19 @@ debug: $EXECUTABLE
$WORKDIR:
mkdir $WORKDIR

$EXECUTABLE: bin $OBJECTS $LIBS
\$(CC) $LDFLAGS $CFLAGS $OBJECTS $LIBS -o $EXECUTABLE $CFLAGS_END
$EXECUTABLE: env bin \$(OBJECTS) \$(LIBS)
\$(CC) \$(LDFLAGS) \$(CFLAGS) \$(OBJECTS) \$(LIBS) -o $EXECUTABLE $CFLAGS_END

EOF

# objects
for C in $SRC ;do
O=`echo "$C " | sed 's/\\.c /.o/g'`
O="$WORKDIR/$O"
cat >>Makefile <<EOF
$O : $SRCDIR/$C $HEADERS
\$(CC) $CFLAGS $PROTO -c $SRCDIR/$C -o $O
O=`echo "$C " | sed 's/\\.c /.o/g'`
O="$WORKDIR/$O"
cat >>Makefile <<EOF

$O : $SRCDIR/$C \$(HEADERS)
\$(CC) \$(CFLAGS) -DPROTOCOL_VERSION=\$(PROTO) -c $SRCDIR/$C -o $O
EOF
done

Expand Down