Browse Source

Make way for more examples

Léo Gaspard 8 years ago
parent
commit
40527f7c57
3 changed files with 8 additions and 11 deletions
  1. 1 1
      .gitignore
  2. 7 10
      Makefile
  3. 0 0
      examples/basic.c

+ 1 - 1
.gitignore

@@ -1 +1 @@
-example
+build

+ 7 - 10
Makefile

@@ -2,18 +2,15 @@
 
 include config.mk
 
-SRC = dtext.c test.c
-HDR = dtext.h
+EXECS := $(patsubst examples/%.c,build/%,$(wildcard examples/*.c))
 
-all: example
+all: $(EXECS)
 
-test: example
-	./example
-
-example: config.mk Makefile ${SRC} ${HDR}
-	${CC} ${CFLAGS} ${LDFLAGS} ${SRC} -o example
+build/%: examples/%.c dtext.c dtext.h config.mk Makefile
+	[ -d build ] || mkdir build
+	${CC} -I. ${CFLAGS} ${LDFLAGS} $< dtext.c -o $@
 
 clean:
-	rm -f example
+	rm -f $(EXECS)
 
-.PHONY: all test clean
+.PHONY: all clean

+ 0 - 0
test.c → examples/basic.c