Introduce clean2 target.
[paraslash.git] / Makefile.in
index d8b82e60d61b6c9bcc66dd9d539811505573e411..d71c0c9a2c8b34cd7cb4750b1d6f213970ce8789 100644 (file)
@@ -8,6 +8,7 @@ MANDIR := @datarootdir@/man/man1
 PACKAGE_VERSION := @PACKAGE_VERSION@
 PACKAGE_STRING := @PACKAGE_STRING@
 install_sh := @install_sh@
+cmdline_dir := @cmdline_dir@
 
 build_date := $(shell date)
 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
@@ -56,6 +57,7 @@ CPPFLAGS += @SSL_CPPFLAGS@
 CPPFLAGS += @ncurses_cppflags@
 CPPFLAGS += @arch_cppflags@
 CPPFLAGS += -I/usr/local/include
+CPPFLAGS += -I$(cmdline_dir)
 CPPFLAGS += @osl_cppflags@
 
 BINARIES = para_server para_client para_audioc para_recv \
@@ -65,42 +67,43 @@ man_pages := $(patsubst %, man/man1/%.1, $(man_binaries))
 man_pages_in := $(patsubst %, web/%.man.in.html, $(man_binaries))
 
 ggo_dir := ggo
+object_dir := objects
 
 m4_ggos := afh audioc audiod client filter gui recv server write
 all_ggos := $(m4_ggos) dccp_recv oggdec_filter alsa_write oss_write fade http_recv \
        osx_write udp_recv amp_filter compress_filter file_write \
-       mp3dec_filter
-ggo_generated := $(addsuffix .cmdline.c, $(all_ggos)) $(addsuffix .cmdline.h, $(all_ggos)) \
-       $(addsuffix .ggo, $(addprefix $(ggo_dir)/,$(m4_ggos)))
+       mp3dec_filter prebuffer_filter
+ggo_generated := $(addsuffix .ggo, $(addprefix $(ggo_dir)/,$(m4_ggos)))
+cmdline_generated := $(addprefix $(cmdline_dir)/,$(addsuffix .cmdline.c, $(all_ggos)) \
+       $(addsuffix .cmdline.h, $(all_ggos)))
 
 autocrap := config.h.in configure
 tarball_pfx := @PACKAGE_TARNAME@-$(PACKAGE_VERSION)
-tarball_delete = web versions pics .changelog_before_cvs .changelog_cvs .gitignore
-tarball_delete := $(patsubst %,$(tarball_pfx)/%,$(tarball_delete))
-tarball_add := $(ggo_generated) $(autocrap)
+tarball_delete := $(addprefix $(tarball_pfx)/,\
+       web versions .changelog_before_cvs .changelog_cvs .gitignore\
+       $(ggo_dir) skencil)
 tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2
 
-.PHONY: clean distclean maintainer-clean install man tarball
+.PHONY: all clean distclean maintainer-clean install man tarball
 all: $(BINARIES) $(man_pages)
 man: $(man_pages)
 tarball: $(tarball)
 
-*.o: para.h config.h gcc-compat.h
+-include $(ggo_dir)/makefile
 
-include Makefile.deps
-include $(ggo_dir)/makefile
-
-%_command_list.c %_command_list.h: %.cmd
+%_command_list.c: %.cmd
        ./command_util.sh c < $< >$@
-       ./command_util.sh h < $< >$(@:%.c=%.h)
-
+%_command_list.h: %.cmd
+       ./command_util.sh h < $< >$@
 %_command_list.man: %.cmd
        ./command_util.sh man < $< > $@
 
-server_command_lists = server_command_list.man afs_command_list.man
-man/man1/para_server.1: para_server $(server_command_lists)
+server_command_lists_ch = server_command_list.c afs_command_list.c \
+       server_command_list.h afs_command_list.h
+server_command_lists_man = server_command_list.man afs_command_list.man
+man/man1/para_server.1: para_server $(server_command_lists_man)
        mkdir -p man/man1
-       opts="-h --detailed-help -N `for i in $(server_command_lists); do printf "%s\n" "-i $$i"; done`"; \
+       opts="-h --detailed-help -N `for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
        help2man $$opts ./para_server > $@
 
 man/man1/para_audiod.1: para_audiod audiod_command_list.man
@@ -118,74 +121,103 @@ man/html/%.html: man/man1/%.1
 web/%.man.in.html: man/man1/%.1
        man2html $< | sed -e '/^<\/BODY>/,$$d' -e '1,/<\/HEAD><BODY>/d' > $@
 
