From 5d28bc1365a6d92ba6fc19d3080cec595df7a8ea Mon Sep 17 00:00:00 2001 From: Anthony Arnold Date: Tue, 17 Jan 2012 17:10:23 +1000 Subject: [PATCH] Can now make install. --- .gitignore | 6 +-- Makefile | 86 ++++++++++++++++++++++++++++++++++++++ adaid.gpr | 15 +++++-- adaid_debug.gpr | 13 +++++- makefile | 36 ---------------- src/adaid-generate.adb | 2 +- support/.gitignore | 0 support/adaid.gpr.in | 8 ++++ support/adaid_debug.gpr.in | 11 +++++ test.gpr | 17 +++++++- test/test.adb | 2 +- 11 files changed, 146 insertions(+), 50 deletions(-) create mode 100644 Makefile delete mode 100644 makefile create mode 100644 support/.gitignore create mode 100644 support/adaid.gpr.in create mode 100644 support/adaid_debug.gpr.in diff --git a/.gitignore b/.gitignore index 06b01b0..6239e6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,2 @@ -*.o -*.ali -*.a -*.so -*.so.* *~ +*.gpr diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e376332 --- /dev/null +++ b/Makefile @@ -0,0 +1,86 @@ +LIB=./lib/libadaid.so +DEBUG=./lib/libadaid.a +TEST=./bin/test +GNAT=gnat +RM=rm +CHMOD=chmod +MKDIR=mkdir -p +CP=cp + + +.PHONY: debug test install installclean clean cleanall all support remove + +#library +$(LIB): src/*.adb src/*.ads include/*.ads + $(GNAT) make -Padaid.gpr + + +#installation +INSTALL = $(shell which $(GNAT) 2> /dev/null | sed -e 's/\/bin\/gnat.*//') +INCLUDE= $(INSTALL)/share/ada/adainclude/adaid +LIBRARY=$(INSTALL)/lib +ALI=$(INSTALL)/lib/ada/adalib/adaid +GPR = $(INSTALL)/share/ada/adainclude + +support/adaid.gpr: support/adaid.gpr.in + @cat $< | sed -e 's!%LIB_DIR%!$(LIBRARY)!' \ + -e 's!%SRC_DIR%!$(INCLUDE)!' \ + -e 's!%ALI_DIR%!$(ALI)!' > $@ + +installclean: +ifeq ($(INSTALL),) + @echo 'Error when installing: $$INSTALL is empty...' + @echo "Please set an installation path before installing" +else + -$(CHMOD) -f -R 777 $(ALI) + $(RM) -fr $(ALI) + -$(CHMOD) -f -R 777 $(INCLUDE) + $(RM) -fr $(INCLUDE) + $(RM) -f $(GPR)/adaid.gpr + $(RM) -f $(GPR)/adaid_debug.gpr +endif + +install: installclean support/adaid.gpr +ifneq ($(INSTALL),) + $(MKDIR) $(GPR) + $(MKDIR) $(LIBRARY) + $(MKDIR) $(INCLUDE) + $(MKDIR) $(ALI) + $(CP) -r ali/* $(ALI) + $(CP) support/*.gpr $(GPR) + $(CP) -r lib/* $(LIBRARY) + $(CP) -r include/* $(INCLUDE) + @echo '-- AdaID has been installed.' +endif + +remove: installclean + + +#debug library +debug: support/adaid_debug.gpr $(DEBUG) + +support/adaid_debug.gpr: support/adaid_debug.gpr.in + @cat $< n | sed -e 's!%LIB_DIR%!$(LIBRARY)!' \ + -e 's!%SRC_DIR%!$(INCLUDE)!' \ + -e 's!%ALI_DIR%!$(ALI)!' > $@ + +$(DEBUG): src/*.adb src/*.ads include/*.ads + $(GNAT) make -Padaid_debug.gpr + +#test executable +$(TEST): $(LIB) include/*.ads test/*.adb test/*.ads + $(GNAT) make -Ptest.gpr + +#run tests +test: $(TEST) + $(TEST) + +#misc +all: $(LIB) $(TEST) + +clean: + $(RM) -f support/*.gpr obj/*.* obj/test/*.* obj/debug/*.* ali/*.* ali/debug/*.* 2> /dev/null + +cleanall: clean + $(RM) -f bin/* lib/* 2> /dev/null + diff --git a/adaid.gpr b/adaid.gpr index ad916f7..1f9061c 100644 --- a/adaid.gpr +++ b/adaid.gpr @@ -1,5 +1,5 @@ library project AdaID is - Version := "1"; + Version := "0.0.0"; for Library_Name use "adaid"; for Object_Dir use "obj"; for Source_Dirs use ("src"); @@ -9,10 +9,19 @@ library project AdaID is for Library_Version use "libadaid.so." & Version; package Builder is - for Default_Switches("Ada") use ("-O2", "-gnat12", "-gnatQ"); + for Default_Switches("Ada") use ("-O2", + "-Wall", + "-Wextra", + "-gnat12", + "-gnatQ"); end Builder; package Compiler is - for Default_Switches("Ada") use ("-O2", "-gnat12", "-I./include"); + for Default_Switches("Ada") use ("-O2", + "-Wall", + "--pedantic-errors", + "-Wextra", + "-gnat12", + "-I./include"); end Compiler; end AdaID; diff --git a/adaid_debug.gpr b/adaid_debug.gpr index e9fbb24..05f0151 100644 --- a/adaid_debug.gpr +++ b/adaid_debug.gpr @@ -7,10 +7,19 @@ library project AdaID_Debug is for Library_ALI_Dir use "ali/debug"; package Builder is - for Default_Switches("Ada") use ("-g", "-gnat12", "-gnatQ"); + for Default_Switches("Ada") use ("-g", + "-Wall", + "-Wextra", + "-gnat12", + "-gnatQ"); end Builder; package Compiler is - for Default_Switches("Ada") use ("-g", "-gnat12", "-I./include"); + for Default_Switches("Ada") use ("-g", + "-Wall", + "--pedantic-errors", + "-Wextra", + "-gnat12", + "-I./include"); end Compiler; end AdaID_Debug; diff --git a/makefile b/makefile deleted file mode 100644 index 3037a54..0000000 --- a/makefile +++ /dev/null @@ -1,36 +0,0 @@ -LIB=./lib/libadaid.so -DEBUG=./lib/libadaid.a -TEST=./bin/test - -#library -$(LIB): src/*.adb src/*.ads include/*.ads - gnatmake -Padaid.gpr - -#debugging -.PHONY: debug - -debug: $(DEBUG) - -$(DEBUG): src/*.adb src/*.ads include/*.ads - gnatmake -Padaid_debug.gpr - -#test executable -$(TEST): $(LIB) include/*.ads test/*.adb test/*.ads - gnatmake -Ptest.gpr - -#run tests -test: $(TEST) - $(TEST) - -#misc -.PHONY: all - -all: $(LIB) $(TEST) - -.PHONY: clean -.PHONY: cleanall -clean: - rm -f obj/*.* obj/test/*.* obj/debug/*.* ali/*.* ali/debug/*.* 2> /dev/null -cleanall: clean - rm -f bin/* lib/* 2> /dev/null - diff --git a/src/adaid-generate.adb b/src/adaid-generate.adb index 44e5388..4e5d99b 100644 --- a/src/adaid-generate.adb +++ b/src/adaid-generate.adb @@ -37,7 +37,7 @@ package body AdaID.Generate is rand := RNG.Random(generator); for i in ByteArray'Range loop - if x = Unsigned_32'Size then + if x = 4 then x := 0; rand := RNG.Random(generator); end if; diff --git a/support/.gitignore b/support/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/support/adaid.gpr.in b/support/adaid.gpr.in new file mode 100644 index 0000000..ab1721e --- /dev/null +++ b/support/adaid.gpr.in @@ -0,0 +1,8 @@ +project AdaID is + for Library_Dir use "%LIB_DIR%"; + for Library_ALI_Dir use "%ALI_DIR%"; + for Library_Name use "adaid"; + for Library_Kind use "dynamic"; + for Externally_Built use "true"; + for Source_Dirs use ("%SRC_DIR%"); +end AdaID; diff --git a/support/adaid_debug.gpr.in b/support/adaid_debug.gpr.in new file mode 100644 index 0000000..de26c60 --- /dev/null +++ b/support/adaid_debug.gpr.in @@ -0,0 +1,11 @@ +project AdaID_Debug is + + for Library_Dir use "../../../lib"; + for Library_ALI_Dir use "../../../lib/ada/adalib/adaid/debug"; + for Library_Name use "adaid_debug"; + for Library_Kind use "static"; + for Externally_Built use "true"; + + for Source_Dirs use ("./adaid"); + +end AdaID_Debug; diff --git a/test.gpr b/test.gpr index c13e3ae..956b116 100644 --- a/test.gpr +++ b/test.gpr @@ -8,7 +8,12 @@ project Test is for Exec_Dir use "bin"; package Builder is - for Default_Switches("Ada") use ("-g", "-gnat12", "-gnatQ", "-I./include"); + for Default_Switches("Ada") use ("-g", + "-Wall", + "-Wextra", + "-gnat12", + "-gnatQ", + "-I./include"); end Builder; @@ -17,7 +22,15 @@ project Test is end Linker; package Compiler is - for Default_Switches("Ada") use ("-Llib", "-ladaid_debug", "-gnatf", "-g", "-I./include"); + for Default_Switches("Ada") use ("-Llib", + "-ladaid_debug", + "-gnatf", + "-gnatwaeF", + "-g", + "-Wall", + "--pedantic-errors", + "-Wextra", + "-I./include"); end Compiler; package Binder is diff --git a/test/test.adb b/test/test.adb index c8acadb..1aad040 100644 --- a/test/test.adb +++ b/test/test.adb @@ -10,7 +10,7 @@ with AdaID_Tests; procedure Test is function Suite return Access_Test_Suite is - Result : Access_Test_Suite := new Test_Suite; + Result : constant Access_Test_Suite := new Test_Suite; begin Add_Test(Result, new AdaID_Tests.UUID_Test); return Result;