diff --git a/Makefile b/Makefile index 56c4860..b983f24 100644 --- a/Makefile +++ b/Makefile @@ -22,4 +22,11 @@ $(DSO_PATH).so.$(DSO_MAJOR).$(DSO_MINOR): $(OBJECTS) ln -sf $(DSO_NAME).so.$(DSO_MAJOR).$(DSO_MINOR) $(DSO_PATH).so.$(DSO_MINOR) ln -sf $(DSO_NAME).so.$(DSO_MAJOR).$(DSO_MINOR) $(DSO_PATH).so +$(BUILD_DIR)/%.o: src/%.c | $(BUILD_DIR) ; $(CC_OBJ) $(BUILD_DIR)/miniz.o: contrib/miniz/miniz.c | $(BUILD_DIR) ; $(CC_OBJ) + +.PHONY: examples +examples: + make -C examples \ + BUILD_DIR=../$(BUILD_DIR)/examples \ + LIB_PATH=../$(BUILD_DIR) diff --git a/common.mk b/common.mk index c56a4ff..10c7ec5 100644 --- a/common.mk +++ b/common.mk @@ -16,6 +16,7 @@ LDFLAGS ?= -flto CFLAGS += -std=gnu11 -D_GNU_SOURCE -Iinc CC_OBJ = $(CC) -c $(CFLAGS) $< -o $@ -MMD -MP -MF $(@:.o=.deps) +LINK_EXE = $(CC) $^ $(LDFLAGS) -o $@ LINK_DSO = $(CC) -fPIC -shared $^ $(LDFLAGS) -o $@ CFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell pkg-config --cflags $(dep))) @@ -23,7 +24,6 @@ LDFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell pkg-config --libs $(dep))) OBJECTS := $(SOURCES:src/%.c=$(BUILD_DIR)/%.o) $(BUILD_DIR): ; mkdir -p $(BUILD_DIR) -$(BUILD_DIR)/%.o: src/%.c | $(BUILD_DIR) ; $(CC_OBJ) .PHONY: clean clean: ; rm -rf $(BUILD_DIR) diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..6fd3bc4 --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,24 @@ +DEPENDENCIES := libpng pixman-1 libuv + +include ../common.mk + +ifdef LIB_PATH +LDFLAGS += -L$(LIB_PATH) -Wl,-rpath=$(shell pwd)/$(LIB_PATH) +endif + +LDFLAGS += -lneatvnc + +all: \ + $(BUILD_DIR)/png-server \ + $(BUILD_DIR)/draw \ + +$(BUILD_DIR)/png-server: $(BUILD_DIR)/png-server.o $(BUILD_DIR)/pngfb.o + $(LINK_EXE) + +$(BUILD_DIR)/draw: $(BUILD_DIR)/draw.o ; $(LINK_EXE) + +$(BUILD_DIR)/%.o: %.c | $(BUILD_DIR) ; $(CC_OBJ) -I../inc + +$(BUILD_DIR)/pngfb.o: ../src/pngfb.c | $(BUILD_DIR) + $(CC_OBJ) -I../inc +