Simplify installation procedure
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 29 Jan 2018 19:56:28 +0000 (20:56 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 29 Jan 2018 19:56:28 +0000 (20:56 +0100)
27 files changed:
.gitignore [new file with mode: 0644]
AUTHORS [deleted file]
INSTALL [deleted file]
LICENSE
Makefile
README.md
cgds
makeMakefile.sh [deleted file]
src/.gitignore [deleted file]
src/Makefile [new file with mode: 0644]
src/Makefile.base [deleted file]
src/obj/.gitkeep [new file with mode: 0644]
test/.gitignore [deleted file]
test/Makefile [new file with mode: 0644]
test/Makefile.base [deleted file]
test/README [new file with mode: 0644]
test/main.c
test/makeMain.sh [changed mode: 0644->0755]
test/obj/.gitkeep [new file with mode: 0644]
test/t.BufferTop.c
test/t.Heap.c
test/t.List.c
test/t.PriorityQueue.c
test/t.Queue.c
test/t.Stack.c
test/t.Tree.c
test/t.Vector.c

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..b9d261d
--- /dev/null
@@ -0,0 +1,5 @@
+*.o
+/src/obj/*.so
+/test/test
+/doc/html/
+/doc/latex/
diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644 (file)
index e43cd6f..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1,13 +0,0 @@
-#Document updated on 2014-12-09.
-################################
-
-#Active developers.
-
-Years    | Name               | Contact email
----------|--------------------|--------------------------
-2013-now | Benjamin Auder     | benjamin.a@mailoo.org
-
-#Past code contributors.
-
-Years     | Name
-----------|--------------------
diff --git a/INSTALL b/INSTALL
deleted file mode 100644 (file)
index fc04dbc..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,9 +0,0 @@
-To build on (hopefully) any GNU/Linux [brackets means "optional"] :
-
-    make [src]
-    [make test]
-    make install
-
-To (un)install the library :
-
-    make (un)install
diff --git a/LICENSE b/LICENSE
index 4422e1d..7fdc5ec 100644 (file)
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,15 @@
-Expat License (often called "MIT license")
+ISC license https://opensource.org/licenses/ISC
 
-Copyright (c) 2013-2014 Benjamin Auder
+Copyright (C) 2013-2018 Benjamin Auder
 
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
 
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
index 86f819b..de9dd81 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,13 @@
 LIBRARY = libcgds.so
 INSTALL_PREFIX = /usr/local
 
+all: src
+
 src:
        cd src && $(MAKE) && cd ..
 
 test:
-       cd test && $(MAKE) && cd ..
+       cd test && ./makeMain.sh && $(MAKE) && cd ..
 
 doc:
        cd doc && $(MAKE) && cd ..
index c67b79f..342d2d6 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,6 +2,12 @@
 
 Various data structures, from stack to tree, which can contain any data type.
 
+## Installation
+
+       make [src]
+       make install
+'src' is Makefile default target.
+
 ## Example
 
        Vector* v = vector_new(int);
diff --git a/cgds b/cgds
index e831038..aa8e45f 120000 (symlink)
--- a/cgds
+++ b/cgds
@@ -1 +1 @@
-src
\ No newline at end of file
+src/
\ No newline at end of file
diff --git a/makeMakefile.sh b/makeMakefile.sh
deleted file mode 100755 (executable)
index 7419805..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/bash
-
-subfolder=$1
-
-cd $subfolder
-cat Makefile.base > Makefile
-printf "\n" >> Makefile
-for folder in `find . -path ./obj -prune -o -type d -print`; do
-       mkdir -p obj/$folder
-done
-
-sources=`find . -type f -name \*.c`
-objects=""
-for file in $sources; do
-       objects+="obj/${file%?}o "
-done
-printf "obj/\$(TARGET): $objects\n" >> Makefile
-printf '\t$(CC) $(LDFLAGS) -o $@ $^\n\n' >> Makefile 
-
-for file in $sources; do
-       deps=`grep '#include "' $file | cut -d ' ' -f 2 | sed 's/^"\(.*\)"$/..\/\1/g' | tr '\n' ' '`
-       fileDotO="obj/${file%?}o"
-       printf "$fileDotO: $file $deps\n" >> Makefile
-       printf '\t$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<\n\n' >> Makefile
-done
-
-cd ..
diff --git a/src/.gitignore b/src/.gitignore
deleted file mode 100644 (file)
index 5d3fa11..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-obj/
-Makefile
diff --git a/src/Makefile b/src/Makefile
new file mode 100644 (file)
index 0000000..d995fd6
--- /dev/null
@@ -0,0 +1,26 @@
+CC = gcc
+CFLAGS = -g -std=gnu99 -fPIC
+LDFLAGS = -shared
+INCLUDES = -I..
+
+SRC_DIR = ./
+OBJ_DIR = ./obj
+
+TARGET = $(OBJ_DIR)/libcgds.so
+
+SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
+H_FILES = $(wildcard $(SRC_DIR)/*.h)
+OBJ_FILES = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES))
+
+all: $(TARGET)
+
+$(TARGET): $(OBJ_FILES)
+       $(CC) $(LDFLAGS) -o $@ $^
+
+$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(SRC_DIR)/%.h
+       $(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<
+
+clean:
+       rm -f $(OBJ_DIR)/*.o $(TARGET)
+
+.PHONY: all clean
diff --git a/src/Makefile.base b/src/Makefile.base
deleted file mode 100644 (file)
index 2df7d91..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-CC = gcc
-CFLAGS = -g -std=gnu99 -fPIC
-LDFLAGS = -shared
-INCLUDES = -I..
-TARGET = libcgds.so
-
-all: obj/$(TARGET)
-
-clean:
-       rm -f obj/*.o
-       rm -f obj/$(TARGET)
-
-.PHONY: all clean
diff --git a/src/obj/.gitkeep b/src/obj/.gitkeep
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/.gitignore b/test/.gitignore
deleted file mode 100644 (file)
index 5d3fa11..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-obj/
-Makefile
diff --git a/test/Makefile b/test/Makefile
new file mode 100644 (file)
index 0000000..c3a67ab
--- /dev/null
@@ -0,0 +1,26 @@
+CC = gcc
+CFLAGS = -g -std=gnu99 -Wno-implicit-function-declaration
+LDFLAGS = -L../src/obj -lcgds -Wl,-rpath=../src/obj
+INCLUDES = -I..
+
+SRC_DIR = ./
+OBJ_DIR = ./obj
+
+TARGET = test
+
+SRC_FILES = $(wildcard $(SRC_DIR)/*.c)
+H_FILES = lut.h helpers.h
+OBJ_FILES = $(patsubst $(SRC_DIR)/%.c,$(OBJ_DIR)/%.o,$(SRC_FILES))
+
+all: $(TARGET)
+
+$(TARGET): $(OBJ_FILES)
+       $(CC) $(LDFLAGS) -o $@ $^
+
+$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(H_FILES)
+       $(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $<
+
+clean:
+       rm -f $(OBJ_DIR)/*.o $(TARGET)
+
+.PHONY: all clean
diff --git a/test/Makefile.base b/test/Makefile.base
deleted file mode 100644 (file)
index 549baf8..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-CC = gcc
-CFLAGS = -g -std=gnu99 -Wno-implicit-function-declaration
-LDFLAGS = -L../src/obj -lcgds
-INCLUDES = -I.. -I../src
-TARGET = testcgds
-
-all: obj/$(TARGET)
-
-clean:
-       rm -f obj/*.o
-       rm -f obj/$(TARGET)
-
-.PHONY: all clean
diff --git a/test/README b/test/README
new file mode 100644 (file)
index 0000000..6ea0137
--- /dev/null
@@ -0,0 +1,4 @@
+Testing procedure (assuming src/Makefile already run):
+  1) ./makeMain.sh
+       2) make
+       3) ./test
index 7b8f5ff..3c2cf04 100644 (file)
@@ -2,19 +2,19 @@
 
 int main(int argc, char** argv)
 {
-       //file ./t.Vector.c :
-       t_vector_clear();
-       t_vector_size();
-       t_vector_push_pop_basic();
-       t_vector_push_pop_evolved();
-       t_vector_copy();
+       //file ./t.Stack.c :
+       t_stack_clear();
+       t_stack_size();
+       t_stack_push_pop_basic();
+       t_stack_push_pop_evolved();
+       t_stack_copy();
 
-       //file ./t.BufferTop.c :
-       t_buffertop_clear();
-       t_buffertop_size();
-       t_buffertop_push_pop_basic();
-       t_buffertop_push_pop_evolved();
-       t_buffertop_copy();
+       //file ./t.List.c :
+       t_list_clear();
+       t_list_size();
+       t_list_push_pop_basic();
+       t_list_push_pop_evolved();
+       t_list_copy();
 
        //file ./t.Tree.c :
        t_tree_clear();
@@ -23,19 +23,12 @@ int main(int argc, char** argv)
        t_tree_iterate();
        t_tree_copy();
 
-       //file ./t.Heap.c :
-       t_heap_clear();
-       t_heap_size();
-       t_heap_push_pop_basic();
-       t_heap_push_pop_evolved();
-       t_heap_copy();
-
-       //file ./t.List.c :
-       t_list_clear();
-       t_list_size();
-       t_list_push_pop_basic();
-       t_list_push_pop_evolved();
-       t_list_copy();
+       //file ./t.Vector.c :
+       t_vector_clear();
+       t_vector_size();
+       t_vector_push_pop_basic();
+       t_vector_push_pop_evolved();
+       t_vector_copy();
 
        //file ./t.Queue.c :
        t_queue_clear();
@@ -44,12 +37,19 @@ int main(int argc, char** argv)
        t_queue_push_pop_evolved();
        t_queue_copy();
 
-       //file ./t.Stack.c :
-       t_stack_clear();
-       t_stack_size();
-       t_stack_push_pop_basic();
-       t_stack_push_pop_evolved();
-       t_stack_copy();
+       //file ./t.Heap.c :
+       t_heap_clear();
+       t_heap_size();
+       t_heap_push_pop_basic();
+       t_heap_push_pop_evolved();
+       t_heap_copy();
+
+       //file ./t.BufferTop.c :
+       t_buffertop_clear();
+       t_buffertop_size();
+       t_buffertop_push_pop_basic();
+       t_buffertop_push_pop_evolved();
+       t_buffertop_copy();
 
        //file ./t.PriorityQueue.c :
        t_priorityqueue_clear();
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/test/obj/.gitkeep b/test/obj/.gitkeep
new file mode 100644 (file)
index 0000000..e69de29
index 17492c6..42b31c9 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "cgds/BufferTop.h"
-#include "test/helpers.h"
-#include "test/lut.h"
+#include "helpers.h"
+#include "lut.h"
 
 void t_buffertop_clear()
 {
index e3d6bbc..b01f835 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "cgds/Heap.h"
-#include "test/helpers.h"
-#include "test/lut.h"
+#include "helpers.h"
+#include "lut.h"
 
 void t_heap_clear()
 {
index 51a83b3..83db68f 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "cgds/List.h"
-#include "test/helpers.h"
-#include "test/lut.h"
+#include "helpers.h"
+#include "lut.h"
 
 void t_list_clear()
 {
index 66417e5..e5c3bae 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "cgds/PriorityQueue.h"
-#include "test/helpers.h"
-#include "test/lut.h"
+#include "helpers.h"
+#include "lut.h"
 
 void t_priorityqueue_clear()
 {
index bf095c7..a393da2 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "cgds/Queue.h"
-#include "test/helpers.h"
-#include "test/lut.h"
+#include "helpers.h"
+#include "lut.h"
 
 void t_queue_clear()
 {
index 5b99b4f..ba53e9f 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "cgds/Stack.h"
-#include "test/helpers.h"
-#include "test/lut.h"
+#include "helpers.h"
+#include "lut.h"
 
 void t_stack_clear()
 {
index 131ba15..3bbf00a 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "cgds/Tree.h"
-#include "test/helpers.h"
-#include "test/lut.h"
+#include "helpers.h"
+#include "lut.h"
 
 void t_tree_clear()
 {
index 8eb32bd..6cae626 100644 (file)
@@ -1,7 +1,7 @@
 #include <stdlib.h>
 #include "cgds/Vector.h"
-#include "test/helpers.h"
-#include "test/lut.h"
+#include "helpers.h"
+#include "lut.h"
 
 void t_vector_clear()
 {