INSTALL ?= install
LN ?= ln
-CFLAGS ?= -O2 -pipe
-CXXFLAGS ?= $(CFLAGS)
+CXXFLAGS ?= -std=c++11 -O2 -pipe
LDFLAGS ?=
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man
-SRC := $(wildcard *.c) $(wildcard *.cpp)
+SRC := ldid.cpp
LIBS ?= -lcrypto -lplist-2.0
-all: ldid
+MANPAGE_LANGS := zh_TW zh_CN
-%.c.o: %.c
- $(CC) -c $(CFLAGS) -I. $< -o $@
+all: ldid
%.cpp.o: %.cpp
- $(CXX) -c -std=c++11 $(CXXFLAGS) -I. -DLDID_VERSION=\"$(VERSION)\" $< -o $@
+ $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) -I. -DLDID_VERSION=\"$(VERSION)\" $< -o $@
ldid: $(SRC:%=%.o)
- $(CXX) $^ $(LDFLAGS) $(LIBS) -o ldid
+ $(CXX) $(CXXFLAGS) -o ldid $^ $(LDFLAGS) $(LIBS)
install: all
- $(INSTALL) -D -m755 ldid $(DESTDIR)$(BINDIR)/ldid
+ $(INSTALL) -d $(DESTDIR)$(BINDIR)/
+ $(INSTALL) -m755 ldid $(DESTDIR)$(BINDIR)/ldid
$(LN) -sf ldid $(DESTDIR)$(BINDIR)/ldid2
- $(INSTALL) -D -m644 docs/ldid.1 $(DESTDIR)$(MANDIR)/man1/ldid.1
- $(INSTALL) -D -m644 docs/ldid.1.zh_TW $(DESTDIR)$(MANDIR)/zh_TW/man1/ldid.1
+ $(INSTALL) -d $(DESTDIR)$(MANDIR)/man1/
+ $(INSTALL) -m644 docs/ldid.1 $(DESTDIR)$(MANDIR)/man1/ldid.1
+ for lang in $(MANPAGE_LANGS); do \
+ $(INSTALL) -d $(DESTDIR)$(MANDIR)/$$lang/man1/; \
+ $(INSTALL) -m644 docs/ldid.$$lang.1 $(DESTDIR)$(MANDIR)/$$lang/man1/ldid.1; \
+ done
clean:
rm -rf ldid *.o