diff --git a/inc/My/Builder.pm b/inc/My/Builder.pm index e6cea1b7..8981ff71 100644 --- a/inc/My/Builder.pm +++ b/inc/My/Builder.pm @@ -97,29 +97,22 @@ sub ACTION_server { my $server_directory = 'server'; my $otarget = 'fb-server'; return if (-e 'bin/'.$otarget ); - # CBuilder doesn't take shell quoting into consideration, - # so the -DVERSION macro does not work like in the former Makefile. - # Instead, I'll just preprocess the two files with perl. - { - my $version = $self->dist_version; - # perl -pie again has problems with shell quoting for the -e'' part. - for my $cfile ( - map {catfile($server_directory, $_)} qw(fb-server.c net.c) - ) { - my $csource = read_file($cfile); - $csource =~ s{" VERSION "}{$version}; - write_file($cfile, $csource); - } - } + + require Games::FrozenBubble; + + my $version = ' -DVERSION="'.$Games::FrozenBubble::RELEASE_VERSION.'" '; { my $cbuilder = ExtUtils::CBuilder->new; + my $cpp = $cbuilder->{config}->{'cppflags'}; + $cpp = $version. $cpp; + $cbuilder->{config}->{'cppflags'} = $cpp; my @ofiles; for my $cfile (qw(fb-server.c log.c tools.c game.c net.c)) { push @ofiles, $cbuilder->compile( source => catfile($server_directory, $cfile), extra_compiler_flags => [ - qw(-g -Wall -Werror -pipe), # verbatim from Makefile + qw(-g -Wall -Werror -pipe ), # verbatim from Makefile '-I' . $server_directory, # does not seem to be necessary $cbuilder->split_like_shell(`pkg-config glib-2.0 --cflags`), $cbuilder->split_like_shell(`pkg-config glib-2.0 --libs`), diff --git a/server/net.c b/server/net.c index 7a0e0f6d..18874702 100644 --- a/server/net.c +++ b/server/net.c @@ -988,7 +988,7 @@ static char * http_get(char * host, int port, char * path) } uname(&uname_); - user_agent = asprintf_("Frozen-Bubble server version 0.001_1 (protocol version %d.%d) on %s/%s\n", proto_major, proto_minor, uname_.sysname, uname_.machine); + user_agent = asprintf_("Frozen-Bubble server version " VERSION " (protocol version %d.%d) on %s/%s\n", proto_major, proto_minor, uname_.sysname, uname_.machine); buf = asprintf_("GET %s HTTP/0.9\r\nHost: %s\r\nUser-Agent: %s\r\n\r\n", path, host, user_agent); free(user_agent); if (write(sock, buf, strlen(buf)) != strlen(buf)) {