diff options
author | kraxel <kraxel> | 2004-04-21 11:55:44 +0000 |
---|---|---|
committer | kraxel <kraxel> | 2004-04-21 11:55:44 +0000 |
commit | c4d7dacb41039e087d20b8889a4d13bd4c9928f2 (patch) | |
tree | 0aef1f53f2e8cd55c4db8915d9d9a1265dd97adc /mk | |
download | input-c4d7dacb41039e087d20b8889a4d13bd4c9928f2.tar.gz |
Initial revision
Diffstat (limited to 'mk')
-rw-r--r-- | mk/Autoconf.mk | 124 | ||||
-rw-r--r-- | mk/Compile.mk | 84 | ||||
-rw-r--r-- | mk/Maintainer.mk | 47 | ||||
-rw-r--r-- | mk/Variables.mk | 33 |
4 files changed, 288 insertions, 0 deletions
diff --git a/mk/Autoconf.mk b/mk/Autoconf.mk new file mode 100644 index 0000000..646e47b --- /dev/null +++ b/mk/Autoconf.mk @@ -0,0 +1,124 @@ +# +# simple autoconf system for GNU make +# +# (c) 2002,2003 Gerd Knorr <kraxel@bytesex.org> +# +# credits for creating this one go to the autotools people because +# they managed it to annoy lots of developers and users (including +# me) with version incompatibilities. +# +# This file is public domain. No warranty. If it breaks you keep +# both pieces. +# +######################################################################## + +# verbose yes/no +verbose ?= no + +# some stuff used by the tests +ifneq ($(verbose),no) + # verbose (for debug) + ac_init = echo "checking $(1) ... " >&2; rc=no + ac_b_cmd = echo "run: $(1)" >&2; $(1) >/dev/null && rc=yes + ac_s_cmd = echo "run: $(1)" >&2; rc=`$(1)` + ac_fini = echo "... result is $${rc}" >&2; echo >&2; echo "$${rc}" +else + # normal + ac_init = echo -ne "checking $(1) ... " >&2; rc=no + ac_b_cmd = $(1) >/dev/null 2>&1 && rc=yes + ac_s_cmd = rc=`$(1) 2>/dev/null` + ac_fini = echo "$${rc}" >&2; echo "$${rc}" +endif + +# some helpers to build cflags and related variables +ac_def_cflags_1 = $(if $(filter yes,$($(1))),-D$(1)) +ac_lib_cflags = $(foreach lib,$(1),$(call ac_def_cflags_1,HAVE_LIB$(lib))) +ac_inc_cflags = $(foreach inc,$(1),$(call ac_def_cflags_1,HAVE_$(inc))) +ac_lib_mkvar_1 = $(if $(filter yes,$(HAVE_LIB$(1))),$($(1)_$(2))) +ac_lib_mkvar = $(foreach lib,$(1),$(call ac_lib_mkvar_1,$(lib),$(2))) + + +######################################################################## +# the tests ... + +# get uname +ac_uname = $(shell \ + $(call ac_init,for system);\ + $(call ac_s_cmd,uname -s | tr 'A-Z' 'a-z');\ + $(call ac_fini)) + +# check for some header file +ac_header = $(shell \ + $(call ac_init,for $(1));\ + $(call ac_b_cmd,echo '\#include <$(1)>' |\ + $(CC) $(CFLAGS) -E -);\ + $(call ac_fini)) + +# check for some library +ac_lib = $(shell \ + $(call ac_init,for $(1) in $(2));\ + echo 'void $(1)(void); int main(void) {$(1)();return 0;}' \ + > __actest.c;\ + $(call ac_b_cmd,$(CC) $(CFLAGS) $(LDFLAGS) -o \ + __actest __actest.c -l$(2) $(3));\ + rm -f __actest __actest.c;\ + $(call ac_fini)) + +# check if some compiler flag works +ac_cflag = $(shell \ + $(call ac_init,if $(CC) supports $(1));\ + echo 'int main() {return 0;}' > __actest.c;\ + $(call ac_b_cmd,$(CC) $(CFLAGS) $(1) $(LDFLAGS) -o \ + __actest __actest.c);\ + rm -f __actest __actest.c;\ + $(call ac_fini)) + +# check for some binary +ac_binary = $(shell \ + $(call ac_init,for $(1));\ + $(call ac_s_cmd,which $(1));\ + bin="$$rc";rc="no";\ + $(call ac_b_cmd,test -x "$$$$bin");\ + $(call ac_fini)) + +# check if lib64 is used +ac_lib64 = $(shell \ + $(call ac_init,for libdir name);\ + $(call ac_s_cmd,$(CC) -print-search-dirs | grep -q lib64 &&\ + echo "lib64" || echo "lib");\ + $(call ac_fini)) + +# check for x11 ressource dir prefix +ac_resdir = $(shell \ + $(call ac_init,for X11 app-defaults prefix);\ + $(call ac_s_cmd, test -d /etc/X11/app-defaults &&\ + echo "/etc/X11" || echo "/usr/X11R6/lib/X11");\ + $(call ac_fini)) + + +######################################################################## +# build Make.config + +define newline + + +endef +make-config-q = $(subst $(newline),\n,$(make-config)) + +ifeq ($(filter config,$(MAKECMDGOALS)),config) +.PHONY: Make.config + LIB := $(call ac_lib64) +else + LIB ?= $(call ac_lib64) + LIB := $(LIB) +endif +.PHONY: config +config: Make.config + @true + +Make.config: GNUmakefile + @echo -e "$(make-config-q)" > $@ + @echo + @echo "Make.config written, edit if needed" + @echo + diff --git a/mk/Compile.mk b/mk/Compile.mk new file mode 100644 index 0000000..75dadde --- /dev/null +++ b/mk/Compile.mk @@ -0,0 +1,84 @@ +# +# some rules to compile stuff ... +# +# (c) 2002 Gerd Knorr <kraxel@bytesex.org> +# +# main features: +# * autodependencies via "cpp -MD" +# * fancy, non-verbose output +# +# This file is public domain. No warranty. If it breaks you keep +# both pieces. +# +######################################################################## + +# verbose yes/no +verbose ?= no + +# dependency files +tmpdep = mk/$(subst /,_,$*).tmp +depfile = mk/$(subst /,_,$*).dep +depfiles = mk/*.dep + +compile_c = $(CC) $(CFLAGS) -Wp,-MD,$(tmpdep) -c -o $@ $< +compile_cc = $(CXX) $(CXXFLAGS) -Wp,-MD,$(tmpdep) -c -o $@ $< +fixup_deps = sed -e "s|.*\.o:|$@:|" < $(tmpdep) > $(depfile) && rm -f $(tmpdep) + +link_app = $(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS) +link_so = $(CC) $(LDFLAGS) -shared -Wl,-soname,$(@F) -o $@ $^ $(LDLIBS) +ar_lib = rm -f $@ && ar -r $@ $^ && ranlib $@ + +moc_h = $(MOC) $< -o $@ +msgfmt_po = msgfmt -o $@ $< + +# non-verbose output +ifeq ($(verbose),no) + echo_compile_c = echo " CC " $@ + echo_compile_cc = echo " CXX " $@ + echo_link_app = echo " LD " $@ + echo_link_so = echo " LD " $@ + echo_ar_lib = echo " AR " $@ + echo_moc_h = echo " MOC " $@ + echo_msgfmt_po = echo " MSGFMT " $@ +else + echo_compile_c = echo $(compile_c) + echo_compile_cc = echo $(compile_cc) + echo_link_app = echo $(link_app) + echo_link_so = echo $(link_so) + echo_ar_lib = echo $(ar_lib) + echo_moc_h = echo $(moc_h) + echo_msgfmt_po = echo $(msgfmt_po) +endif + +%.o: %.c + @$(echo_compile_c) + @$(compile_c) + @$(fixup_deps) + +%.o: %.cc + @$(echo_compile_cc) + @$(compile_cc) + @$(fixup_deps) + +%.o: %.cpp + @$(echo_compile_cc) + @$(compile_cc) + @$(fixup_deps) + + +%.so: %.o + @$(echo_link_so) + @$(link_so) + +%: %.o + @$(echo_link_app) + @$(link_app) + +%.moc : %.h + @$(echo_moc_h) + @$(moc_h) + +%.mo : %.po + @$(echo_msgfmt_po) + @$(msgfmt_po) + diff --git a/mk/Maintainer.mk b/mk/Maintainer.mk new file mode 100644 index 0000000..f5ff691 --- /dev/null +++ b/mk/Maintainer.mk @@ -0,0 +1,47 @@ +# just some maintainer stuff for me ... +######################################################################## + +make-sync-dir = $(HOME)/src/gnu-make +pbuilder-dir = /work/pbuilder/result +snapshot-dir = $(HOME)/snapshot +snapshot-date = $(shell date +%Y%m%d) +snapshot-name = $(snapshot-dir)/$(PACKAGE)-$(snapshot-date).tar.gz + +deb-version = $(shell dpkg-parsechangelog | sed -n 's/^Version: \(.*:\|\)//p') +deb-arch := $(shell uname -m | sed \ + -e 's/i.86/i386/' \ + -e 's/ppc/powerpc/') +deb-dsc := ../$(PACKAGE)_$(VERSION).dsc +deb-changes := $(pbuilder-dir)/$(PACKAGE)_$(VERSION)_$(deb-arch).changes + + +.PHONY: sync checkit release port tarball dist rpm +sync:: distclean + test -d $(make-sync-dir) + rm -f INSTALL mk/*.mk + cp -v $(make-sync-dir)/INSTALL . + cp -v $(make-sync-dir)/*.mk mk + chmod 444 INSTALL mk/*.mk + + +dsc source $(deb-dsc): clean + test "$(VERSION)" = "$(deb-version)" + dpkg-buildpackage -S -us -uc -rfakeroot + +debs pbuild $(deb-changes): $(deb-dsc) + sudo /usr/sbin/pbuilder build $(deb-dsc) + -lintian -i $(deb-changes) + +release: $(deb-changes) + debsign $(deb-changes) + + +tarball dist: realclean + (cd ..; tar czf $(TARBALL) $(DIR)) + +snapshot snap: realclean + (cd ..; tar czf $(snapshot-name) $(DIR)) + +rpm: tarball + rpm -ta ../$(TARBALL) + diff --git a/mk/Variables.mk b/mk/Variables.mk new file mode 100644 index 0000000..4449d81 --- /dev/null +++ b/mk/Variables.mk @@ -0,0 +1,33 @@ +# common variables ... +######################################################################## + +# package + version +empty := +space := $(empty) $(empty) +PWD := $(shell pwd) +DIR := $(patsubst $(dir $(PWD))%,%,$(PWD)) +PACKAGE := $(word 1,$(subst -,$(space),$(DIR))) +VERSION := $(word 2,$(subst -,$(space),$(DIR))) +TARBALL := $(PACKAGE)_$(VERSION).tar.gz + +# directories +DESTDIR = +prefix ?= /usr/local +bindir = $(DESTDIR)$(prefix)/bin +mandir = $(DESTDIR)$(prefix)/share/man +locdir = $(DESTDIR)$(prefix)/share/locale + +# programs +CC ?= gcc +CXX ?= g++ +MOC ?= $(if $(QTDIR),$(QTDIR)/bin/moc,moc) +INSTALL ?= install +INSTALL_BINARY := $(INSTALL) -s +INSTALL_SCRIPT := $(INSTALL) +INSTALL_DATA := $(INSTALL) -m 644 +INSTALL_DIR := $(INSTALL) -d + +# cflags +CFLAGS ?= -g -O2 +CFLAGS += -Wall -Wmissing-prototypes -Wstrict-prototypes \ + -Wpointer-arith -Wunused |