]> git.ipfire.org Git - thirdparty/newt.git/blobdiff - Makefile.in
install python modules to purelib and platlib
[thirdparty/newt.git] / Makefile.in
index fd9eedbe6440a7240b44cfb559e321a7e01b8cdd..1741ee757359d7d365fb142a239276ffed310b0e 100644 (file)
@@ -1,37 +1,56 @@
-LIBS = -lslang -lm #-lefence
-SHLIBS = -lslang -lm -lc
+LIBS = -lslang @LIBS@
+LIBTCL = @TCL_LIB_FLAG@
 
-GPM_SUPPORT=@gpm_support@
-
-CFLAGS = $(RPM_OPT_FLAGS) -Wall -I/usr/include/slang
-ifeq ($(RPM_OPT_FLAGS),)
-CFLAGS += -g # -O2 -I/usr/include/slang
-endif
+CC = @CC@
+CPP = @CPP@
+CFLAGS = @CFLAGS@
+LDFLAGS = @LDFLAGS@
+CPPFLAGS = -D_GNU_SOURCE @CPPFLAGS@
+GNU_LD = @GNU_LD@
 
 VERSION = @VERSION@
-CVSTAG = r$(subst .,-,$(VERSION))
-SONAME = @VERSION@
+TAG = r$(subst .,-,$(VERSION))
+SONAME = @SONAME@
+SOEXT = so
+
+PYTHONVERS = @PYTHONVERS@
+WHIPTCLLIB = @WHIPTCLLIB@
+ifneq ($(WHIPTCLLIB),)
+WHIPTCLSO = $(WHIPTCLLIB).$(SOEXT)
+else
+WHIPTCLSO =
+endif
 
-PROGS = test whiptail whiptcl.so testgrid
-TESTOBJS = test.o
+PROGS = test whiptail $(WHIPTCLSO) testgrid testtree showchars showkey
+TESTOBJS = test.o testgrid.o testtree.o showchars.o showkey.o
 NDIALOGOBJS = whiptail.o dialogboxes.o
-WHIPTCLOBJS = whiptcl.o dialogboxes.o
+WHIPTCLOBJS = shared/whiptcl.o shared/dialogboxes.o
 LIBNEWT = libnewt.a
-LIBNEWTSH = libnewt.so.$(VERSION)
-LIBNEWTSONAME = libnewt.so.$(SONAME)
+LIBNEWTSH = libnewt.$(SOEXT).$(VERSION)
+LIBNEWTSONAME = libnewt.$(SOEXT).$(SONAME)
 LIBOBJS = newt.o button.o form.o checkbox.o entry.o label.o listbox.o \
           scrollbar.o textbox.o scale.o grid.o windows.o buttonbar.o \
          checkboxtree.o
 
+ifneq ($(GNU_LD),)
+SHLIBFLAGS= -Wl,--version-script,newt.0.52.ver -Wl,-soname,$(LIBNEWTSONAME)
+else
+SHLIBFLAGS=
+endif
+
 SHCFLAGS = -fPIC
 
-prefix = /usr
-includedir = $(prefix)/include
-libdir = $(prefix)/lib
-bindir = $(prefix)/bin
-ARCHNAME = $(shell uname -m | sed 's/i.86/i386/')
-pythondir = $(prefix)/lib/python1.5
-pythonbindir = $(prefix)/lib/python1.5/lib-dynload
+prefix = @prefix@
+includedir = @includedir@
+exec_prefix = @exec_prefix@
+libdir = @libdir@
+bindir = @bindir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+mandir = @mandir@
+man1dir = $(mandir)/man1
+pkgconfigdir = $(libdir)/pkgconfig
+instroot ?= $(DESTDIR)
 
 #--------------------------------------
 
@@ -46,84 +65,134 @@ else
 TARGET=depend $(PROGS)
 endif
 
-all:   $(TARGET) _snackmodule.so
+all:   $(TARGET) _snack.$(SOEXT)
 
-test:  $(TESTOBJS) $(LIBNEWT)
-       gcc -g -o test $(TESTOBJS) $(LIBNEWT) $(LIBS) -static
+test:  test.o $(LIBNEWT)
+       $(CC) -g -o test test.o $(LIBNEWT) $(LDFLAGS) $(LIBS)
 
 testgrid:      testgrid.o $(LIBNEWT)
