libxputty 0.1
Loading...
Searching...
No Matches
Makefile

Simple example of how to build this

# usually those variables been set by Makefile.base
# in case we run from this directory, we do a minimal setup
# assume we build for Linux
ifndef MKBASE
ECHO = @echo
B_ECHO = @echo
R_ECHO = @echo
PKGCONFIG = pkg-config
STATIC_LIB_EXT = a
XELF = x11
endif
# include path to link with libxputty static files and headers
LIB_DIR := ../libxputty/
HEADER_DIR := $(LIB_DIR)include/
# include path for library headers
INCLUDES := -I. -I$(HEADER_DIR)
# link flags to dynamic link cairo and X11 (default)
# or, when build for Windows, using the needed flags
LDFLAGS += -fPIC `$(PKGCONFIG) $(PKGCONFIG_FLAGS) --cflags --libs cairo $(XELF)` -lm \
$(PAWPAW_LFLAGS)
# debug flags, use this to debug a problem with libxputty
DEBUG_LDFLAGS += -g -D DEBUG -DLIBDEBUG
# collect the files to build
EXAMPLE_SOURCES := $(wildcard *.c)
EXAMPLE_OBJ := $(patsubst %.c,%.o,$(EXAMPLE_SOURCES))
EXEC_FILES := $(patsubst %.c,%,$(EXAMPLE_SOURCES))
WEXEC_FILES := $(patsubst %, %.exe,$(EXEC_FILES))
# if build for Windows add the file extension
ifeq ($(TARGET), Windows)
EXEC_FILES := $(patsubst %, %$(EXE_EXT),$(EXEC_FILES))
endif
.PHONY : all clean
all: done
debug: LDFLAGS += $(DEBUG_LDFLAGS)
debug: all
clean:
ifndef EXTRAQUIET
@$(ECHO) "Clean up $(reset)"
endif
$(QUIET)rm -f $(EXAMPLE_OBJ) $(EXEC_FILES) $(WEXEC_FILES)
# check if libxputty include files been available
$(HEADER_DIR)*.h:
@$(R_ECHO)You need to build libxputty before build the examples!!$(reset)
exit 1
# build the object files
$(EXAMPLE_OBJ): $(EXAMPLE_SOURCES) $(HEADER_DIR)*.h
@$(ECHO) "Building object file $@ $(reset)"
$(QUIET)$(CC) -c $(patsubst %.o,%.c,$@) -o $@ $(INCLUDES) $(LDFLAGS)
# build the binaries
$(EXEC_FILES): $(EXAMPLE_OBJ)
@$(B_ECHO) "Compiling $@ $(reset)"
$(QUIET)$(CC) -Wall $(CFLAGS) $(patsubst %$(EXE_EXT),%.c,$@) -L. $(LIB_DIR)libxputty.$(STATIC_LIB_EXT) -o $@ $(INCLUDES) $(LDFLAGS)
done: $(EXEC_FILES)
@$(B_ECHO) "=================== DONE =======================$(reset)"
doc: