### -*-makefile-*- ################################################# ## Makefile.common ## ## standard targets and rules #################################################################### # 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 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 += -pg ifdef GNOME_CONFIG_BIN GNOME_CFLAGS += $(shell ${GNOME_CONFIG_BIN} --cflags gnomeui) endif QT_FLAGS := %.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) ""