-       gcc -g -o testgrid testgrid.o $(LIBNEWT) $(LIBS)
-
-_snackmodule.so:   snackmodule.o $(LIBNEWTSH)
-       gcc --shared -o _snackmodule.so snackmodule.o -L . $(LIBNEWTSH)
-
-snackmodule.o:   snackmodule.c
-       gcc -I/usr/include/python1.5 -fPIC $(CFLAGS) -c snackmodule.c
+       $(CC) -g -o testgrid testgrid.o $(LIBNEWT) $(LDFLAGS) $(LIBS)
+
+testtree:      testtree.o $(LIBNEWT)
+       $(CC) -g -o testtree testtree.o $(LIBNEWT) $(LDFLAGS) $(LIBS)
+
+showchars:     showchars.o $(LIBNEWT)
+       $(CC) -g -o showchars showchars.o $(LIBNEWT) $(LDFLAGS) $(LIBS)
+
+showkey:       showkey.o $(LIBNEWT)
+       $(CC) -g -o showkey showkey.o $(LIBNEWT) $(LDFLAGS) $(LIBS)
+
+_snack.$(SOEXT):   snack.c $(LIBNEWTSH)
+ifneq ($(PYTHONVERS),)
+       @for ver in $(PYTHONVERS); do \
+               pyconfig=$$ver-config; \
+               if ! $$pyconfig --cflags > /dev/null 2>&1 && \
+                               python-config --cflags > /dev/null 2>&1; then \
+                       echo $$pyconfig not found, using python-config; \
+                       pyconfig=python-config; \
+               fi; \
+               mkdir -p $$ver; \
+               PCFLAGS=`$$pyconfig --cflags`; \
+               PLDFLAGS=`$$pyconfig --ldflags --embed || $$pyconfig --ldflags`; \
+               echo $(CC) $(SHCFLAGS) $(CFLAGS) $(CPPFLAGS) $$PCFLAGS -c -o $$ver/snack.o snack.c; \
+               $(CC) $(SHCFLAGS) $(CFLAGS) $(CPPFLAGS) $$PCFLAGS -c -o $$ver/snack.o snack.c; \
+               echo $(CC) --shared $(LDFLAGS) $$PLDFLAGS -o $$ver/_snack.$(SOEXT) $$ver/snack.o -L. -lnewt $(LIBS); \
+               $(CC) --shared $(LDFLAGS) $$PLDFLAGS -o $$ver/_snack.$(SOEXT) $$ver/snack.o -L. -lnewt $(LIBS); \
+       done
+endif
+       touch $@
 
 whiptail: $(NDIALOGOBJS) $(LIBNEWTSH)
-       gcc -g -o whiptail $(NDIALOGOBJS) -L . $(LIBNEWTSH) $(LIBS) -lpopt
+       $(CC) -g -o whiptail $(NDIALOGOBJS) -L. $(LDFLAGS) -lnewt $(LIBS) -lpopt
 
-whiptcl.so: $(WHIPTCLOBJS) $(LIBNEWTSH)
-       gcc -shared -o whiptcl.so $(WHIPTCLOBJS) -L . $(LIBNEWTSH) -ltcl -lslang -lpopt -lm
+whiptcl.$(SOEXT): $(WHIPTCLOBJS) $(LIBNEWTSH)
+       $(CC) -shared $(SHCFLAGS) $(LDFLAGS) -o whiptcl.$(SOEXT) $(WHIPTCLOBJS) -L. -lnewt  $(LIBTCL) -lpopt $(LIBS)
 
-$(LIBNEWT): $(LIBNEWT)($(LIBOBJS))
+$(LIBNEWT): $(LIBOBJS)
+       ar rv $@ $^
 
-newt.o: newt.c Makefile
-       $(CC) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
+newt.o $(SHAREDDIR)/newt.o: newt.c Makefile
 
 veryclean: clean
-       rm -f .depend
+       rm -f .depend *.pc
 
 clean:
        rm -f $(PROGS) *.o $(LIBNEWT) core $(LIBNEWTSH)  \
