include config.mk
-all: $(TARGET)
-test: $(LIBTARGET)
- @$(MAKE) $(MFLAGS) -s -C tests
+SRCDIR=src
+DOCDIR=doc
+all: $(TARGET)
options:
@echo "$(PROJECT) build options:"
@echo "LIBS = $(LIBS)"
@echo "LDFLAGS = $(LDFLAGS)"
@echo "CC = $(CC)"
-install: $(TARGET) doc/$(MAN1)
+test: $(LIBTARGET)
+ @$(MAKE) $(MFLAGS) -s -C tests
+
+clean:
+ @$(MAKE) $(MFLAGS) -C src clean
+ @$(MAKE) $(MFLAGS) -C tests clean
+
+install: $(TARGET) $(DOCDIR)/$(MAN1)
install -d $(DESTDIR)$(BINDIR)
- install -d $(DESTDIR)$(MANDIR1)
- install -m 755 $(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
- @echo "install -m 644 src/$(MAN1) $(DESTDIR)$(MANDIR1)/$(MAN1)"
+ install -d $(DESTDIR)$(MANDIR)/man1
+ install -m 755 $(SRCDIR)/$(TARGET) $(DESTDIR)$(BINDIR)/$(TARGET)
+ @echo "install -m 644 $(SRCDIR)/$(MAN1) $(DESTDIR)$(MANDIR)/man1/$(MAN1)"
@sed -e "s/VERSION/$(VERSION)/g" \
- -e "s/DATE/`date +'%m %Y'`/g" < doc/$(MAN1) > $(DESTDIR)$(MANDIR1)/$(MAN1)
- @chmod 644 $(DESTDIR)$(MANDIR1)/$(MAN1)
+ -e "s/DATE/`date +'%m %Y'`/g" < $(DOCDIR)/$(MAN1) > $(DESTDIR)$(MANDIR)/man1/$(MAN1)
+ @chmod 644 $(DESTDIR)$(MANDIR)/man1/$(MAN1)
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/$(TARGET)
- $(RM) $(DESTDIR)$(MANDIR1)/$(MAN1)
-
-clean: test-clean
- $(RM) src/*.o src/*.lo src/hints.js.h
- $(RM) $(TARGET)
-
-test-clean:
- $(RM) $(LIBTARGET)
- @$(MAKE) $(MFLAGS) -C tests clean
+ $(RM) $(DESTDIR)$(MANDIR)/man1/$(MAN1)
dist: dist-clean
@echo "Creating tarball."
dist-clean:
$(RM) $(DIST_FILE)
-src/hints.o: src/hints.js.h
-src/hints.lo: src/hints.js.h
-
-src/hints.js.h: src/hints.js
- @echo "minify $<"
- @cat $< | src/js2h.sh > $@
-
-$(OBJ): src/config.h config.mk
-$(LOBJ): src/config.h config.mk
-
-$(TARGET): $(OBJ)
- @echo "$(CC) $@"
- @$(CC) $(OBJ) -o $@ $(LDFLAGS)
-
-$(LIBTARGET): $(LOBJ)
- @echo "$(CC) $@"
- @$(CC) -shared ${LOBJ} -o $@ $(LDFLAGS)
-
-src/config.h:
- @echo create $@ from src/config.def.h
- @cp src/config.def.h $@
-
-%.o: %.c %.h
- @echo "${CC} $@"
- @$(CC) $(CFLAGS) -c -o $@ $<
-
-%.lo: %.c %.h
- @echo "${CC} $@"
- @$(CC) -DTESTLIB $(CFLAGS) -fPIC -c -o $@ $<
+$(TARGET):
+ @$(MAKE) $(MFLAGS) -C src $(TARGET)
--include $(DEPS)
+$(LIBTARGET):
+ @$(MAKE) $(MFLAGS) -C src $(LIBTARGET)
-.PHONY: clean debug all install uninstall options dist dist-clean test test-clean
+.PHONY: clean all install uninstall options dist dist-clean test
CFLAGS += ${CPPFLAGS}
LDFLAGS += ${LIBFLAGS}
-OBJ = $(patsubst %.c, %.o, $(wildcard src/*.c))
-LOBJ = $(patsubst %.c, %.lo, $(wildcard src/*.c))
-DEPS = $(OBJ:%.o=%.d)
-
TARGET = $(PROJECT)
-LIBTARGET = tests/lib$(PROJECT).so
+LIBTARGET = lib$(PROJECT).so
DIST_FILE = $(PROJECT)_$(VERSION).tar.gz
-MANDIR1 = $(MANDIR)/man1
MAN1 = $(PROJECT).1
-MFLAGS =
+MFLAGS = --no-print-directory
--- /dev/null
+BASEDIR=..
+include $(BASEDIR)/config.mk
+
+OBJ = $(patsubst %.c, %.o, $(wildcard *.c))
+LOBJ = $(patsubst %.c, %.lo, $(wildcard *.c))
+
+all: $(TARGET)
+
+clean: clean-lib
+ $(RM) $(TARGET) *.o *.lo hints.js.h
+
+clean-lib:
+ $(RM) $(LIBTARGET)
+
+hints.o: hints.js.h
+hints.lo: hints.js.h
+
+hints.js.h: hints.js
+ @echo "minify $<"
+ @cat $< | ./js2h.sh > $@
+
+$(OBJ): config.h $(BASEDIR)/config.mk
+$(LOBJ): config.h $(BASEDIR)/config.mk
+
+$(TARGET): $(OBJ)
+ @echo "$(CC) $@"
+ @$(CC) $(OBJ) -o $@ $(LDFLAGS)
+
+$(LIBTARGET): $(LOBJ)
+ @echo "$(CC) $@"
+ @$(CC) -shared ${LOBJ} -o $@ $(LDFLAGS)
+
+config.h:
+ @echo create $@ from config.def.h
+ @cp config.def.h $@
+
+%.o: %.c %.h
+ @echo "${CC} $@"
+ @$(CC) $(CFLAGS) -c -o $@ $<
+
+%.lo: %.c %.h
+ @echo "${CC} $@"
+ @$(CC) -DTESTLIB $(CFLAGS) -fPIC -c -o $@ $<
+
+-include $(OBJ:.o=.d)
+
+.PHONY: all clean clean-lib