From: Andrea Canciani Date: Sun, 4 Sep 2011 16:00:38 +0000 (+0200) Subject: build-win32: Share targets and variables across win32 makefiles X-Git-Tag: pixman-0.23.6~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a76b78c2daa61900572014070d3e856a460fd554;p=platform%2Fupstream%2Fpixman.git build-win32: Share targets and variables across win32 makefiles The win32 build system repeatedly defines some basic variables (notably program names and flags) and C sources compilation rules. They can be factored out to a common Makefile, to be included in every other Makefile.win32. --- diff --git a/Makefile.win32.common b/Makefile.win32.common new file mode 100644 index 0000000..56c3593 --- /dev/null +++ b/Makefile.win32.common @@ -0,0 +1,54 @@ +LIBRARY = pixman-1 + +CC = cl +LD = link +AR = lib +PERL = perl + +ifeq ($(top_builddir),) +top_builddir = $(top_srcdir) +endif + +CFG_VAR = $(CFG) +ifeq ($(CFG_VAR),) +CFG_VAR = release +endif + +ifeq ($(CFG_VAR),debug) +CFG_CFLAGS = -MDd -Od -Zi +CFG_LDFLAGS = -DEBUG +else +CFG_CFLAGS = -MD -O2 +CFG_LDFLAGS = +endif + +# Package definitions, to be used instead of those provided in config.h +PKG_CFLAGS = -DPACKAGE=$(LIBRARY) -DPACKAGE_VERSION="" -DPACKAGE_BUGREPORT="" + +BASE_CFLAGS = -nologo -I. -I$(top_srcdir) -I$(top_srcdir)/pixman + +PIXMAN_CFLAGS = $(BASE_CFLAGS) $(PKG_CFLAGS) $(CFG_CFLAGS) $(CFLAGS) +PIXMAN_LDFLAGS = -nologo $(CFG_LDFLAGS) $(LDFLAGS) +PIXMAN_ARFLAGS = -nologo $(LDFLAGS) + + +inform: +ifneq ($(CFG),release) +ifneq ($(CFG),debug) +ifneq ($(CFG),) + @echo "Invalid specified configuration option: "$(CFG)"." + @echo + @echo "Possible choices for configuration are 'release' and 'debug'" + @exit 1 +endif + @echo "Using default RELEASE configuration... (use CFG=release or CFG=debug)" +endif +endif + + +$(CFG_VAR)/%.obj: %.c $(BUILT_SOURCES) + @mkdir -p $(CFG_VAR) + @$(CC) -c $(PIXMAN_CFLAGS) -Fo"$@" $< + +clean: inform + @$(RM) $(CFG_VAR)/*.{exe,ilk,lib,obj,pdb} $(BUILT_SOURCES) || exit 0 diff --git a/pixman/Makefile.win32 b/pixman/Makefile.win32 index d2d018a..beff4a0 100644 --- a/pixman/Makefile.win32 +++ b/pixman/Makefile.win32 @@ -2,17 +2,7 @@ default: all top_srcdir = .. include $(top_srcdir)/pixman/Makefile.sources - -LIBRARY = pixman-1 - -CC = cl -LINK = link -PERL = perl - -CFG_VAR = $(CFG) -ifeq ($(CFG_VAR),) -CFG_VAR=release -endif +include $(top_srcdir)/Makefile.win32.common MMX_VAR = $(MMX) ifeq ($(MMX_VAR),) @@ -24,26 +14,18 @@ ifeq ($(SSE2_VAR),) SSE2_VAR=on endif -CFLAGS = -MD -nologo -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -I../pixman/src -I. -DPACKAGE=$(LIBRARY) -DPACKAGE_VERSION="" -DPACKAGE_BUGREPORT="" MMX_CFLAGS = -DUSE_MMX -w14710 -w14714 SSE2_CFLAGS = -DUSE_SSE2 -# optimization flags -ifeq ($(CFG_VAR),debug) -CFLAGS += -Od -Zi -else -CFLAGS += -O2 -endif - # MMX compilation flags ifeq ($(MMX_VAR),on) -CFLAGS += $(MMX_CFLAGS) +PIXMAN_CFLAGS += $(MMX_CFLAGS) libpixman_sources += pixman-mmx.c endif # SSE2 compilation flags ifeq ($(SSE2_VAR),on) -CFLAGS += $(SSE2_CFLAGS) +PIXMAN_CFLAGS += $(SSE2_CFLAGS) libpixman_sources += pixman-sse2.c endif @@ -51,26 +33,6 @@ OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(libpixman_sources)) # targets all: inform informMMX informSSE2 $(CFG_VAR)/$(LIBRARY).lib - @exit 0 -clean: inform clean_r - @exit 0 -pixman: inform informMMX informSSE2 $(CFG_VAR)/$(LIBRARY).lib - @exit 0 - -inform: -ifneq ($(CFG),release) -ifneq ($(CFG),debug) -ifneq ($(CFG),) - @echo "Invalid specified configuration option : "$(CFG)"." - @echo - @echo -n "Possible choices for configuration are " - @echo "'release' and 'debug'" - @echo "" - @exit 1 -endif - @echo "Using default RELEASE configuration... (use CFG=release or CFG=debug)" -endif -endif informMMX: ifneq ($(MMX),off) @@ -78,8 +40,7 @@ ifneq ($(MMX),on) ifneq ($(MMX),) @echo "Invalid specified MMX option : "$(MMX_VAR)"." @echo - @echo -n "Possible choices for MMX are 'on' or 'off'" - @echo "" + @echo "Possible choices for MMX are 'on' or 'off'" @exit 1 endif @echo "Setting MMX flag to default value 'on'... (use MMX=on or MMX=off)" @@ -92,22 +53,14 @@ ifneq ($(SSE2),on) ifneq ($(SSE2),) @echo "Invalid specified SSE option : "$(SSE2)"." @echo - @echo -n "Possible choices for SSE2 are 'on' or 'off'" - @echo "" + @echo "Possible choices for SSE2 are 'on' or 'off'" @exit 1 endif @echo "Setting SSE2 flag to default value 'on'... (use SSE2=on or SSE2=off)" endif endif -# pixman compilation and linking -$(CFG_VAR)/%.obj: %.c $(BUILT_SOURCES) - @mkdir -p $(CFG_VAR) - @$(CC) -c $(CFLAGS) -Fo"$@" $< +# pixman linking $(CFG_VAR)/$(LIBRARY).lib: $(OBJECTS) - lib -NOLOGO -OUT:$@ $(OBJECTS) || exit 0 - -clean_r: - @rm -f $(CFG_VAR)/*.obj $(CFG_VAR)/*.lib $(CFG_VAR)/*.pdb $(CFG)/*.ilk || exit 0 - @rm -f $(CFG)/*.obj $(CFG)/*.lib $(CFG)/*.pdb $(CFG)/*.ilk $(BUILT_SOURCES) || exit 0 + @$(AR) $(PIXMAN_ARFLAGS) -OUT:$@ $^ diff --git a/test/Makefile.win32 b/test/Makefile.win32 index 215fb04..c857db9 100644 --- a/test/Makefile.win32 +++ b/test/Makefile.win32 @@ -2,25 +2,12 @@ default: all top_srcdir = .. include $(top_srcdir)/test/Makefile.sources +include $(top_srcdir)/Makefile.win32.common -CC = cl -LINK = link - -CFG_VAR = $(CFG) -ifeq ($(CFG_VAR),) -CFG_VAR=release -endif - -CFLAGS = -MD -nologo -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_BIND_TO_CURRENT_VCLIBS_VERSION -D_MT -I../pixman -I. -I../ -TEST_LDADD = ../pixman/$(CFG_VAR)/pixman-1.lib $(CFG_VAR)/libutils.lib -INCLUDES = -I../pixman -I$(top_builddir)/pixman - -# optimization flags -ifeq ($(CFG_VAR),debug) -CFLAGS += -Od -Zi -else -CFLAGS += -O2 -endif +TEST_LDADD = \ + $(top_builddir)/pixman/$(CFG_VAR)/$(LIBRARY).lib \ + $(CFG_VAR)/libutils.lib \ + $(NULL) libutils_OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(libutils_sources)) @@ -29,18 +16,13 @@ OBJECTS = $(patsubst %.c, $(CFG_VAR)/%.obj, $(SOURCES)) TESTS = $(patsubst %, $(CFG_VAR)/%.exe, $(TESTPROGRAMS)) BENCHS = $(patsubst %, $(CFG_VAR)/%.exe, $(BENCHMARKS)) - -all: $(TESTS) $(BENCHS) +all: inform $(TESTS) $(BENCHS) $(CFG_VAR)/libutils.lib: $(libutils_OBJECTS) - @lib -NOLOGO -OUT:$@ $^ || exit 0 - -$(CFG_VAR)/%.obj: %.c - @mkdir -p $(CFG_VAR) - @$(CC) -c $(CFLAGS) -Fo"$@" $< + @$(AR) $(PIXMAN_ARFLAGS) -OUT:$@ $^ $(CFG_VAR)/%.exe: $(CFG_VAR)/%.obj $(TEST_LDADD) - @$(LINK) /NOLOGO /OUT:$@ $^ + @$(LD) $(PIXMAN_LDFLAGS) -OUT:$@ $^ -clean: - @rm -f $(CFG_VAR)/*.obj $(CFG_VAR)/*.pdb || exit 0 +$(top_builddir)/pixman/$(CFG_VAR)/$(LIBRARY).lib: + @$(MAKE) -C $(top_builddir)/pixman -f Makefile.win32