-               $(SHAREDOBJS) *.so*
+               $(SHAREDDIR)/*.o *.$(SOEXT)*
 
 depend:
-       $(CPP) $(CFLAGS) -M $(SOURCES) > .depend
-
-$(SHAREDDIR):
-       mkdir -p $(SHAREDDIR)
+       $(CC) $(CFLAGS) $(CPPFLAGS) -M $(SOURCES) > .depend
 
 sharedlib: $(LIBNEWTSH)
 
-$(LIBNEWTSH): $(SHAREDDIR) $(SHAREDOBJS)
-       gcc -shared -o $(LIBNEWTSH) -Wl,-soname,$(LIBNEWTSONAME) $(SHAREDOBJS) $(SHLIBS)
+$(LIBNEWTSH): $(SHAREDOBJS)
+       $(CC) -shared -o $(LIBNEWTSH) $(SHLIBFLAGS) $(SHAREDOBJS) $(LDFLAGS) $(LIBS)
+       ln -fs $(LIBNEWTSONAME) libnewt.$(SOEXT)
+       ln -fs $(LIBNEWTSH) $(LIBNEWTSONAME)
 
 $(SHAREDDIR)/%.o : %.c
-       $(CC) $(SHCFLAGS) -c $(CFLAGS) -o $@ $<
+       @mkdir -p $(SHAREDDIR)
+       $(CC) $(SHCFLAGS) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<
 
-$(SHAREDDIR)/newt.o: newt.c Makefile
-       $(CC) $(SHCFLAGS) $(CFLAGS) -DVERSION=\"$(VERSION)\" -c -o $@ $<
-
-
-install: $(LIBNEWT) whiptail
+install: $(LIBNEWT) install-sh whiptail
        [ -d $(instroot)/$(bindir) ] || install -m 755 -d $(instroot)/$(bindir)
        [ -d $(instroot)/$(libdir) ] || install -m 755 -d $(instroot)/$(libdir)
-       [ -d $(instroot)/$(includedir) ] || install -m 755 -d $(instroot)/$(includedir)
-       install -m 644 newt.h $(instroot)/$(includedir)
+       [ -d $(instroot)/$(man1dir) ] || install -m 755 -d $(instroot)/$(man1dir)
        install -m 644 $(LIBNEWT) $(instroot)/$(libdir)
-       install -s -m 755 whiptail $(instroot)/$(bindir)
+       install -m 755 whiptail $(instroot)/$(bindir)
+       install -m 644 whiptail.1 $(instroot)/$(man1dir)
+       make -C po datadir=$(instroot)/$(datadir) install
 
-install-sh: sharedlib whiptcl.so _snackmodule.so
+install-sh: sharedlib install-tcl install-py
+       [ -d $(instroot)/$(libdir) ] || install -m 755 -d $(instroot)/$(libdir)
+       [ -d $(instroot)/$(includedir) ] || install -m 755 -d $(instroot)/$(includedir)
+       [ -d $(instroot)/$(pkgconfigdir) ] || install -m 755 -d $(instroot)/$(pkgconfigdir)
+       install -m 644 newt.h $(instroot)/$(includedir)
        install -m 755 $(LIBNEWTSH) $(instroot)/$(libdir)
-       ln -sf $(LIBNEWTSH) $(instroot)/$(libdir)/libnewt.so
-       install -m 755 whiptcl.so $(instroot)/$(libdir)
-       [ -d $(instroot)/$(pythonbindir) ] || install -m 755 -d $(instroot)/$(pythonbindir)
-       install -m 755 _snackmodule.so $(instroot)/$(pythonbindir)
-       install -m 755 snack.py $(instroot)/$(pythondir)
-
-archive:
-       @cvs tag -F $(CVSTAG)
-       @rm -rf /tmp/newt-$(VERSION) /tmp/newt
-       @cd /tmp; cvs export -r$(CVSTAG) newt; mv newt newt-$(VERSION)
-       @cd /tmp/newt-$(VERSION); autoconf
-       @cd /tmp; tar czSpf newt-$(VERSION).tar.gz newt-$(VERSION)
+       ln -sf $(LIBNEWTSONAME) $(instroot)/$(libdir)/libnewt.$(SOEXT)
+       ln -sf $(LIBNEWTSH) $(instroot)/$(libdir)/$(LIBNEWTSONAME)
+       install -m 644 libnewt.pc $(instroot)/$(pkgconfigdir)
+
+install-tcl: $(WHIPTCLSO)
+ifneq ($(WHIPTCLSO),)
+       [ -d $(instroot)/$(libdir) ] || install -m 755 -d $(instroot)/$(libdir)
+       install -m 755 $(WHIPTCLSO) $(instroot)/$(libdir)
+endif
+
+install-py: _snack.$(SOEXT)
+ifneq ($(PYTHONVERS),)
+       @for ver in $(PYTHONVERS); do \
+               PLATLIB=`$$ver -c "import sysconfig; print(sysconfig.get_path('platlib'))"`; \
+               PURELIB=`$$ver -c "import sysconfig; print(sysconfig.get_path('purelib'))"`; \
+               [ -d $(instroot)/$$PLATLIB ] || install -m 755 -d $(instroot)/$$PLATLIB ;\
+               [ -d $(instroot)/$$PURELIB ] || install -m 755 -d $(instroot)/$$PURELIB ;\
+               echo install -m 755 $$ver/_snack.$(SOEXT) $(instroot)/$$PLATLIB;\
+               install -m 755 $$ver/_snack.$(SOEXT) $(instroot)/$$PLATLIB;\
+               echo install -m 644 snack.py $(instroot)/$$PURELIB;\
+               install -m 644 snack.py $(instroot)/$$PURELIB;\
+       done
+endif
+
+Makefile: configure.ac
+       @echo "You need to rerun ./autogen.sh and ./configure before continuing"
+       @exit 1
+
+create-archive: Makefile
+       @rm -rf /tmp/newt-$(VERSION)
+       @git archive --prefix=newt-$(VERSION)/ $(TAG) | tar x -C /tmp
+       @cd /tmp/newt-$(VERSION) && ./autogen.sh && rm -rf autom4te.cache .gitignore
+       @cd /tmp; tar c --owner root --group root newt-$(VERSION) | gzip -9 > newt-$(VERSION).tar.gz
        @rm -rf /tmp/newt-$(VERSION)
        @cp /tmp/newt-$(VERSION).tar.gz .
        @rm -f /tmp/newt-$(VERSION).tar.gz
        @echo " "
        @echo "The final archive is ./newt-$(VERSION).tar.gz."
 
+tag-archive: Makefile
+       @git tag $(TAG)
+
+archive: tag-archive create-archive
+
 ifeq (.depend,$(wildcard .depend))
 include .depend
 endif