loaders: JPG: Fix bussy loop on corrupted file.
[gfxprim.git] / lib.mk
blob23b7fcb8c44006b8be321b26534549c169c58b79
2 # Most of the libraries just generate object files that
3 # are later linked in build into the libgfxprim.so
5 ifndef LIBNAME
6 $(error LIBNAME not defined, fix your library Makefile)
7 endif
9 ifeq ($(BUILDLIB),yes)
11 # Rules for single library, applied only when objects
12 # are not linked to the libgfxprim.so. This generates libgfxprim_$(LIBNAME).
14 include $(TOPDIR)/libver.mk
15 include $(TOPDIR)/config.mk
17 LIB_NAME=libgfxprim-$(LIBNAME)
18 BUILD_DIR=$(TOPDIR)/build/
20 STATIC_LIB=$(LIB_NAME).a
21 DYNAMIC_LIB=$(LIB_NAME).so.$(LIB_VERSION).$(LIB_RELEASE)
22 SONAME=$(LIB_NAME).so.$(LIB_MAJOR)
23 SYMLINKS=$(LIB_NAME).so.$(LIB_MAJOR) $(LIB_NAME).so
25 LIBS=$(BUILD_DIR)$(STATIC_LIB) $(BUILD_DIR)$(DYNAMIC_LIB)
27 ALL+=$(LIBS) $(SYMLINKS)
28 CLEAN+=$(LIBS) $(addprefix $(BUILD_DIR),$(SYMLINKS))
31 # OBJECTS are set in post.mk so we need to duplicate the values in
32 # OBJS here too to have correct dependencies
34 OBJS=$(CSOURCES:.c=.o)
36 $(BUILD_DIR)$(DYNAMIC_LIB): $(OBJS)
37 ifdef VERBOSE
38 rm -f $@
39 $(CC) -fPIC --shared -Wl,-soname -Wl,$(SONAME) $(LDLIBS_$(LIBNAME)) $^ -o $@
40 else
41 @rm -f $(@)
42 @echo "LD $@"
43 @$(CC) -fPIC --shared -Wl,-soname -Wl,$(SONAME) $(LDLIBS_$(LIBNAME)) $^ -o $@
44 endif
46 $(BUILD_DIR)$(STATIC_LIB): $(OBJS)
47 ifdef VERBOSE
48 $(AR) rcs $@ $^
49 else
50 @echo "AR $@"
51 @$(AR) rcs $@ $^
52 endif
54 $(SYMLINKS): $(BUILD_DIR)$(DYNAMIC_LIB)
55 ifdef VERBOSE
56 rm -f $(BUILD_DIR)$@
57 cd $(BUILD_DIR) && ln -s $(DYNAMIC_LIB) $@
58 else
59 @echo "LN $@"
60 @rm -f $(BUILD_DIR)$@
61 @cd $(BUILD_DIR) && ln -s $(DYNAMIC_LIB) $@
62 endif
64 else
66 # If we are not executed from the top Makefile, trigger
67 # libGP.so rebuild.
69 ifndef TOP_MAKE
70 ALL+=rebuild_lib
72 rebuild_lib:
73 @$(MAKE) --no-print-directory -C $(TOPDIR)/build/
74 endif
75 endif