1 # An interesting trick run a shell command:
2 # GNU Make uses $(shell cmd), whereas
3 # BSD make use $(var:sh), where ${var} holds the command
5 OS ?= $(shell $(OS.exec))$(OS.exec:sh)
26 CFLAGS ?= -g -pedantic -Werror
27 CFLAGS += -std=c99 -Wall -Wextra
30 SPARSEFLAGS=-Wsparse-all -Wno-decl
32 # BSD make does not define RM
35 # Installation paths and modes
37 BINDIR ?= $(PREFIX)/bin
39 MANDIR ?= $(PREFIX)/man
42 # Common library includes
43 LDLIBS = -lOpenCL -ldl
45 # OS-specific library includes
46 LDLIBS_Darwin = -framework OpenCL
47 LDLIBS_Darwin_exclude = -lOpenCL
49 LDLIBS += $(LDLIBS_${OS})
51 # Remove -lOpenCL if OS is Darwin
52 LDLIBS := $(LDLIBS:$(LDLIBS_${OS}_exclude)=)
61 $(PROG).o: $(PROG).c $(HDR)
64 $(RM) $(PROG).o $(PROG)
72 $(BINDIR)/$(PROG): $(PROG) $(BINDIR)
73 install -p -m $(BINMODE) $(PROG) $@
75 $(MANDIR)/$(MAN): $(MAN) $(MANDIR)/man1
76 install -p -m $(MANMODE) $(MAN) $@
78 install: $(BINDIR)/$(PROG) $(MANDIR)/$(MAN)
82 $(SPARSE) $(CPPFLAGS) $(CFLAGS) $(SPARSEFLAGS) $^
85 .PHONY: clean sparse install