diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-08-18 13:00:03 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-08-18 20:14:37 +1000 |
commit | 1e61f2961e0f13ce077a85febe080e50bea3f59d (patch) | |
tree | 7b495c25339c7a9de25fa91a2d7c0e17db938c19 | |
parent | 6f288aab0c5797f844ee458dd98f30b1f3db62c6 (diff) | |
download | jimtcl-1e61f2961e0f13ce077a85febe080e50bea3f59d.zip jimtcl-1e61f2961e0f13ce077a85febe080e50bea3f59d.tar.gz jimtcl-1e61f2961e0f13ce077a85febe080e50bea3f59d.tar.bz2 |
Add support for BSD make
Use the new conditional template support in autosetup
to avoid (most) GNU-isms in the generated Makefile.
Signed-off-by: Steve Bennett <steveb@workware.net.au>
-rw-r--r-- | Makefile.in | 102 | ||||
-rw-r--r-- | auto.def | 18 | ||||
-rw-r--r-- | tests/Makefile | 3 |
3 files changed, 52 insertions, 71 deletions
diff --git a/Makefile.in b/Makefile.in index e8b545e..208e7ea 100644 --- a/Makefile.in +++ b/Makefile.in @@ -6,7 +6,6 @@ STRIP = @STRIP@ # Configuration -jim_libtype := @JIM_LIBTYPE@ SH_CFLAGS ?= @SH_CFLAGS@ SH_LDFLAGS ?= @SH_LDFLAGS@ SHOBJ_CFLAGS ?= @SHOBJ_CFLAGS@ @@ -16,55 +15,46 @@ LDFLAGS = @LDFLAGS@ LDLIBS += @LIBS@ exec_prefix ?= @exec_prefix@ prefix ?= @prefix@ -install_jim = @install_jim@ -CPPFLAGS += -D_GNU_SOURCE -Wall $(OPTIM) -I. -ifneq (@srcdir@,.) -CPPFLAGS += -I@srcdir@ +CC += -D_GNU_SOURCE -Wall $(OPTIM) -I. +@if srcdir != . +CFLAGS += -I@srcdir@ VPATH := @srcdir@ -endif +@endif -ifeq ($(jim_libtype),static) - LIBJIM := libjim.a -else - LIBJIM := libjim.so - SH_LIBJIM := $(LIBJIM) - CPPFLAGS += $(SH_CFLAGS) - DEF_LD_PATH := @LD_LIBRARY_PATH@=`pwd` -endif +@if JIM_STATICLIB +LIBJIM := libjim.a +@else +LIBJIM := libjim.so +SH_LIBJIM := $(LIBJIM) +CC += $(SH_CFLAGS) +DEF_LD_PATH := @LD_LIBRARY_PATH@=`pwd` +@endif -.EXPORT_ALL_VARIABLES: - -OBJS := _load-static-exts.o jim-subcmd.o jim-interactive.o jim-format.o jim.o utf8.o jimregexp.o @EXTRA_OBJS@ +OBJS := _load-static-exts.o jim-subcmd.o jim-interactive.o jim-format.o jim.o utf8.o jimregexp.o \ + @EXTRA_OBJS@ @C_EXT_OBJS@ @TCL_EXT_OBJS@ JIMSH := jimsh@EXEEXT@ -JIM_EXTENSIONS := @JIM_STATIC_C_EXTS@ @JIM_STATIC_TCL_EXTS@ -C_EXT_OBJS := $(patsubst %,jim-%.o,@JIM_STATIC_C_EXTS@) $(patsubst %,_jim-%.o,@JIM_STATIC_TCL_EXTS@) -C_EXT_SHOBJS := $(patsubst %,%.so,@JIM_MOD_EXTENSIONS@) -EXTENSION_TCL := $(patsubst %,%.tcl,@JIM_TCL_EXTENSIONS@) - -.PRECIOUS: jim-%.c - -all: $(JIMSH) $(C_EXT_SHOBJS) +all: $(JIMSH) @C_EXT_SHOBJS@ # Create C extensions from pure Tcl extensions -_jim-%.c: %.tcl - @tclsh@ @srcdir@/make-c-ext.tcl $< >$@ || ( rm $@; exit 1) - -_initjimsh.c: initjimsh.tcl - @tclsh@ @srcdir@/make-c-ext.tcl $< >$@ || ( rm $@; exit 1) +.SUFFIXES: .tcl +.tcl.o: + @tclsh@ @srcdir@/make-c-ext.tcl $< >_$*.c || ( rm _$*.c; exit 1) + $(CC) $(CFLAGS) -c -o $@ _$*.c || ( rm _$*.c; exit 1) + @rm -f _$*.c docs: Tcl.html -$(JIMSH): $(LIBJIM) jimsh.o _initjimsh.o - $(CC) $(CFLAGS) @SH_LINKFLAGS@ $(LDFLAGS) -o $@ jimsh.o _initjimsh.o $(LIBJIM) $(LDLIBS) +$(JIMSH): $(LIBJIM) jimsh.o initjimsh.o + $(CC) $(CFLAGS) @SH_LINKFLAGS@ $(LDFLAGS) -o $@ jimsh.o initjimsh.o $(LIBJIM) $(LDLIBS) -ifdef install_jim -install: all docs $(EXTENSION_TCL) install-exec +@if JIM_INSTALL +install: all docs @TCL_EXTS@ install-exec mkdir -p $(DESTDIR)$(prefix)/lib/jim cp $(LIBJIM) $(DESTDIR)$(prefix)/lib - cp @srcdir@/README.extensions $(C_EXT_SHOBJS) $(EXTENSION_TCL) $(DESTDIR)$(prefix)/lib/jim + cp @srcdir@/README.extensions @C_EXT_SHOBJS@ @TCL_EXTS@ $(DESTDIR)$(prefix)/lib/jim mkdir -p $(DESTDIR)$(prefix)/include cp @srcdir@/jim.h @srcdir@/jim-eventloop.h @srcdir@/jim-nvp.h @srcdir@/jim-signal.h \ @srcdir@/jim-subcmd.h @srcdir@/jim-win32compat.h $(DESTDIR)$(prefix)/include @@ -79,44 +69,45 @@ install-exec: all uninstall: rm -f $(DESTDIR)$(prefix)/bin/$(JIMSH) rm -f $(DESTDIR)$(prefix)/lib/$(LIBJIM) - for i in README.extensions $(C_EXT_SHOBJS) $(EXTENSION_TCL); do rm -f $(DESTDIR)$(prefix)/lib/jim/$$i; done + for i in README.extensions @C_EXT_SHOBJS@ @TCL_EXTS@; do rm -f $(DESTDIR)$(prefix)/lib/jim/$$i; done rm -f $(DESTDIR)$(prefix)/include/jim*.h rm -f $(DESTDIR)$(prefix)/doc/jim/Tcl.html -else +@else install install-exec uninstall: -endif +@endif test: $(JIMSH) - $(DEF_LD_PATH) $(MAKE) jimsh=`pwd`/jimsh -C @srcdir@/tests + $(DEF_LD_PATH) $(MAKE) -C @srcdir@/tests jimsh=`pwd`/jimsh -$(OBJS) $(C_EXT_OBJS): Makefile +$(OBJS): Makefile -ifeq (@JIM_UTF8@,1) +@if JIM_UTF8 # Generate the unicode case mapping utf8.o: _unicode_mapping.c _unicode_mapping.c: @srcdir@/UnicodeData.txt @srcdir@/parse-unidata.tcl @tclsh@ @srcdir@/parse-unidata.tcl @srcdir@/UnicodeData.txt >$@ || ( rm $@; exit 1) -endif +@endif _load-static-exts.c: @srcdir@/make-load-static-exts.tcl Makefile - @tclsh@ @srcdir@/make-load-static-exts.tcl $(JIM_EXTENSIONS) >$@ || ( rm $@; exit 1) + @tclsh@ @srcdir@/make-load-static-exts.tcl @STATIC_EXTS@ >$@ || ( rm $@; exit 1) -ifeq ($(jim_libtype),static) -$(LIBJIM): $(OBJS) $(C_EXT_OBJS) - $(AR) cr $@ $^ +@if JIM_STATICLIB +$(LIBJIM): $(OBJS) + $(AR) cr $@ $(OBJS) $(RANLIB) $@ -else -$(LIBJIM): $(OBJS) $(C_EXT_OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) $(SH_LDFLAGS) -o $@ $^ $(LDLIBS) -endif +@else +$(LIBJIM): $(OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) $(SH_LDFLAGS) -o $@ $(OBJS) $(LDLIBS) +@endif +# XXX: This won't work for BSD make %.so: jim-%.c - $(CC) $(CPPFLAGS) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o $*.o $^ + $(CC) $(CFLAGS) $(SHOBJ_CFLAGS) -c -o $*.o jim-$*.c $(CC) $(CFLAGS) $(LDFLAGS) $(SHOBJ_LDFLAGS) -o $@ $*.o $(SH_LIBJIM) $(LDLIBS) Tcl.html: jim_tcl.txt - @tclsh@ @srcdir@/make-index $^ | asciidoc -o $@ -d manpage - || cp @srcdir@/Tcl_shipped.html Tcl.html + @tclsh@ @srcdir@/make-index jim_tcl.txt | asciidoc -o $@ -d manpage - || cp @srcdir@/Tcl_shipped.html Tcl.html clean: rm -f *.o *.so lib*.a $(JIMSH) Tcl.html _*.c @@ -133,15 +124,10 @@ EMPTY_AUTOMAKE_TARGETS := dvi pdf ps info html tags ctags mostlyclean maintainer .PHONY: $(EMPTY_AUTOMAKE_TARGETS) $(EMPTY_AUTOMAKE_TARGETS): -# automake compatibilty - install sources from the current dir to $(distdir) +# automake compatibility - install sources from the current dir to $(distdir) distdir_full := $(shell cd $(distdir); pwd) distdir: cd "@srcdir@"; git ls-files | cpio -pdmu $(distdir_full) -ifeq ($(findstring clean,$(MAKECMDGOALS)),) -Makefile: @AUTODEPS@ @srcdir@/Makefile.in - @CC='@CC@' @AUTOREMAKE@ -endif - reconfig: CC='@CC@' @AUTOREMAKE@ @@ -168,16 +168,11 @@ if {[opt-bool references]} { } if {[opt-bool shared with-jim-shared]} { msg-result "Building shared library" - define JIM_LIBTYPE shared } else { msg-result "Building static library" - define JIM_LIBTYPE static -} -if {[opt-bool install-jim]} { - define install_jim 1 -} else { - define install_jim "" + define JIM_STATICLIB } +define JIM_INSTALL [opt-bool install-jim] # Note: Extension handling is mapped directly from the configure.ac # implementation @@ -381,10 +376,11 @@ foreach e $ext { } } -define JIM_STATIC_C_EXTS $ext_static_c -define JIM_STATIC_TCL_EXTS $ext_static_tcl -define JIM_TCL_EXTENSIONS $extmodtcl -define JIM_MOD_EXTENSIONS $extmod +define STATIC_EXTS [concat $ext_static_c $ext_static_tcl] +define C_EXT_OBJS [prefix jim- [suffix .o $ext_static_c]] +define TCL_EXT_OBJS [suffix .o $ext_static_tcl] +define C_EXT_SHOBJS [suffix .so $extmod] +define TCL_EXTS [suffix .tcl $extmodtcl] define EXTRA_OBJS $extra_objs make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -none * diff --git a/tests/Makefile b/tests/Makefile index 586352a..36ed253 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,8 +1,7 @@ jimsh ?= ../jimsh -export LD_LIBRARY_PATH := ..:$(LD_LIBRARY_PATH) test: - @set -e; for i in *.test; do $(jimsh) $$i; done + @set -e; for i in *.test; do LD_LIBRARY_PATH=..:$(LD_LIBRARY_PATH) $(jimsh) $$i; done clean: rm -f gorp.file2 cat gorp.file sleep exit wc sh echo test1 |