Makefile: add shared lib
This commit is contained in:
parent
3fcfdb6720
commit
966a1e12f6
@ -12,7 +12,15 @@ LDLIBS = #$(pkg-config --libs sdl)
|
||||
|
||||
bin = main
|
||||
cxxbin = cxxmain
|
||||
sources = $(wildcard *.c)
|
||||
lib = libexample.so
|
||||
|
||||
#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)
|
||||
$(cxxbin):
|
||||
$(LINK.cc) $^ $(LDLIBS) -o $@
|
||||
|
||||
$(lib): CFLAGS += -fpic
|
||||
$(lib): $(lib_obj)
|
||||
|
||||
%.so:
|
||||
$(LINK.c) -shared $^ $(LDLIBS) -o $@
|
||||
|
||||
.PHONY: clean
|
||||
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)
|
||||
endif
|
||||
|
Loading…
Reference in New Issue
Block a user