From ebd5d43621e65f374433f3df29f8bee54166ab95 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 15 May 2019 18:10:18 +0200 Subject: [PATCH] rework the makefiles --- .gitignore | 3 +++ example/Makefile | 21 +++++++++++---------- tools/Makefile | 40 +++++++++++++++++++--------------------- 3 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..552748f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +tools/bin +tools/obj +example/books diff --git a/example/Makefile b/example/Makefile index 6748278..9156518 100644 --- a/example/Makefile +++ b/example/Makefile @@ -1,10 +1,11 @@ -BOOKROOT=.. -TOOLSDIR=$(BOOKROOT)/tools -PSDIR=$(BOOKROOT)/ps -YAPP=$(TOOLSDIR)/yapp -MAKEMANIFEST=$(TOOLSDIR)/makemanifest -PSGEN=BOOKROOT=$(BOOKROOT) $(TOOLSDIR)/psgen -INCLUDERES=(cd $(PSDIR); includeres) +BOOKROOT = .. +TOOLSDIR = $(BOOKROOT)/tools +PSDIR = $(BOOKROOT)/ps + +YAPP = $(TOOLSDIR)/yapp +MAKEMANIFEST = $(TOOLSDIR)/makemanifest +PSGEN = env BOOKROOT=$(BOOKROOT) $(TOOLSDIR)/psgen +INCLUDERES = (cd $(PSDIR); includeres) code.ps pagenums: filelist footer.ps MANIFEST books $(PSGEN) -P2 -l3 -DfooterFile=footer.ps filelist pagenums 1 \ @@ -16,8 +17,8 @@ books: MANIFEST: filelist $(MAKEMANIFEST) $< > $@ -clean: - rm -f `cat .gitignore` - gv%: %.ps gv $< + +clean: + rm -f `cat .gitignore` diff --git a/tools/Makefile b/tools/Makefile index 138d5b7..522090d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,30 +1,28 @@ -all: unmunge repair munge +BIN = bin +OBJ = obj +CFLAGS = -g -O -W -Wall -OPT = -g -O -W -Wall -COMMON_OBJS = util.o +BINS = $(addprefix $(BIN)/, unmunge munge repair) +UNMUNGE_OBJS = $(addprefix $(OBJ)/, util.o unmunge.o) +MUNGE_OBJS = $(addprefix $(OBJ)/, util.o munge.o) +REPAIR_OBJS = $(addprefix $(OBJ)/, util.o heap.o mempool.o subst.o repair.o) -UNMUNGE_OBJS = $(COMMON_OBJS) unmunge.o -MUNGE_OBJS = $(COMMON_OBJS) munge.o -REPAIR_OBJS = $(COMMON_OBJS) heap.o mempool.o subst.o repair.o +all: $(BINS) -unmunge: $(UNMUNGE_OBJS) - $(CC) $(OPT) -o $@ $(UNMUNGE_OBJS) +$(BIN)/unmunge: $(UNMUNGE_OBJS) + $(CC) $(CFLAGS) -o $@ $(UNMUNGE_OBJS) -munge: $(MUNGE_OBJS) - $(CC) $(OPT) -o $@ $(MUNGE_OBJS) +$(BIN)/munge: $(MUNGE_OBJS) + $(CC) $(CFLAGS) -o $@ $(MUNGE_OBJS) -repair: $(REPAIR_OBJS) - $(CC) $(OPT) -o $@ $(REPAIR_OBJS) +$(BIN)/repair: $(REPAIR_OBJS) + $(CC) $(CFLAGS) -o $@ $(REPAIR_OBJS) -.c.o: - $(CC) $(OPT) -o $@ -c $< +$(OBJ)/%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< clean: - -rm -f *.o munge unmunge repair core *.core + rm -f $(OBJ)/* $(BIN)/*.core -unmunge.o: util.h -munge.o: util.h -repair.o: heap.h mempool.h util.h subst.h -heap.o: heap.h -mempool.o: mempool.h -subst.o: subst.h +cleaner: + rm -f $(BIN)/* $(OBJ)/* $(BIN)/*.core