From 0d6783e3738d75cdfa09ad7d6ed251a5026c0b3b Mon Sep 17 00:00:00 2001 From: Alejandro Mery Date: Mon, 9 Feb 2009 18:40:36 +0100 Subject: [PATCH] protothread: improve to install two flavours of .a, one for debugging and one for production --- develop/protothread/makefile.patch | 77 +++++++++++++++++++++------- develop/protothread/protothread.conf | 22 +++++++- 2 files changed, 80 insertions(+), 19 deletions(-) diff --git a/develop/protothread/makefile.patch b/develop/protothread/makefile.patch index c69627825..36c95f6c3 100644 --- a/develop/protothread/makefile.patch +++ b/develop/protothread/makefile.patch @@ -14,43 +14,84 @@ # version. # --- SDE-COPYRIGHT-NOTE-END --- ---- ./Makefile.orig 2009-01-18 19:12:34.000000000 +0000 -+++ ./Makefile 2009-01-18 19:40:18.000000000 +0000 -@@ -1,15 +1,36 @@ +Index: protothread.h +=================================================================== +--- ./protothread.h (revision 3) ++++ ./protothread.h (working copy) +@@ -6,7 +6,9 @@ + #ifndef PROTOTHREAD_H + #define PROTOTHREAD_H + ++#ifndef PT_DEBUG + #define PT_DEBUG 1 /* enabled (else 0) */ ++#endif + #define pt_assert(condition) if (PT_DEBUG) assert(condition) + + /* standard definitions */ +Index: Makefile +=================================================================== +--- ./Makefile (revision 3) ++++ ./Makefile (working copy) +@@ -1,15 +1,56 @@ +CC = gcc ++LD = gcc +AR = ar CFLAGS = -g -Wall +-OBJS = \ +- protothread_test.o \ +prefix = /usr/local +bindir = $(prefix)/bin +libdir = $(prefix)/lib -+DESTDIR= ++includedir = $(prefix)/include ++DESTDIR = ++ ++ifeq ($(DEBUG),yes) ++ CFLAGS += -DPT_DEBUG=1 ++else ++ifeq ($(DEBUG),no) ++ CFLAGS += -DPT_DEBUG=0 ++endif ++endif + -+TARGETS = pttest protothread.a ++SRCDIR = . + - OBJS = \ - protothread_test.o \ ++TARGETS = pttest libprotothread.a ++ ++LIB_OBJS = \ protothread_lock.o \ protothread_sem.o \ protothread.o \ -+ +-pttest: $(OBJS) protothread.h +- $(CC) $(CFLAGS) -o $@ $(OBJS) ++OBJS = $(LIB_OBJS) \ ++ protothread_test.o + +-$(OBJS): protothread.h + +.PHONY: all clean install + +all: $(TARGETS) + - pttest: $(OBJS) protothread.h - $(CC) $(CFLAGS) -o $@ $(OBJS) - -+protothread.a: $(OBJS) -+ $(AR) rcs $@ $(OBJS) ++define OBJ_template ++$(1).o: $(SRCDIR)/$(1).c $(wildcard $(SRCDIR)/$(1).h) $(SRCDIR)/protothread.h ++ $(CC) $(CFLAGS) -c -o $$@ -I$(SRCDIR)/ $$< ++endef ++ ++$(foreach x,$(basename $(OBJS)),$(eval $(call OBJ_template,$(x)))) ++ ++pttest: $(OBJS) ++ $(LD) $(LDFLAGS) -o $@ $^ ++ ++libprotothread.a: $(LIB_OBJS) ++ $(AR) rcs $@ $^ + - $(OBJS): protothread.h - clean: - rm -f *.o -+ rm -f $(OBJS) $(TARGETS) ++ rm -f *.o $(TARGETS) + +install: -+ cp -vf pttest $(DESTDIR)$(bindir)/ -+ cp -vf protothread.a $(DESTDIR)$(libdir)/ ++ cp -vf pttest $(DESTDIR)$(bindir)/pttest$(SUFFIX) ++ cp -vf libprotothread.a $(DESTDIR)$(libdir)/libprotothread$(SUFFIX).a ++ cp -vf $(SRCDIR)/*.h $(DESTDIR)$(includedir)/ diff --git a/develop/protothread/protothread.conf b/develop/protothread/protothread.conf index 219a92259..04bcabc64 100644 --- a/develop/protothread/protothread.conf +++ b/develop/protothread/protothread.conf @@ -14,4 +14,24 @@ custextract=autoextract_subdir_tar_bz2 -hook_add postmake 5 'cp -vf license.txt gdbinit $DESTDIR$docdir/' +buildloops=2 + +makeopt_orig="-f ../Makefile SRCDIR=.. $makeopt" + +hook_add preconf 5 'buildloop_control' +buildloop_control() { + [ "$buildloop" = 1 ] || cd .. + mkdir "objdir$buildloop" + cd "objdir$buildloop" + + case "$buildloop" in + 1) makeopt="$makeopt_orig DEBUG=yes" + makeinstopt="$makeopt_orig SUFFIX=_debug install" + ;; + 2) makeopt="$makeopt_orig DEBUG=no" + makeinstopt="$makeopt_orig install" + ;; + esac +} + +hook_add postdoc 5 'cp -vf ../license.txt ../gdbinit $DESTDIR$docdir/'