# $Id$ # # common rules for compilation. # # Variables: # # srcdir ... source directory. # top_srcdir ... optionally, top source directory. # CC ... path of GNU C compiler # CXX ... path of GNU C++ compiler # PKGCONFIG ... path of the pkg-config tool. # WINDRES ... windows resource compiler, if $(ARTIFACT).rc is to be compiled in. # MOC ... The path of the Qt moc binary. If empty, no moc processing will be undertaken. # MOCHEADERS... optional list of Qt header files to preproces using moc. # MOCFLAGS..... Flags to pass to Qt moc. # UIC ... The path of the uic-qt3 binary. # UIC4 ... The path of the uic-qt4 binary. # UICFILES ... list of header files to preproces using uic. # BUILDDATESOURCES... list of source files to preprocess with __VERSION__ and __BUILD_DATE__ # BISON ... The path of the bison binary. If empty, no bison processing will be undertaken # BISONFLAGS... Flags to pass to bison. # YSOURCES ... list of *.y files to be processed by bison # FLEX ... The path of the fley binary. If empty, no flex processing will be undertaken # FLEXFLAGS ... Flags to pass to flex. # LSOURCES ... list of *.l files to be processed by flex # EXTPKGS ... list of external pkg-config packages. # HEADERS ... list of header files to install. # HEADERDIR ... subdirectory of $(prefix)/include where to install headers. # SOURCES ... list of source packages to compile. # INCLUDES ... list of optional include directories # CFLAGS ... C options like -Wall -g -O2 # CXXFLAGS ... C++ options like -Wall -g -O2 # BUILDTYPE ... lib,so,dll,exe,bin # ARTIFACT ... The name of the build artifact # ABI_VERSION ... Version of the ABI for shared libraries, used to preprocess windows resources. # NODEVRULES ... If non-empty don't generate install-dev rules. # # SPECIALCOMPILEMK ... project specific special-foo.mk to include ifeq ($(VERSION),) VERSION=$(shell /usr/share/pba-cbs/sh/get_deb_version.sh $(srcdir) $(top_srcdir)) endif OBJS:=$(addsuffix .o,$(basename $(SOURCES))) DEPENDS:=$(addsuffix .d,$(basename $(SOURCES))) ifneq ($(HEADERS),) ABSHEADERS=$(addprefix $(srcdir)/,$(HEADERS)) endif ifeq ($(HEADERDIR),) HEADERDESTDIR=$(DESTDIR)$(prefix)/include else HEADERDESTDIR=$(DESTDIR)$(prefix)/include/$(HEADERDIR) endif ifeq ($(BUILDTYPE),dll) ABI_CFLAGS=-DBUILD_$(subst -,_,$(ARTIFACT))_DLL else ifeq ($(BUILDTYPE),so) ABI_CFLAGS=-fPIC else ABI_CFLAGS= endif ifeq ($(EXTPKGS),) EXT_CFLAGS= else EXT_CFLAGS=$(shell $(PKGCONFIG) --cflags $(EXTPKGS)) endif ifneq ($(WINDRES),) ifeq ($(BUILDTYPE),dll) include /usr/share/pba-cbs/mk/special-compile-windres.mk else ifeq ($(BUILDTYPE),exe) include /usr/share/pba-cbs/mk/special-compile-windres.mk endif endif ifneq ($(UIC),) include /usr/share/pba-cbs/mk/special-compile-uic-qt3.mk endif ifneq ($(UIC4),) include /usr/share/pba-cbs/mk/special-compile-uic-qt4.mk endif ifneq ($(MOC),) include /usr/share/pba-cbs/mk/special-compile-moc.mk endif ifneq ($(BISON),) include /usr/share/pba-cbs/mk/special-compile-bison.mk endif ifneq ($(FLEX),) include /usr/share/pba-cbs/mk/special-compile-flex.mk endif ifneq ($(BUILDDATESOURCES),) include /usr/share/pba-cbs/mk/special-compile-builddate.mk endif ifneq ($(SPECIALCOMPILEMK),) include $(SPECIALCOMPILEMK) endif %.o %.d: $(srcdir)/%.c $(CC) $(ABI_CFLAGS) $(CFLAGS) $(EXT_CFLAGS) $(INCLUDES) -MMD -MT '$*.d $*.o' -c $< -o $*.o %.o %.d: $(srcdir)/%.cpp $(CXX) $(ABI_CFLAGS) $(CXXFLAGS) $(EXT_CFLAGS) $(INCLUDES) -MMD -MT '$*.d $*.o' -c $< -o $*.o %.o %.d: $(srcdir)/%.cc $(CXX) $(ABI_CFLAGS) $(CXXFLAGS) $(EXT_CFLAGS) $(INCLUDES) -MMD -MT '$*.d $*.o' -c $< -o $*.o compile:: $(OBJS) clean:: rm -f $(OBJS) $(DEPENDS) ifneq ($(HEADERS),) ifeq ($(NODEVRULES),) install-dev:: $(ABSHEADERS) mkdir -p $(HEADERDESTDIR) install -m 644 -p $(ABSHEADERS) $(HEADERDESTDIR) endif endif ifneq ($(MAKECMDGOALS),clean) include $(DEPENDS) endif