Commit 966a1e12 authored by Mathieu Maret's avatar Mathieu Maret

Makefile: add shared lib

parent 3fcfdb67
......@@ -12,7 +12,15 @@ LDLIBS = #$(pkg-config --libs sdl)
bin = main
cxxbin = cxxmain
sources = $(wildcard *.c)
lib =
#Will be compiled with -fpic
lib_src = lib.c
lib_obj = $(lib_src:%.c=%.o)
lib_dep = $(lib_src:%.c=%.d)
$(info $$lib_obj is ${lib_obj})
sources = $(filter-out $(lib_src), $(wildcard *.c))
objects = $(sources:%.c=%.o)
depends = $(sources:%.c=%.d)
......@@ -30,11 +38,18 @@ $(cxxbin) : $(cxx_objects)
$( $^ $(LDLIBS) -o $@
$(lib): CFLAGS += -fpic
$(lib): $(lib_obj)
$(LINK.c) -shared $^ $(LDLIBS) -o $@
.PHONY: clean
$(RM) $(bin) $(objects) $(depends) $(cxxbin) $(cxx_objects) $(cxx_depends)
$(RM) $(bin) $(objects) $(depends) $(cxxbin) $(cxx_objects) $(cxx_depends) $(lib) $(lib_obj) $(lib_dep)
ifneq ($(MAKECMDGOALS),clean)
-include $(depends)
-include $(cxx_depends)
-include $(lib_dep)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment