|
| 1 | +# A generic buildfiles to build single executable directory projects depending |
| 2 | +# only on pkg-config ability to build. It automatically names the project on |
| 3 | +# the toplevel directory you're in. |
| 4 | +# |
| 5 | +# Setting additional CFLAGS like $ export CFLAGS=-Wall -Werror # can help you |
| 6 | +# track issues down better after compilation. |
| 7 | +# |
| 8 | +# 20071008 |
| 9 | +# Øyvind Kolås (c) 2007 <pippin@gimp.org> placed in the Public Domain. |
| 10 | +## |
| 11 | + |
| 12 | +PKGMODULES = clutter-1.0 |
| 13 | + |
| 14 | +# you only need to change the following if you want to change where the |
| 15 | +# generated tarball gets scp'd to: |
| 16 | + |
| 17 | +SCP_DESTINATION= |
| 18 | + |
| 19 | +BINARY=$(shell basename `pwd`)# |
| 20 | +PACKAGE=../$(BINARY).tar.bz2 # you can use both .gz and .bz2 as extension here |
| 21 | + |
| 22 | + |
| 23 | +## |
| 24 | +# end of template configuration. |
| 25 | +# |
| 26 | + |
| 27 | +# This makefile uses the current directory as the only target binary, and |
| 28 | +# expects a single of the .c files to contain a main function. |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +all: $(BINARY) |
| 33 | + |
| 34 | +# The help available also contains brief information about the different |
| 35 | +# build rules supported. |
| 36 | +help: |
| 37 | + @echo '' |
| 38 | + @echo 'Available targets in this make system' |
| 39 | + @echo '' |
| 40 | + @echo ' (none) builds $(BINARY)' |
| 41 | + @echo ' dist create $(PACKAGE)' |
| 42 | + @echo ' clean rm *.o *~ and foo and bar' |
| 43 | + @echo ' run ./$(BINARY)' |
| 44 | + @echo ' gdb gdb ./$(BINARY)' |
| 45 | + @echo ' gdb2 gdb ./$(BINARY) --g-fatal-warnings' |
| 46 | + @echo ' scp scp $(PACKAGE) $(SCP_DESTINATION)' |
| 47 | + @echo ' help this help' |
| 48 | + @echo '' |
| 49 | + |
| 50 | + |
| 51 | +LIBS= $(shell pkg-config --libs $(PKGMODULES)) |
| 52 | +INCS= $(shell pkg-config --cflags $(PKGMODULES)) |
| 53 | + |
| 54 | +CFLAGS+=-Wall |
| 55 | +CFILES = $(wildcard *.c) |
| 56 | +OBJECTS = $(subst ./,,$(CFILES:.c=.o)) |
| 57 | +HFILES = $(wildcard *.h) |
| 58 | +%.o: %.c $(HFILES) |
| 59 | + $(CC) -g $(CFLAGS) $(INCS) -c $< -o$@ |
| 60 | +$(BINARY): $(OBJECTS) |
| 61 | + $(CC) -o $@ $(LIBS) $(OBJECTS) |
| 62 | +test: run |
| 63 | +run: $(BINARY) |
| 64 | + ./$(BINARY) |
| 65 | + |
| 66 | +../$(BINARY).tar.gz: clean $(CFILES) $(HFILES) |
| 67 | + cd ..;tar czvhf $(BINARY).tar.gz $(BINARY)/* |
| 68 | + @ls -slah ../$(BINARY).tar.gz |
| 69 | +../$(BINARY).tar.bz2: clean $(CFILES) $(HFILES) |
| 70 | + cd ..;tar cjvhf $(BINARY).tar.bz2 $(BINARY)/* |
| 71 | + @ls -slah ../$(BINARY).tar.bz2 |
| 72 | + |
| 73 | +dist: $(PACKAGE) |
| 74 | + echo $(PACKAGE) |
| 75 | +scp: dist |
| 76 | + scp $(PACKAGE) $(SCP_DESTINATION) |
| 77 | + |
| 78 | +gdb: all |
| 79 | + gdb --args ./$(BINARY) |
| 80 | +gdb2: all |
| 81 | + gdb --args ./$(BINARY) -demo --g-fatal-warnings |
| 82 | +clean: |
| 83 | + rm -fvr *.o $(BINARY) *~ *.patch |
0 commit comments