mirror of
https://gitlab.com/klmp200/LO27.git
synced 2024-11-19 18:33:20 +00:00
Add true makefile + lists
This commit is contained in:
parent
30e9c36b2d
commit
77491c8e61
BIN
CellElemFunc.o
BIN
CellElemFunc.o
Binary file not shown.
27
LibCell/Makefile
Normal file
27
LibCell/Makefile
Normal file
@ -0,0 +1,27 @@
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -Werror -pedantic -fpic -g
|
||||
|
||||
|
||||
LIBSDIR=-L/usr/lib -L../Libs
|
||||
INCLUDEDIR=-I/usr/include -I.
|
||||
|
||||
#Library variables
|
||||
LIBTARGET=libCellElement.so
|
||||
LIBSOURCE=CellElement
|
||||
LIBSOURCECFILE=$(LIBSOURCE:=.c)
|
||||
LIBSOURCEOFILE=$(LIBSOURCE:=.o)
|
||||
|
||||
#Generating the library binary
|
||||
$(LIBTARGET): $(LIBSOURCEOFILE)
|
||||
@echo "\n Generating the library binary"
|
||||
$(CC) $(CFLAGS) -shared $(LIBSOURCEOFILE) -o ../Libs/$(LIBTARGET)
|
||||
|
||||
#Generating object files
|
||||
.c.o:
|
||||
@echo "\n Generating " $@ " from " $<
|
||||
$(CC) $(CFLAGS) $(INCLUDEDIR) -c -o $@ $<
|
||||
|
||||
#Cleaning
|
||||
clean:
|
||||
@echo "\n Cleaning"
|
||||
rm -rf *.o *.exe *.so
|
@ -7,24 +7,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <CellElement.h>
|
||||
|
||||
int main(int argc, char **argv){
|
||||
cellElement * tree = NULL;
|
||||
tree = CreateCellElem();
|
||||
tree->colIndex = 1;
|
||||
AddNextRow(tree);
|
||||
tree->nextRow->colIndex = 2;
|
||||
AddNextCol(tree);
|
||||
tree->nextCol->colIndex = 3;
|
||||
recursivePrint(tree);
|
||||
removeNextRow(tree);
|
||||
removeNextCol(tree);
|
||||
|
||||
recursivePrint(tree);
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
cellElement * CreateCellElem(){
|
||||
cellElement * elem = NULL;
|
||||
@ -136,3 +118,9 @@ void recursivePrint(cellElement * tree){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void FreeCellElement(cellElement* element) {
|
||||
if (element != NULL){
|
||||
free(element);
|
||||
}
|
||||
}
|
@ -47,7 +47,8 @@ int AddNextRow(cellElement* tree);
|
||||
|
||||
void removeNextCol(cellElement* list);
|
||||
void removeNextRow(cellElement* list);
|
||||
|
||||
void recursivePrint(cellElement * tree);
|
||||
|
||||
void FreeCellElement(cellElement* element);
|
||||
|
||||
#endif
|
29
LibList/Makefile
Normal file
29
LibList/Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -Werror -pedantic -fpic -g
|
||||
|
||||
|
||||
LIBSDIR=-L/usr/lib -L../Libs
|
||||
INCLUDEDIR=-I/usr/include -I.
|
||||
|
||||
#Library variables
|
||||
LIBTARGET=libList.so
|
||||
LIBSOURCE=list CellElement
|
||||
LIBSOURCECFILE=$(LIBSOURCE:=.c)
|
||||
LIBSOURCEOFILE=$(LIBSOURCE:=.o)
|
||||
|
||||
#Generating the library binary
|
||||
$(LIBTARGET): $(LIBSOURCEOFILE)
|
||||
@echo "\n Generating the library binary"
|
||||
$(CC) $(CFLAGS) -shared $(LIBSOURCEOFILE) -o ../Libs/$(LIBTARGET)
|
||||
|
||||
#Generating object files
|
||||
.c.o:
|
||||
@echo "\n Generating " $@ " from " $<
|
||||
$(CC) $(CFLAGS) $(INCLUDEDIR) -c -o $@ $<
|
||||
|
||||
#Cleaning
|
||||
clean:
|
||||
@echo "\n Cleaning"
|
||||
rm -rf *.o *.exe *.so
|
||||
|
||||
|
99
LibList/list.h
Normal file
99
LibList/list.h
Normal file
@ -0,0 +1,99 @@
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
#include <CellElement.h>
|
||||
|
||||
#define SUCCESS 0
|
||||
#define FAILURE 1
|
||||
|
||||
typedef struct ListElement ListElement;
|
||||
struct ListElement {
|
||||
void *data;
|
||||
ListElement *next;
|
||||
ListElement *previous;
|
||||
};
|
||||
|
||||
typedef struct List {
|
||||
ListElement *head;
|
||||
ListElement *tail;
|
||||
int size;
|
||||
} List;
|
||||
|
||||
/*
|
||||
* Create a new list
|
||||
* @return a pointer of list
|
||||
*/
|
||||
List * CreateList();
|
||||
|
||||
/*
|
||||
* Insert an element at the begining of a list
|
||||
* @param list pointer of a list
|
||||
* @param data any type of data
|
||||
* @param size size of the data
|
||||
* @return status of the operation
|
||||
*/
|
||||
int unshift(List* list, cellElement* data);
|
||||
|
||||
/*
|
||||
* Insert an element at the end of a list
|
||||
* @param list pointer of a list
|
||||
* @param data any type of data
|
||||
* @param size size of the data
|
||||
* @return status of the operation
|
||||
*/
|
||||
int push(List* list, cellElement* data);
|
||||
|
||||
/*
|
||||
* Get an element in a given list
|
||||
* @param list as a pointer
|
||||
* @param nb the number of the element (can be negative)
|
||||
* @return an element
|
||||
*/
|
||||
ListElement * GetElement(List *list, int nb);
|
||||
|
||||
/*
|
||||
* Delete an element with a pointer of element in the list
|
||||
* @param list as a pointer
|
||||
* @param element of the list as a pointer
|
||||
* @return status of the operation
|
||||
*/
|
||||
int PopPtnList(List *list, ListElement *element);
|
||||
|
||||
/*
|
||||
* Delete an element with a position in the list
|
||||
* @param list as a pointer
|
||||
* @param position of the element
|
||||
* @return status of the operation
|
||||
*/
|
||||
int RemoveElement(List *list, int nb);
|
||||
|
||||
/*
|
||||
* Delete the first element of the list
|
||||
* @param list as a pointer
|
||||
* @return status of the operation
|
||||
*/
|
||||
int shift(List *list);
|
||||
|
||||
/*
|
||||
* Delete the last element of the list
|
||||
* @param list as a pointer
|
||||
* @return status of the operation
|
||||
*/
|
||||
int pop(List *list);
|
||||
|
||||
/*
|
||||
* Delete every elements in a list
|
||||
* @param list as a pointer
|
||||
* @return status of the operation
|
||||
*/
|
||||
int DeleteListContent(List *list);
|
||||
|
||||
|
||||
/*
|
||||
* Free a list
|
||||
* @param list as a pointer
|
||||
* @return status of the operation
|
||||
*/
|
||||
int FreeList(List *list);
|
||||
|
||||
#endif /* LIST_H */
|
68
Makefile
68
Makefile
@ -1,21 +1,57 @@
|
||||
CXX = gcc
|
||||
TARGET = Exe
|
||||
SOURCEFILE = CellElemFunc
|
||||
CFLAGS = -Wall -Werror -ansi -pedantic -fpic -I. -g
|
||||
# Makefile compiling the whole project
|
||||
# Don't forget before the first compilation to run that command:
|
||||
# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:./Libs
|
||||
|
||||
#Generating the executable
|
||||
$(TARGET): $(SOURCEFILE).o
|
||||
@echo "Generating the executable" $@
|
||||
$(CXX) $(CFLAGS) $(SOURCEFILE).o -o $@
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -Werror -pedantic -fpic -g
|
||||
|
||||
$(SOURCEFILE).o:
|
||||
@echo "Generating objectfiles" $@
|
||||
$(CXX) $(CFLAGS) -c $(SOURCEFILE).c -o $@
|
||||
|
||||
#Cleaning the executable
|
||||
LIBSDIR=-L/usr/lib -L./Libs
|
||||
INCLUDEDIR=-I/usr/include -I. -I./LibCell -I./LibList
|
||||
|
||||
#Exe test variables
|
||||
TARGET=main.exe
|
||||
SOURCE=main
|
||||
|
||||
SOURCECFILE=$(SOURCE:=.c)
|
||||
SOURCEOFILE=$(SOURCE:=.o)
|
||||
|
||||
#Library variables
|
||||
DEPENDENCE=libCellElement.so
|
||||
DEPENDENCENAME=CellElement
|
||||
|
||||
DEPENDENCELIST=libList.so
|
||||
DEPENDENCENAMELIST=List
|
||||
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
#Generating the main.exe
|
||||
$(TARGET): $(SOURCEOFILE) $(DEPENDENCELIST) lib
|
||||
@echo "\n Generating the " $(TARGET) " binary"
|
||||
$(CC) $(SOURCEOFILE) $(LIBSDIR) -l$(DEPENDENCENAME) -l$(DEPENDENCENAMELIST) -o $(TARGET)
|
||||
|
||||
#Generating the library binary
|
||||
lib:
|
||||
@echo "\n Generating the automaton library binary"
|
||||
mkdir -p Libs
|
||||
$(MAKE) -C LibCell
|
||||
|
||||
$(DEPENDENCELIST):
|
||||
@echo "\n Generating the list library binary"
|
||||
$(MAKE) -C LibList
|
||||
|
||||
|
||||
#Generating object files
|
||||
.c.o:
|
||||
@echo "\n Generating " $@ " from " $<
|
||||
$(CC) $(CFLAGS) $(INCLUDEDIR) -c -o $@ $<
|
||||
|
||||
|
||||
#Cleaning
|
||||
clean:
|
||||
@echo "Cleaning temporary files"
|
||||
rm -rf *.o *- *.so $(TARGET)
|
||||
|
||||
|
||||
@echo "\n Cleaning"
|
||||
rm -rf *.o ./Libs/*.so *.exe
|
||||
$(MAKE) -C LibCell clean
|
||||
$(MAKE) -C LibList clean
|
||||
|
||||
|
28
main.c
Normal file
28
main.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*********************************************************************************
|
||||
* File Name : main.c
|
||||
* Created By : klmp200
|
||||
* Creation Date : [2016-12-10 01:06]
|
||||
* Last Modified : [2016-12-10 01:07]
|
||||
* Description :
|
||||
**********************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <CellElement.h>
|
||||
|
||||
int main(int argc, char **argv){
|
||||
cellElement * tree = NULL;
|
||||
tree = CreateCellElem();
|
||||
tree->colIndex = 1;
|
||||
AddNextRow(tree);
|
||||
tree->nextRow->colIndex = 2;
|
||||
AddNextCol(tree);
|
||||
tree->nextCol->colIndex = 3;
|
||||
recursivePrint(tree);
|
||||
removeNextRow(tree);
|
||||
removeNextCol(tree);
|
||||
recursivePrint(tree);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user