summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@beryl-project.org>2007-05-06 00:18:36 +0200
committerDennis kasprzyk <onestone@beryl-project.org>2007-05-06 00:18:36 +0200
commit27a6ce390e00e37f4f3441c129b81eba159ffc15 (patch)
tree26adf397caac050b06230f2fb46793177c2c0370
parent7d463ca7a45fdfa0c1ed987ecfb98a7409d66322 (diff)
downloadwinrules-27a6ce390e00e37f4f3441c129b81eba159ffc15.tar.gz
winrules-27a6ce390e00e37f4f3441c129b81eba159ffc15.tar.bz2
updated Makefile
-rw-r--r--Makefile195
1 files changed, 107 insertions, 88 deletions
diff --git a/Makefile b/Makefile
index 7628d00..e592676 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
##
#
-# Compiz plugin Makefile
+# Beryl/Compiz plugin Makefile
#
# Copyright : (C) 2006 by Dennis Kasprzyk
# E-mail : dennis.kasprzyk@rwth-aachen.de
@@ -18,10 +18,22 @@
#
##
-DESTDIR = $(HOME)/.compiz/plugins
-XMLDIR = $(HOME)/.compiz/metadata
+## configuration
+
+#enter plugin name here
PLUGIN = winrules
-SHADER = yes
+
+#enter dependencies here
+PKG_DEP =
+
+## end of configuration
+
+#enter beryl or compiz here
+TARGET = compiz
+
+
+DESTDIR = $(HOME)/.$(TARGET)/plugins
+XMLDIR = $(HOME)/.$(TARGET)/metadata
BUILDDIR = build
@@ -29,59 +41,121 @@ CC = gcc
LIBTOOL = libtool
INSTALL = install
-CGC = /usr/bin/cgc
+BCOP = `pkg-config --variable=bin bcop`
-#CFLAGS = -g -Wall `pkg-config --cflags x11 compiz`
-CFLAGS = -g -Wall -DGL_DEBUG `pkg-config --cflags x11 compiz`
-LDFLAGS = `pkg-config --libs x11 `
+CFLAGS = -g -Wall `pkg-config --cflags $(PKG_DEP) $(TARGET) `
+LDFLAGS = `pkg-config --libs $(PKG_DEP) $(TARGET) `
-vert-shaders := $(patsubst %.vcg,%.vert,$(shell find -name '*.vcg' 2> /dev/null | sed -e 's/^.\///'))
-frag-shaders := $(patsubst %.fcg,%.frag,$(shell find -name '*.fcg' 2> /dev/null | sed -e 's/^.\///'))
+is-bcop-target := $(shell if [ -e $(PLUGIN).xml ]; then cat $(PLUGIN).xml | grep "useBcop=\"true\"";fi )
-shader_files := $(shell find -name '*.vcg' 2> /dev/null | sed -e 's/^.\///')
-shader_files += $(shell find -name '*.fcg' 2> /dev/null | sed -e 's/^.\///')
+bcop-target := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN).xml; fi )
+bcop-target-src := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN)_options.c; fi )
+bcop-target-hdr := $(shell if [ -n "$(is-bcop-target)" ]; then echo $(PLUGIN)_options.h; fi )
-headers := $(shell find -name '$(PLUGIN)*.h' 2> /dev/null | sed -e 's/^.\///')
-headers := $(filter-out $(PLUGIN)_shader.h,$(headers))
+# find all the object files (including those from .moc.cpp files)
-shader_header := $(shell if [ -x $(CGC) -a '$(SHADER)' == 'yes' ]; then echo "$(PLUGIN)_shader.h"; fi )
+c-objs := $(patsubst %.c,%.lo,$(shell find -name '*.c' 2> /dev/null | grep -v "$(BUILDDIR)/" | sed -e 's/^.\///'))
+c-objs := $(filter-out $(bcop-target-src:.c=.lo),$(c-objs))
+c-objs += $(bcop-target-src:.c=.lo)
+# system include path parameter, -isystem doesn't work on old gcc's
+inc-path-param = $(shell if [ -z "`gcc --version | head -n 1 | grep ' 3'`" ]; then echo "-isystem"; else echo "-I"; fi)
-shaders := $(addprefix $(BUILDDIR)/,$(vert-shaders))
-shaders += $(addprefix $(BUILDDIR)/,$(frag-shaders))
-
+# default color settings
color := $(shell if [ $$TERM = "dumb" ]; then echo "no"; else echo "yes"; fi)
-.PHONY: $(BUILDDIR)/compiz_$(PLUGIN).csm
-all: $(BUILDDIR) $(shader_header) $(BUILDDIR)/lib$(PLUGIN).la
+#
+# Do it.
+#
+
+.PHONY: $(BUILDDIR) build-dir bcop-build c-build-objs c-link-plugin
+
+all: $(BUILDDIR) build-dir bcop-build c-build-objs c-link-plugin
+
+bcop-build: $(bcop-target-hdr) $(bcop-target-src)
+
+c-build-objs: $(addprefix $(BUILDDIR)/,$(cxx-objs))
+
+c-link-plugin: $(BUILDDIR)/lib$(PLUGIN).la
+
+#
+# Create build directory
+#
$(BUILDDIR) :
- @mkdir $(BUILDDIR)
+ @mkdir -p $(BUILDDIR)
+
+$(DESTDIR) :
+ @mkdir -p q$(DESTDIR)
+
+#
+# BCOP'ing
+
+%_options.h: %.xml
+ @if [ '$(color)' != 'no' ]; then \
+ echo -e -n "\033[0;1;5mbcop'ing \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
+ else \
+ echo "bcop'ing $< -> $@"; \
+ fi
+ @$(BCOP) --header=$@ $<
+ touch $@
+ @if [ '$(color)' != 'no' ]; then \
+ echo -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \
+ fi
+
+%_options.c: %.xml
+ @if [ '$(color)' != 'no' ]; then \
+ echo -e -n "\033[0;1;5mbcop'ing \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
+ else \
+ echo "bcop'ing $< -> $@"; \
+ fi
+ @$(BCOP) --source=$@ $<
+ touch $@
+ @if [ '$(color)' != 'no' ]; then \
+ echo -e "\r\033[0mbcop'ing : \033[34m$< -> $@\033[0m"; \
+ fi
-$(BUILDDIR)/lib$(PLUGIN).lo: $(PLUGIN).c $(headers) $(shader_header)
+
+#
+# Compiling
+#
+
+$(BUILDDIR)/%.lo: %.c
@if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5mcompiling \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
+ echo -n -e "\033[0;1;5mcompiling \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
else \
- echo "compiling : $< -> $@"; \
+ echo "compiling $< -> $@"; \
fi
@$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) -c -o $@ $<
@if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
+ echo -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
fi
-$(BUILDDIR)/lib$(PLUGIN).la: $(BUILDDIR)/lib$(PLUGIN).lo
+#
+# Linking
+#
+
+cxx-rpath-prefix := -Wl,-rpath,
+
+$(BUILDDIR)/lib$(PLUGIN).la: $(addprefix $(BUILDDIR)/,$(c-objs))
@if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5mlinking \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
+ echo -e -n "\033[0;1;5mlinking -> \033[0;31m$@\033[0m"; \
else \
- echo "linking : $< -> $@"; \
+ echo "linking -> $@"; \
fi
- @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $<
+ @$(LIBTOOL) --quiet --mode=link $(CC) $(LDFLAGS) -rpath $(DESTDIR) -o $@ $(addprefix $(BUILDDIR)/,$(c-objs))
@if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mlinking : \033[34m$< -> $@\033[0m"; \
+ echo -e "\r\033[0mlinking -> \033[34m$@\033[0m"; \
fi
-install: all
+
+clean:
+ rm -rf $(BUILDDIR)
+ rm -f $(bcop-target-src)
+ rm -f $(bcop-target-hdr)
+
+install: $(DESTDIR) all
@if [ '$(color)' != 'no' ]; then \
echo -n -e "\033[0;1;5minstall \033[0;1;37m: \033[0;31m$(DESTDIR)/lib$(PLUGIN).so\033[0m"; \
else \
@@ -99,66 +173,11 @@ install: all
echo "install : $(XMLDIR)/$(PLUGIN).xml"; \
fi; \
mkdir -p $(XMLDIR); \
- cp $(PLUGIN).xml $(XMLDIR)/$(PLUGIN).xml; \
+ $(INSTALL) $(PLUGIN).xml $(XMLDIR)/$(PLUGIN).xml; \
if [ '$(color)' != 'no' ]; then \
echo -e "\r\033[0minstall : \033[34m$(XMLDIR)/$(PLUGIN).xml\033[0m"; \
fi; \
fi
-
-clean:
- rm -rf $(BUILDDIR)
-
-$(BUILDDIR)/%.vert: %.vcg
- @if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5mcompiling \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
- else \
- echo "compiling : $< -> $@"; \
- fi
- @$(CGC) -unroll all -quiet -fastmath -fastprecision -profile arbvp1 -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
-
-$(BUILDDIR)/%.frag: %.fcg
- @if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5mcompiling \033[0;1;37m: \033[0;32m$< \033[0;1;37m-> \033[0;31m$@\033[0m"; \
- else \
- echo "compiling : $< -> $@"; \
- fi
- @$(CGC) -unroll all -quiet -fastmath -fastprecision -profile arbfp1 -o $@ $<
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mcompiling : \033[34m$< -> $@\033[0m"; \
- fi
+
-$(PLUGIN)_shader.h: $(shaders)
- @if [ '$(color)' != 'no' ]; then \
- echo -n -e "\033[0;1;5mcreating \033[0;1;37m: \033[0;31m$@\033[0m"; \
- else \
- echo "creating : $@"; \
- fi
- @echo "/**" > $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " *" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " * This file is autogenerated from :" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " * $(shader_files)" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " *" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " * This program is distributed in the hope that it will be useful," >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " * but WITHOUT ANY WARRANTY; without even the implied warranty of" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " * GNU General Public License for more details." >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " *" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo " **/" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo "#ifndef $(PLUGIN)_SHADER_H" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo "#define $(PLUGIN)_SHADER_H" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @for i in $(shaders); do \
- echo >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp; \
- echo "static const char* `basename $$i | sed -s 's/\..*$$//'` = ">> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp; \
- cat $$i | grep -v "^#" | sed -e 's/^/\t"/' | sed -e 's/$$/\\n"/' >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp; \
- echo ";" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp; \
- done
- @echo >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @echo "#endif" >> $(BUILDDIR)/$(PLUGIN)_shader.h.tmp
- @cp $(BUILDDIR)/$(PLUGIN)_shader.h.tmp $(PLUGIN)_shader.h
- @if [ '$(color)' != 'no' ]; then \
- echo -e "\r\033[0mcreating : \033[34m$@\033[0m"; \
- fi