On Tue, 16 Feb 2010, Nicolas Boulenguez wrote:
On Sun, Feb 14, 2010 at 11:17:02AM -0500, Thomas Dickey wrote:
On Sun, 14 Feb 2010, Nicolas Boulenguez wrote:
I would like to make a separate package from the Ada binding. This
seems the only solution since the GNAT compiler will not be available
on all debian architectures before long, and this would make it quite
difficult to build it from the same tarball than the C API.
It should not be difficult to convince the upstream to make its source
a separate tarball, since nothing has been modified in it for many
years.
actually, it seems that every time gnat is updated, there are more
stylistic changes needed (aside from that, it's pretty stable).
Would you please release a separate tarball containing only the Ada95/
subdirectory and the related documentation?? I cannot estimate the
work needed if you still want generated Makefiles, but the following
Makefile and GNAT project file make the job for me and may be a
starting point.
thanks - I'll see what I can do with this. (I may make an Ada95/configure
to fill in the details).
-- Content of file: Makefile
#!/usr/bin/make -f
# These main variables may be inherited from a distribution script.
LIB_NAME ?= ncursesada
DESTDIR ?=
SONAME ?= lib$(LIB_NAME).so.1
# These main variables only depend on these sources.
ADA_DIR := $(realpath .)/Ada95
BUILD_DIR := $(realpath .)/build
GNAT_PROJECT := build.gpr
# gnatmake can do parallel builds; we don't want make to interfere.
.NOTPARALLEL:
CPUS := $(shell getconf _NPROCESSORS_ONLN)
###################### build directory
$(BUILD_DIR) $(BUILD_DIR)/src $(BUILD_DIR)/m4:
mkdir -p $@
###################### C program exporting representations
$(BUILD_DIR)/gen: $(ADA_DIR)/gen/gen.c \
| $(BUILD_DIR)
gcc $< -o $@ -lncurses
###################### files containing the m4 macros
define generate_macro
$(BUILD_DIR)/m4/$(1): $(BUILD_DIR)/gen \
| $(BUILD_DIR)/m4
$$< "" $(2) > $$@
GENERATED_MACROS += $(BUILD_DIR)/m4/$(1)
endef
$(eval $(call generate_macro,Character_Attribute_Set_Rep,B A))
$(eval $(call generate_macro,Base_Defs,B B))
$(eval $(call generate_macro,Color_Defs,B C))
$(eval $(call generate_macro,Window_Offsets,B D))
$(eval $(call generate_macro,Key_Definitions,B K))
$(eval $(call generate_macro,Linker_Options,B L))
$(eval $(call generate_macro,ACS_Map,B M))
$(eval $(call generate_macro,Old_Keys,B O))
$(eval $(call generate_macro,Public_Variables,B P))
$(eval $(call generate_macro,AC_Rep,B R))
$(eval $(call generate_macro,Version_Info,B V))
$(eval $(call generate_macro,Trace_Defs,B T))
$(eval $(call generate_macro,Menu_Opt_Rep,M R))
$(eval $(call generate_macro,Menu_Base_Defs,M B))
$(eval $(call generate_macro,Menu_Linker_Options,M L))
$(eval $(call generate_macro,Item_Rep,M I))
$(eval $(call generate_macro,Form_Opt_Rep,F R))
$(eval $(call generate_macro,Form_Base_Defs,F B))
$(eval $(call generate_macro,Form_Linker_Options,F L))
$(eval $(call generate_macro,Field_Rep,F I))
$(eval $(call generate_macro,Mouse_Base_Defs,P B))
$(eval $(call generate_macro,Mouse_Event_Rep,P M))
$(eval $(call generate_macro,Mouse_Events,B E))
$(eval $(call generate_macro,Panel_Linker_Options,P L))
$(eval $(call generate_macro,Chtype_Def,E C))
$(eval $(call generate_macro,Eti_Defs,E E))
###################### m4 generated Ada sources
define generate_m4_source
$(BUILD_DIR)/src/$(1): $(ADA_DIR)/gen/$(1).m4 \
$(ADA_DIR)/gen/normal.m4 \
$(GENERATED_MACROS) \
| $(BUILD_DIR)/src
(cd $(BUILD_DIR)/m4 && m4 -DNCURSES_EXT_FUNCS=TODO \
-DM4MACRO=$(ADA_DIR)/gen/normal.m4) \
< $$< \
| sed -e '/^\-\-\ \ \-\*\-\ ada\ \-\*\-.*/d' \
> $$@
GENERATED_SOURCES += $(BUILD_DIR)/src/$(1)
endef
$(foreach template, \
$(patsubst $(ADA_DIR)/gen/%.m4,%, \
$(wildcard $(ADA_DIR)/gen/terminal_interface-curses*.m4)), \
$(eval $(call generate_m4_source,$(template))))
###################### gnatprep generated Ada sources
# pragma Unreferenced has entered standard Ada now.
# Choose whether we add trace() function to all models of ncurses
$(BUILD_DIR)/src/terminal_interface-curses-trace.adb:
$(ADA_DIR)/src/terminal_interface-curses-trace.adb_p \
| $(BUILD_DIR)/src
gnatprep $< $@ -DADA_TRACE=False -DPRAGMA_UNREF=True
GENERATED_SOURCES += $(BUILD_DIR)/src/terminal_interface-curses-trace.adb
##################### build/install/clean Ada sources
.PHONY: build
build: export BUILD_DIR := $(BUILD_DIR)
build: export ADA_DIR := $(ADA_DIR)
build: export LIB_NAME := $(LIB_NAME)
build: export SONAME := $(SONAME)
build: $(GENERATED_SOURCES)
gnatmake -j$(CPUS) -p -P$(GNAT_PROJECT) -XLIB_KIND=dynamic
gnatmake -j$(CPUS) -p -P$(GNAT_PROJECT) -XLIB_KIND=static
.PHONY: install
install:
install --directory $(DESTDIR)/usr/share/ada/adainclude/$(LIB_NAME)
install --mode=644 \
$(ADA_DIR)/src/*.ad[sb] \
$(GENERATED_SOURCES) \
$(DESTDIR)/usr/share/ada/adainclude/$(LIB_NAME)
install --directory $(DESTDIR)/usr/lib/ada/adalib/$(LIB_NAME)
install --mode=444 \
$(BUILD_DIR)/dynamic-ali/* \
$(DESTDIR)/usr/lib/ada/adalib/$(LIB_NAME)
install --mode=644 \
$(BUILD_DIR)/lib$(LIB_NAME).a \
$(BUILD_DIR)/$(SONAME) \
$(DESTDIR)/usr/lib
cd $(DESTDIR)/usr/lib && ln -s $(SONAME) lib$(LIB_NAME).so
.PHONY: uninstall
uninstall:
rm -rf \
$(DESTDIR)/usr/share/ada/adainclude/$(LIB_NAME) \
$(DESTDIR)/usr/lib/ada/adalib/$(LIB_NAME) \
$(DESTDIR)/usr/lib/lib$(LIB_NAME).a \
$(DESTDIR)/usr/lib/$(SONAME) \
$(DESTDIR)/usr/lib/lib$(LIB_NAME).so
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
-- Content of file: build.gpr
project Build is
Build_Dir := External ("BUILD_DIR");
Ada_Dir := External ("ADA_DIR");
Kind := External ("LIB_KIND");
for Library_Name use External ("LIB_NAME");
for Library_Version use External ("SONAME");
for Library_Kind use Kind;
for Library_Dir use Build_Dir;
for Object_Dir use Build_Dir & "/" & Kind & "-obj";
for Library_ALI_Dir use Build_Dir & "/" & Kind & "-ali";
for Source_Dirs use (Ada_Dir & "/src",
Build_Dir & "/src");
package Compiler is
for Default_Switches ("Ada") use
("-g", "-O2", "-gnatafno", "-gnatVa", "-gnatwa");
end Compiler;
end Build;
--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net