Skip to content

Commit

Permalink
Examples: use auto-generated dependencies in Make example
Browse files Browse the repository at this point in the history
  • Loading branch information
Maratyszcza committed Nov 10, 2015
1 parent 6fb7df1 commit 8b2b554
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ MANIFEST
*.exe
*.s
*.S
*.d

# Example binaries
# Example binaries and generated headers
examples/make/test
examples/make/matmul-opt.h
22 changes: 13 additions & 9 deletions examples/make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ else
PEACHPY_IMAGE_FORMAT=elf
endif

matmul-opt.o: matmul-opt.py
python -m peachpy.x86_64 -mabi=sysv -mimage-format=$(PEACHPY_IMAGE_FORMAT) -mcpu=default -o $@ $<
PEACHPY_SOURCES = matmul-opt.py
C_SOURCES = matmul-ref.c test.c
OBJECTS = $(PEACHPY_SOURCES:.py=.o) $(C_SOURCES:.c=.o)
DEPENDENCIES = $(PEACHPY_SOURCES:.py=.d) $(C_SOURCES:.c=.d)

matmul-ref.o: matmul-ref.c
$(CC) -m64 -std=gnu99 $(CFLAGS) -o $@ -c $<
-include $(DEPENDENCIES)

test.o: test.c
$(CC) -m64 -std=gnu99 $(CFLAGS) -o $@ -c $<
%.o: %.py
python -m peachpy.x86_64 -mabi=sysv -mimage-format=$(PEACHPY_IMAGE_FORMAT) -MMD -MF $(<:.py=.d) -o $(@:.py=.o) $<

test: test.o matmul-ref.o matmul-opt.o
$(CC) -m64 -g $^ -o $@
%.o: %.c
$(CC) -m64 -std=gnu99 $(CFLAGS) -MMD -MF $(<:.c=.d) -o $(@:.c=.o) -c $<

test: $(OBJECTS)
$(CC) -m64 -g $(LDFLAGS) $^ -o $@ $(LDLIBS)

clean:
-rm -f matmul-opt.o matmul-ref.o test.o test
-rm -f $(OBJECTS) $(DEPENDENCIES) test

0 comments on commit 8b2b554

Please sign in to comment.