gnucash/Makefile.common

131 lines
4.5 KiB
Makefile
Raw Normal View History

# Makefile.common -- standard targets and rules
# Copyright (C) 2000 Linas Vepstas
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# 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, contact:
#
# Free Software Foundation Voice: +1-617-542-5942
# 59 Temple Place - Suite 330 Fax: +1-617-542-2652
# Boston, MA 02111-1307, USA gnu@gnu.org
# Autoconf notes...
# Need to handle -MD there.
# COMMON_SRCS: have to be compiled separately for all flavors
# MOTIF_SRCS: are motif only sources
# GNOME_SRCS: are gnome only sources
# INDEP_SRCS: are for flavor independent sources (like engine)
# OBJS is for flavor independent files
# GNOME/MOTIF_OBJS is for flavor dependent files
# Clear all of the default suffix rules. They were causing a great
# deal of agony when trying to get the .tmpl rules to work. In
# general, we want to take charge of these for now.
.SUFFIXES:
OBJS := $(addprefix obj/,${INDEP_SRCS:.c=.o})
GNOME_OBJS := $(addprefix obj/gnome/,${COMMON_SRCS:.c=.o})
GNOME_OBJS += $(addprefix obj/gnome/,${GNOME_SRCS:.c=.o})
MOTIF_OBJS := $(addprefix obj/motif/,${COMMON_SRCS:.c=.o})
MOTIF_OBJS += $(addprefix obj/motif/,${MOTIF_SRCS:.c=.o})
QT_OBJS := $(addprefix obj/qt/,${COMMON_SRCS:.c=.o})
QT_OBJS += $(addprefix obj/qt/,${QT_SRCS:.cpp=.o})
CFLAGS += ${DEFS}
ifdef GNOME_CONFIG_BIN
GNOME_CFLAGS += $(shell ${GNOME_CONFIG_BIN} --cflags gnomeui)
endif
ifdef GLIB_CONFIG_BIN
GLIB_CFLAGS := $(shell ${GLIB_CONFIG_BIN} --cflags)
GLIB_LIBS := $(shell ${GLIB_CONFIG_BIN} --libs)
endif
QT_FLAGS :=
# All c files depend on headers with the same names.
%.c : %.h
# Basically take the output foo.d file and put it in the right
# subdirectory, adding a prefix indicating where the file actually
# lives (i.e. obj-pic/Foo.cc rather than Foo.cc. This would all be
# unnecessary if gcc actually paid attention to the argument to "-o".
# Note that this cannot handle subdirs in the Makefile dir, so if the
# relevant Makefile was src/foo/Makefile, this rule can't handle
# src/foo/bar/x.c src/foo/x.c and src/foo/bax/x.c. You'd need another
# Makefile in src/foo/bar and src/foo/bax for now.
define cleanupdeps
sed -e "1 s|$(basename $<)\.o|$@|1" $(basename $@).d.tmp > $(basename $@).d
rm $(basename $@).d.tmp
endef
# Default rule used for non-flavor dependent files (i.e. all of register)
obj/%.o: %.c
@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
$(CC) -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) -o $@ $<
${cleanupdeps}
obj/%.o: %.cpp
@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
g++ -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) -o $@ $<
${cleanupdeps}
obj/motif/%.o: %.c
@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
$(CC) -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) ${MOTIF_CFLAGS} -DMOTIF -o $@ $<
${cleanupdeps}
obj/gnome/%.o: %.c
@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
$(CC) -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) ${GNOME_CFLAGS} -DGNOME -o $@ $<
${cleanupdeps}
obj/qt/%.o: %.cpp
@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
g++ -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) ${QT_CFLAGS} -DKDE -o $@ $<
${cleanupdeps}
obj/qt/%.o: %.c
@if [ ! -e $(dir $@) ]; then mkdir -p $(dir $@); fi
$(CC) -Wp,-MD,$(basename $@).d.tmp -c $(CFLAGS) ${QT_CFLAGS} -DKDE -o $@ $<
${cleanupdeps}
clean-files:
rm -f *~ *.bak \#*
rm -rf obj
-rm -rf ${TRASH}
clean: clean-files
$(foreach dir,${CLEAN_SUBDIRS},(cd ${dir} && $(MAKE) clean);)
distclean: clean-files
$(foreach dir,${CLEAN_SUBDIRS},(cd ${dir} && $(MAKE) distclean);)
rm -f Makefile.bak
rm -f $(foreach f,$(wildcard *.in),$(filter-out configure,$(f:.in=)))
-rm -rf ${DIST_TRASH}
dist:
$(foreach dir,${CLEAN_SUBDIRS},(cd ${dir} && $(MAKE) dist);)
.PHONY: clean clean-files dist distclean
# Get dependencies (if existent).
-include $(shell if [ -e obj ]; then find obj -name "*.d"; fi) ""