edid-decode: Rewrite build to accept multiple jobs
[edid-decode.git] / Makefile
blobdc597f024f28a750e783e7e3515de384706e12f6
1 ifeq ($(OS),Windows_NT)
2 bindir ?= /usr/bin
3 mandir ?= /usr/share/man
4 else
5 UNAME_S := $(shell uname -s)
6 ifeq ($(UNAME_S),Darwin)
7 bindir ?= /usr/local/sbin
8 mandir ?= /usr/local/share/man
9 else
10 bindir ?= /usr/bin
11 mandir ?= /usr/share/man
12 endif
13 endif
15 EMXX ?= em++
17 SOURCES = $(wildcard *.cpp)
18 OBJECTS := $(patsubst %.cpp, _build/%.o, $(SOURCES))
20 WARN_FLAGS = -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Wimplicit-fallthrough
22 all: edid-decode
24 sha = -DSHA=$(shell if test -d .git ; then git rev-parse --short=12 HEAD ; fi)
25 date = -DDATE=$(shell if test -d .git ; then TZ=UTC git show --quiet --date='format-local:"%F %T"' --format='%cd'; fi)
27 edid-decode: makebuilddir $(OBJECTS) edid-decode.h oui.h Makefile
28 $(CXX) $(LDFLAGS) $(WARN_FLAGS) -g $(sha) $(date) -o $@ $(OBJECTS) -lm
30 edid-decode.js: $(SOURCES) edid-decode.h oui.h Makefile
31 $(EMXX) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(WARN_FLAGS) $(sha) $(date) -s EXPORTED_FUNCTIONS='["_parse_edid"]' -s EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -o $@ $(SOURCES) -lm
33 _build/%.o: %.cpp
34 $(CXX) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(WARN_FLAGS) -g $(sha) $(date) -o $@ -c $<
36 makebuilddir:
37 mkdir -p _build
39 clean:
40 rm -rf _build
41 rm -f edid-decode edid-decode.js edid-decode.wasm
43 install:
44 mkdir -p $(DESTDIR)$(bindir)
45 install -m 0755 edid-decode $(DESTDIR)$(bindir)
46 mkdir -p $(DESTDIR)$(mandir)/man1
47 install -m 0644 edid-decode.1 $(DESTDIR)$(mandir)/man1