AUTOMAKE_OPTIONS = foreign 1.4 no-dependencies libexec_PROGRAMS = detect-upc detect_upc_SOURCES = detect-upc.c detect-upc.h $(SCANNER_SRC) libexec_SCRIPTS = upcppp if CROSS_COMPILING # Use HOST_CC for this program when cross-compiling, because it must run on the host CFLAGS_STAMP=$(top_builddir)/detect-upc/.set-cflags $(CFLAGS_STAMP): $(srcdir)/Makefile.in cd $(top_builddir) && CONFIG_HEADERS= CONFIG_FILES=detect-upc/Makefile ./config.status mv Makefile Makefile.bak && \ @PERL@ -p -e 's|^\s*CFLAGS\s*=.*$$|CFLAGS=@HOST_CFLAGS@| ; \ s|^\s*CC\s*=.*$$|CC=@HOST_CC@| ; \ s|^\s*UPCR_EXTRA_CFLAGS\s*=.*$$|UPCR_EXTRA_CFLAGS=| ; \ s|^\s*LDFLAGS\s*=.*$$|LDFLAGS=@HOST_LDFLAGS@| ; \ s|^\s*LIBS\s*=.*$$|LIBS=@HOST_LIBS@| ; ' \ Makefile.bak >Makefile && \ rm -f Makefile.bak touch $(CFLAGS_STAMP) Makefile: $(CFLAGS_STAMP) touch Makefile endif UPCR_EXTRA_CFLAGS = @UPCR_EXTRA_CFLAGS@ if BUILDCONFIG_DEBUG detect_upc_CFLAGS = -DDEBUG $(UPCR_EXTRA_CFLAGS) else detect_upc_CFLAGS = -DNDEBUG $(UPCR_EXTRA_CFLAGS) endif # Required by Automake 1.4 AM_CFLAGS = $(detect_upc_CFLAGS) # A scanner.c generated by a vendor-lex may require their specific lib # Though our flex-generated scanner.c is stand-alone, an extra -l is harmless detect_upc_LDADD = $(LEXLIB) # Install .pl in libexecdir, but w/o exec permissions dotpldir = $(libexecdir) dotpl_DATA = upcppp.pl if UPCR_USE_LEX # We are using a LEX # Let automake do its normal thing to build. # However, we also add the scanner.c to the files to clean. SCANNER_SRC = scanner.l scanner_clean = scanner.c if UPCR_HAVE_FLEX # Since we know this is flex we can pass args to tune AM_LFLAGS = -8 -Cfe endif # automake-1.4-p5 doesn't DIST files from the build dir unless in cygnus mode scanner_dist_hook: scanner.c @test -f '$(distdir)/scanner.c' || cp -p scanner.c '$(distdir)'/ else # We are NOT using a LEX and must rely on the prebuilt scanner.c # Always use the prebuilt scanner.c. # Never delete from srcdir, but may copy to blddir if necessary. # If out-of-date, issue warning at build and refuse to distribute. SCANNER_SRC = scanner.c all-local: force @if test -f '$(srcdir)/scanner.c' -a \ -n "`find '$(srcdir)/scanner.l' -newer '$(srcdir)/scanner.c' 2>&1`"; then \ echo '**** WARNING: scanner.c might be out-of-date but cannot be rebuilt without a lex ****' >&2; \ fi scanner_dist_hook: force @if test -f '$(srcdir)/scanner.c' -a \ -n "`find '$(srcdir)/scanner.l' -newer '$(srcdir)/scanner.c' 2>&1`"; then \ echo '**** WARNING: scanner.c might be out-of-date but cannot be rebuilt without a lex ****' >&2; \ echo '**** ERROR: refusing to distribute potentially out-of-date scanner.c ****' >&2; \ exit 1; \ fi scanner.c: scanner.l @if test -f '$(srcdir)/scanner.c'; then :; else \ echo '**** ERROR: missing source file scanner.c cannot be built without a lex ****' >&2; \ exit 1; \ fi; \ $(scanner_cp) if BUILD_IS_SRC scanner_cp = : scanner_clean = else scanner_cp = cp '$(srcdir)/scanner.c' . scanner_clean = scanner.c endif endif # upcppp upcppp: $(top_builddir)/gasnet/other/perlstart # Things to copy from srcdir to buildir when they differ if BUILD_IS_SRC files_we_copy = else files_we_copy = $(dotpl_DATA) $(files_we_copy): force @srcfile="$(srcdir)/`basename $@`" ; \ if test ! -f "$@" -o "`find $$srcfile -newer '$@' 2>&1`" ; then \ echo cp -f "$$srcfile" . ; \ cp -f "$$srcfile" . ; \ fi endif # Things to conditionally clean CLEANFILES = $(scanner_clean) $(CFLAGS_STAMP) DISTCLEANFILES = $(files_we_copy) # Make sure scanner.c is flex-generated and newer than scanner.l so user won't need lex dist-hook: @$(MAKE) scanner_dist_hook @if test -d $(top_srcdir)/.git && \ (cd $(srcdir) && \ test `git log -n1 --format='%ct' -- scanner.c` -lt \ `git log -n1 --format='%ct' -- scanner.l`); then \ echo '**** ERROR: scanner.c appears to be older than scanner.l ****' >&2; \ echo '**** ERROR: refusing to distribute potentially out-of-date scanner.c ****' >&2; \ exit 1; \ elif \! grep yy_flex '$(distdir)/scanner.c' >/dev/null 2>&1; then \ echo '**** ERROR: scanner.c does not appear to have been generated by flex ****' >&2; \ echo '**** ERROR: refusing to distribute potentially non-portable scanner.c ****' >&2; \ exit 1; \ else \ sleep 10; \ touch '$(distdir)/scanner.c'; \ fi # Make certain we distribute the same files regardless of using LEX or not EXTRA_DIST = scanner.c scanner.l $(dotpl_DATA) .PHONY: force scanner_dist_hook