summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2016-06-04 19:58:41 -0400
committerJesse Luehrs <doy@tozt.net>2016-06-04 19:58:41 -0400
commit08bc395716446d5ca94b7e87fc59b5d3398609cb (patch)
tree904061b3d8ba6c963cf4ab28f459a873751506fc
parentbd9fc2ba0396f04df399c1f685aacced84128518 (diff)
downloadlibvt100-08bc395716446d5ca94b7e87fc59b5d3398609cb.tar.gz
libvt100-08bc395716446d5ca94b7e87fc59b5d3398609cb.zip
add a makefile target for examples
-rw-r--r--Makefile9
-rw-r--r--examples/test1.c7
2 files changed, 14 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index ec99c92..8c4d341 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,8 @@ OUT = libvt100.so
SOUT = libvt100.a
BUILD = build/
SRC = src/
+EXDIR = examples/
+EXAMPLES = $(EXDIR)test1
OBJ = $(BUILD)parser.o \
$(BUILD)screen.o \
$(BUILD)unicode-extra.o
@@ -28,6 +30,8 @@ dynamic: $(OUT) ## Build a dynamic library
static: $(SOUT) ## Build a static library
+examples: $(EXAMPLES) ## Build the example programs
+
$(OUT): $(OBJ)
$(QUIET_LD)$(CC) -fPIC -shared -o $@ $^ $(ALLLDFLAGS)
@@ -38,6 +42,9 @@ $(BUILD)%.o: $(SRC)%.c | $(BUILD)
@$(MAKEDEPEND) -o $(<:$(SRC)%.c=$(BUILD).%.d) $<
$(QUIET_CC)$(CC) $(ALLCFLAGS) -c -fPIC -o $@ $<
+$(EXDIR)%: $(EXDIR)%.c $(SOUT)
+ $(QUIET_CC)$(CC) $(ALLCFLAGS) $(ALLLDFLAGS) -I src -o $@ $^
+
$(BUILD):
@mkdir -p $(BUILD)
@@ -50,7 +57,7 @@ $(SRC)%.h: $(SRC)%.l
$(QUIET_LEX)$(LEX) --header-file=$(<:.l=.h) -o /dev/null $<
clean: ## Remove build files
- rm -f $(OUT) $(SOUT) $(OBJ) $(OBJ:$(BUILD)%.o=$(BUILD).%.d)
+ rm -f $(OUT) $(SOUT) $(OBJ) $(OBJ:$(BUILD)%.o=$(BUILD).%.d) $(EXAMPLES)
@rmdir -p $(BUILD) > /dev/null 2>&1 || true
help: ## Display this help
diff --git a/examples/test1.c b/examples/test1.c
index 906fe5a..849a41e 100644
--- a/examples/test1.c
+++ b/examples/test1.c
@@ -4,6 +4,8 @@
#include "vt100.h"
+#define UNUSED(x) ((void)x)
+
int main(int argc, char *argv[])
{
VT100Screen *vt;
@@ -11,6 +13,9 @@ int main(int argc, char *argv[])
size_t offset = 0;
int i, j, skip;
+ UNUSED(argc);
+ UNUSED(argv);
+
vt = vt100_screen_new(24, 80);
// vt100_screen_set_window_size(vt);
@@ -36,7 +41,7 @@ int main(int argc, char *argv[])
continue;
}
struct vt100_cell *cell = &vt->grid->rows[i].cells[j];
- printf("%*s", cell->len, cell->contents);
+ printf("%*s", (int)cell->len, cell->contents);
if (cell->is_wide)
skip = 1;
}