1
0
mirror of https://github.com/solemnwarning/ipxwrapper synced 2024-12-30 16:45:37 +01:00

Generate header dependencies on the fly using gcc -MM.

This commit is contained in:
Daniel Collins 2012-10-21 12:08:31 +00:00
parent c6e1cc9665
commit b95d88a5c4
2 changed files with 52 additions and 4 deletions

View File

@ -20,9 +20,16 @@ else
DBG_OPT := -Wl,-s
endif
CFLAGS := -Wall -D_WIN32_WINNT=0x0500 $(DBG_OPT) -I./include/
CFLAGS := -Wall -D_WIN32_WINNT=0x0500 $(DBG_OPT) -I./include/
CXXFLAGS := $(CFLAGS)
# Used by mkdeps.pl
#
export CC
export CFLAGS
export CXX
export CXXFLAGS
VERSION := r$(shell svn info | grep Revision | sed -e 's/.*: //')
IPXWRAPPER_DEPS := src/ipxwrapper.o src/winsock.o src/ipxwrapper_stubs.o src/log.o src/common.o \
@ -43,7 +50,7 @@ all: ipxwrapper.dll wsock32.dll mswsock.dll ipxconfig.exe dpwsockx.dll ipxrouter
clean:
rm -f ipxwrapper.dll wsock32.dll mswsock.dll ipxconfig.exe dpwsockx.dll ipxrouter.exe
rm -f src/*.o src/*_stubs.s version.o
rm -f src/*.o src/*_stubs.s version.o Makefile.dep
dist: all
mkdir ipxwrapper-$(VERSION)
@ -57,7 +64,14 @@ dist: all
rm -r ipxwrapper-$(VERSION)-src/
.SECONDARY:
.PHONY: all clean dist
.PHONY: all clean dist depend
depend: Makefile.dep
Makefile.dep: src/*.c src/*.cpp
perl mkdeps.pl
-include Makefile.dep
ipxwrapper.dll: $(IPXWRAPPER_DEPS)
echo 'const char *version_string = "$(VERSION)", *compile_time = "'`date`'";' | $(CC) -c -x c -o version.o -
@ -93,5 +107,5 @@ icons/%.o: icons/%.rc icons/%.ico
src/%_stubs.o: src/%_stubs.s
nasm -f win32 -o $@ $<
src/%.o: src/%.c src/ipxwrapper.h src/config.h src/common.h src/router.h
src/%.o: src/%.c
$(CC) $(CFLAGS) -c -o $@ $<

34
mkdeps.pl Normal file
View File

@ -0,0 +1,34 @@
# IPXWrapper - Generate Make dependencies
# Copyright (C) 2012 Daniel Collins <solemnwarning@solemnwarning.net>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
use strict;
use warnings;
my $cc = $ENV{CC};
my $cflags = $ENV{CFLAGS};
my $cxx = $ENV{CXX};
my $cxxflags = $ENV{CXXFLAGS};
open(my $depends, ">Makefile.dep") or die("Cannot open Makefile.dep: $!");
foreach my $cmd((map { "$cc $cflags -MM $_" } glob("src/*.c")), (map { "$cxx $cxxflags -MM $_" } glob("src/*.cpp")))
{
print "mkdeps.pl: $cmd\n";
print {$depends} "src/".qx($cmd)."\n";
}
close($depends);