From 9130887d03b43d4ee6ff88f84d84146dece33c08 Mon Sep 17 00:00:00 2001 From: "Begerad, Stefan" Date: Thu, 5 Jan 2023 12:14:52 +0100 Subject: [PATCH] feat: add lib-version --- lib-version/main.c | 9 +++++++++ lib-version/makefile | 21 ++++++++++++++++++++ lib-version/makefile-fail | 39 +++++++++++++++++++++++++++++++++++++ lib-version/makefile-fail-2 | 21 ++++++++++++++++++++ lib-version/makefile-fine | 21 ++++++++++++++++++++ lib-version/readme.md | 5 +++++ 6 files changed, 116 insertions(+) create mode 100644 lib-version/main.c create mode 100644 lib-version/makefile create mode 100644 lib-version/makefile-fail create mode 100644 lib-version/makefile-fail-2 create mode 100644 lib-version/makefile-fine create mode 100644 lib-version/readme.md diff --git a/lib-version/main.c b/lib-version/main.c new file mode 100644 index 0000000..9e88959 --- /dev/null +++ b/lib-version/main.c @@ -0,0 +1,9 @@ +#include +#include +int main() { + int lib_ver = PQlibVersion(); + printf("Version of libpq: %d\n", lib_ver); + printf("Version of libpq: %d\n", lib_ver); + printf("Version of libpq: %d\n", lib_ver); + return 0; +} diff --git a/lib-version/makefile b/lib-version/makefile new file mode 100644 index 0000000..616581c --- /dev/null +++ b/lib-version/makefile @@ -0,0 +1,21 @@ +# Docu +# +#$@ is the name of the file to be made +#$? is the names of the changed dependents +#$< the name of the related file that caused the action +#$* the prefix shared by target and dependent files +# +# Others +RM = /bin/rm -f +# +# Source, Executable, Includes, Library Defines +EXE = main +# +# Compiler, Linker Defines +CC = /usr/bin/gcc +# +all: + $(CC) main.c -I/usr/include/postgresql -L/usr/lib/x86_64-linux-gnu -lpq -std=c99 -Wall -o $(EXE) +# Clean Up Objects, Exectuables, Dumps out of source directory +clean: + $(RM) *.o $(EXE) *~ diff --git a/lib-version/makefile-fail b/lib-version/makefile-fail new file mode 100644 index 0000000..86a6c54 --- /dev/null +++ b/lib-version/makefile-fail @@ -0,0 +1,39 @@ +# Docu +# +#$@ is the name of the file to be made +#$? is the names of the changed dependents +#$< the name of the related file that caused the action +#$* the prefix shared by target and dependent files +# +#CFLAGS:Extra flags to give to the C compiler +#LDFLAGS:Extra flags to give to compilers when they are supposed to invoke the linker, `ld'. +# +# Source, Executable, Includes, Library Defines +INCL = +SRC = main.c +OBJ = $(SRC:.c=.o) +LIBS = -lpq +EXE = main +INC = -I. -I$(pg_config --includedir) + +# Compiler, Linker Defines +CC = /usr/bin/gcc +CFLAGS = -std=c99 -Wall +LIBPATH = -L. -L$(pg_config --libdir) +LDFLAGS = -o $(EXE) $(LIBPATH) $(LIBS) +RM = /bin/rm -f + +# Compile and Assemble C Source Files into Object Files +%.o: %.c + $(CC) $(INC) $(CFLAGS) -c $*.c + +# Link all Object Files with external Libraries into Binaries +$(EXE): $(OBJ) + $(CC) $(LDFLAGS) $(OBJ) + +# Objects depend on these Libraries +$(OBJ): $(INCL) + +# Clean Up Objects, Exectuables, Dumps out of source directory +clean: + $(RM) $(OBJ) $(EXE) diff --git a/lib-version/makefile-fail-2 b/lib-version/makefile-fail-2 new file mode 100644 index 0000000..4af3a5f --- /dev/null +++ b/lib-version/makefile-fail-2 @@ -0,0 +1,21 @@ +# Docu +# +#$@ is the name of the file to be made +#$? is the names of the changed dependents +#$< the name of the related file that caused the action +#$* the prefix shared by target and dependent files +# +# Others +RM = /bin/rm -f +# +# Source, Executable, Includes, Library Defines +EXE = main +# +# Compiler, Linker Defines +CC = /usr/bin/gcc +# +all: main.o + $(CC) main.c -I/usr/include/postgresql -L/usr/lib/x86_64-linux-gnu -lpq -std=c99 -Wall -o $(EXE) +# Clean Up Objects, Exectuables, Dumps out of source directory +clean: + $(RM) *.o $(EXE) *~ diff --git a/lib-version/makefile-fine b/lib-version/makefile-fine new file mode 100644 index 0000000..616581c --- /dev/null +++ b/lib-version/makefile-fine @@ -0,0 +1,21 @@ +# Docu +# +#$@ is the name of the file to be made +#$? is the names of the changed dependents +#$< the name of the related file that caused the action +#$* the prefix shared by target and dependent files +# +# Others +RM = /bin/rm -f +# +# Source, Executable, Includes, Library Defines +EXE = main +# +# Compiler, Linker Defines +CC = /usr/bin/gcc +# +all: + $(CC) main.c -I/usr/include/postgresql -L/usr/lib/x86_64-linux-gnu -lpq -std=c99 -Wall -o $(EXE) +# Clean Up Objects, Exectuables, Dumps out of source directory +clean: + $(RM) *.o $(EXE) *~ diff --git a/lib-version/readme.md b/lib-version/readme.md new file mode 100644 index 0000000..616a262 --- /dev/null +++ b/lib-version/readme.md @@ -0,0 +1,5 @@ +* build instruction + +``` +gcc -o main main.c -I/usr/include/postgresql -L/usr/lib/x86_64-linux-gnu -lpq -std=c99 +```