diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ef37426 --- /dev/null +++ b/Makefile @@ -0,0 +1,45 @@ +.PHONY: server client shared install + +# > configuration start + +lib_name := som_net + +CC = gcc +CFLAGS = -I. -g -Wall -Werror -Wextra +LD_FLAGS = -L. + +# < configuration end + +.SOURCES := $(wildcard $(MAKECMDGOALS)/*.c) +.OBJECTS := $(patsubst $(MAKECMDGOALS)/%.c,$(MAKECMDGOALS)/%.o,$(.SOURCES)) + +SHARED_LD = -shared -fPIC +CLIENT_LD = -l${lib_name} +SERVER_LD = -l${lib_name} + +export LD_LIBRARY_PATH:=`pwd` +# help text +default: + @echo " make targets: shared, client, server, [install >WIP<]" + @echo " *shared is required for all targets!" + +# target: client +client: .client_comp +.client_comp: $(.OBJECTS) + $(CC) ${LD_FLAGS} ${CFLAGS} -o client_example ${.OBJECTS} ${CLIENT_LD} + +# target: server +server: .server_comp +.server_comp: $(.OBJECTS) + $(CC) ${LD_FLAGS} ${CFLAGS} -o server_example ${.OBJECTS} ${SERVER_LD} + +# target: shared +shared: .shared_comp +.shared_comp: $(.OBJECTS) + $(CC) ${LD_FLAGS} ${SHARED_LD} ${CFLAGS} -o lib${lib_name}.so ${.OBJECTS} + +clean: + rm -f $(wildcard ./**/*.o) client_example server_example lib${lib_name}.so + +**/%.o: **/%.c + $(CC) -c -o $@ $< |