+$(object_dir):
+       mkdir -p $@
+
+$(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
+       $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @oggvorbis_cppflags@ $<
+
+$(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
+       $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @oggvorbis_cppflags@ $<
 
-oggdec_filter.o: oggdec_filter.c
-       $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @oggvorbis_cppflags@ $<
-ogg_afh.o: ogg_afh.c
-       $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @oggvorbis_cppflags@ $<
+$(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
+       $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
 
-mp3dec_filter.o: mp3dec_filter.c
-       $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
+$(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
+       $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
 
-aacdec_filter.o: aacdec_filter.c
-       $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
+$(object_dir)/aac_common.o: aac_common.c | $(object_dir)
+       $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
 
-aac_common.o: aac_common.c
-       $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
+$(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
+       $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
 
-aac_afh.o: aac_afh.c
-       $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
+$(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
+       $(CC) -c $(CPPFLAGS) -o $@ $<
 
-%.cmdline.o: %.cmdline.c
-       $(CC) -c $(CPPFLAGS) $<
+$(object_dir)/%.o: %.c | $(object_dir)
+       $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
 
-%.o: %.c
-       $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
+# We depend on the *.cmdline.[ch] files as these must be present for depend.sh
+# to work. The first dependency is explititly given as it is used by $<.
+$(object_dir)/%.cmdline.d: %.cmdline.c $(cmdline_generated) | $(object_dir)
+       ./depend.sh $(object_dir) $(CPPFLAGS) $< > $@
+$(object_dir)/%.d: %.c $(cmdline_generated) | $(object_dir)
+       ./depend.sh  $(object_dir) $(CPPFLAGS) $< > $@
 
-para_recv: @recv_objs@
-       $(CC) $(LDFLAGS) @recv_objs@ -o $@ @recv_ldflags@
+recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
+filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
+client_objs := $(addprefix $(object_dir)/, @client_objs@)
+gui_objs := $(addprefix $(object_dir)/, @gui_objs@)
+audiod_objs := $(addprefix $(object_dir)/, @audiod_objs@)
+audioc_objs := $(addprefix $(object_dir)/, @audioc_objs@)
+fade_objs := $(addprefix $(object_dir)/, @fade_objs@)
+server_objs := $(addprefix $(object_dir)/, @server_objs@)
+write_objs := $(addprefix $(object_dir)/, @write_objs@)
+afh_objs := $(addprefix $(object_dir)/, @afh_objs@)
 
-para_filter: @filter_objs@
-       $(CC) $(LDFLAGS) @filter_objs@ -o $@ @filter_ldflags@
+all_objs := $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
+       $(audiod_objs ) $(audioc_objs) $(fade_objs) $(server_objs) \
+       $(write_objs) $(afh_objs)
+-include $(all_objs:.o=.d)
 
-para_client: @client_objs@
-       $(CC) $(LDFLAGS) -o $@ @client_objs@ @client_ldflags@
+para_recv: $(recv_objs)
+       $(CC) $(LDFLAGS) $(recv_objs) -o $@ @recv_ldflags@
 
-para_gui: @gui_objs@
-       $(CC) $(LDFLAGS) -o $@ @gui_objs@ -lncurses
+para_filter: $(filter_objs)
+       $(CC) $(LDFLAGS) $(filter_objs) -o $@ @filter_ldflags@
 
-para_audiod: @audiod_objs@
-       $(CC) $(LDFLAGS) -o $@ @audiod_objs@ @audiod_ldflags@
+para_client: $(client_objs)
+       $(CC) $(LDFLAGS) -o $@ $(client_objs) @client_ldflags@
 
-para_audioc: @audioc_objs@
-       $(CC) $(LDFLAGS) -o $@ @audioc_objs@ @audioc_ldflags@
+para_gui: $(gui_objs)
+       $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lncurses
 
-para_fade: @fade_objs@
-       $(CC) $(LDFLAGS) -o $@ @fade_objs@ @fade_ldflags@
+para_audiod: audiod_command_list.c audiod_command_list.h $(audiod_objs)
+       $(CC) $(LDFLAGS) -o $@ $(audiod_objs) @audiod_ldflags@
 
-para_server: @server_objs@
-       $(CC) $(LDFLAGS) -o $@ @server_objs@  @server_ldflags@
+para_audioc: $(audioc_objs)
+       $(CC) $(LDFLAGS) -o $@ $(audioc_objs) @audioc_ldflags@
 
-para_write: @write_objs@
-       $(CC) $(LDFLAGS) -o $@ @write_objs@ @write_ldflags@
+para_fade: $(fade_objs)
+       $(CC) $(LDFLAGS) -o $@ $(fade_objs) @fade_ldflags@
 
-para_afh: @afh_objs@
-       $(CC) $(LDFLAGS) -o $@ @afh_objs@ @afh_ldflags@
+para_server: $(server_command_lists_ch) $(server_objs)
+       $(CC) $(LDFLAGS) -o $@ $(server_objs)  @server_ldflags@
+
+para_write: $(write_objs)
+       $(CC) $(LDFLAGS) -o $@ $(write_objs) @write_ldflags@
+
+para_afh: $(afh_objs)
+       $(CC) $(LDFLAGS) -o $@ $(afh_objs) @afh_ldflags@
 
 clean:
-       rm -f *.o $(BINARIES)
+       rm -f $(BINARIES) $(object_dir)/*.o
+
+clean2: clean
+       rm -rf man $(object_dir)
        rm -f *_command_list.*
-       rm -rf man
-distclean: clean
+
+distclean: clean2
        rm -f Makefile autoscan.log config.status config.log && \
-       rm -rf web/sync/* autom4te.cache aclocal.m4
+       rm -rf autom4te.cache aclocal.m4
        rm -f GPATH GRTAGS GSYMS GTAGS
 
 maintainer-clean: distclean
        rm -f $(ggo_generated) *.tar.bz2 \
                config.h configure \
                config.h.in skencil/*.pdf skencil/*.ps
-       rm -rf web_sync
+       rm -rf web_sync $(cmdline_dir)
 
 install: all man
        mkdir -p $(BINDIR) $(MANDIR)
@@ -193,12 +225,13 @@ install: all man
        $(install_sh) -m 644 $(man_pages) $(MANDIR)
        mkdir -p $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
 
-@PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2: $(tarball_add)
+$(tarball): $(cmdline_generated)
        rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
        git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
                | tar --delete $(tarball_delete) > $(tarball_pfx).tar
-       mkdir $(tarball_pfx)
-       cp -r $(tarball_add) $(tarball_pfx)
+       mkdir -p $(tarball_pfx)/$(cmdline_dir)
+       cp -r $(autocrap) $(tarball_pfx)
+       cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
        tar rf $(tarball_pfx).tar $(tarball_pfx)/*
        rm -rf $(tarball_pfx)
        bzip2 -9 $(tarball_pfx).tar