| 1 | #Copyright (C) 2007 L. Donnie Smith |
|---|
| 2 | |
|---|
| 3 | HEADER = $(LIB_NAME).h |
|---|
| 4 | STATIC_LIB = lib$(LIB_NAME).a |
|---|
| 5 | LINK_NAME = lib$(LIB_NAME).so |
|---|
| 6 | SO_NAME = $(LINK_NAME).$(MAJOR_VER) |
|---|
| 7 | SHARED_LIB = $(SO_NAME).$(MINOR_VER) |
|---|
| 8 | |
|---|
| 9 | OBJECTS = $(SOURCES:.c=.o) |
|---|
| 10 | DEPS = $(SOURCES:.c=.d) |
|---|
| 11 | |
|---|
| 12 | CFLAGS += -fpic |
|---|
| 13 | |
|---|
| 14 | all: static shared |
|---|
| 15 | |
|---|
| 16 | static: $(STATIC_LIB) |
|---|
| 17 | |
|---|
| 18 | shared: $(SHARED_LIB) |
|---|
| 19 | |
|---|
| 20 | $(STATIC_LIB): $(OBJECTS) |
|---|
| 21 | ar rcs $(STATIC_LIB) $(OBJECTS) |
|---|
| 22 | |
|---|
| 23 | $(SHARED_LIB): $(OBJECTS) |
|---|
| 24 | $(CC) -shared -Wl,-soname,$(SO_NAME) $(LDFLAGS) $(LDLIBS) \ |
|---|
| 25 | -o $(SHARED_LIB) $(OBJECTS) |
|---|
| 26 | |
|---|
| 27 | install: install_header install_static install_shared |
|---|
| 28 | |
|---|
| 29 | install_header: $(INC_INST_DIR) |
|---|
| 30 | install $(LIB_NAME).h $(INC_INST_DIR) |
|---|
| 31 | |
|---|
| 32 | $(INC_INST_DIR): |
|---|
| 33 | install -d $(INC_INST_DIR) |
|---|
| 34 | |
|---|
| 35 | install_static: static $(LIB_INST_DIR) |
|---|
| 36 | install $(STATIC_LIB) $(LIB_INST_DIR) |
|---|
| 37 | |
|---|
| 38 | install_shared: shared $(LIB_INST_DIR) |
|---|
| 39 | install $(SHARED_LIB) $(LIB_INST_DIR) |
|---|
| 40 | ln -sf $(SHARED_LIB) $(LIB_INST_DIR)/$(SO_NAME) |
|---|
| 41 | ln -sf $(SO_NAME) $(LIB_INST_DIR)/$(LINK_NAME) |
|---|
| 42 | @LDCONFIG@ |
|---|
| 43 | |
|---|
| 44 | $(LIB_INST_DIR): |
|---|
| 45 | install -d $(LIB_INST_DIR) |
|---|
| 46 | |
|---|
| 47 | clean: |
|---|
| 48 | rm -f $(STATIC_LIB) $(SHARED_LIB) $(OBJECTS) $(DEPS) |
|---|
| 49 | |
|---|
| 50 | uninstall: |
|---|
| 51 | rm -f $(INC_INST_DIR)/$(LIB_NAME).h $(LIB_INST_DIR)/$(STATIC_LIB) \ |
|---|
| 52 | $(LIB_INST_DIR)/$(LINK_NAME)* |
|---|
| 53 | |
|---|
| 54 | ifneq ($(MAKECMDGOALS),clean) |
|---|
| 55 | ifneq ($(MAKECMDGOALS),distclean) |
|---|
| 56 | include $(COMMON)/include/dep.mak |
|---|
| 57 | -include $(DEPS) |
|---|
| 58 | endif |
|---|
| 59 | endif |
|---|
| 60 | |
|---|
| 61 | .PHONY: all static shared install install_header install_static install_shared clean uninstall |
|---|