CVS: libraries/commandline makefile,1.5,1.5.2.1
"Sergey A. Borshch" <[email protected]> Sun, 15 Feb 2009 21:48:15 +0000
| Newsgroups | gmane.comp.hardware.texas-instruments.msp430.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mspgcc/libraries/commandline
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv20147/commandline
Modified Files:
Tag: MSP430X
makefile
Log Message:
multilib build.
Index: makefile
===================================================================
RCS file: /cvsroot/mspgcc/libraries/commandline/makefile,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -w -d -r1.5 -r1.5.2.1
--- makefile 9 Oct 2008 15:00:13 -0000 1.5
+++ makefile 15 Feb 2009 21:48:13 -0000 1.5.2.1
@@ -1,53 +1,98 @@
-# makfile configuration
+# makefile configuration
+ifndef PREFIX
+PREFIX := /usr/local/msp430
+endif
+
LIBRARYNAME = commandline
CSOURCES = commandline.c commandline_number.c commandline_usage.c \
help.c reset.c checksum.c \
memory_write.c memory_erase.c hexdump.c \
tabcomplete.c
#~ ASOURCES =
-CPU = msp1
-ASFLAGS = -mmcu=${CPU} -I ../include
-CFLAGS = -mmcu=${CPU} -O2 -Wall -std=gnu99 -g -I ../include
+COMMON := $(LIB_OPTIONS)
+COMMON += -I ../include
+COMMON += -MD -MP -MT $(BUILDDIR)/$(*F).o -MF $(BUILDDIR)/$(@F).d
-#switch the compiler (for the internal make rules)
-CC = msp430-gcc
-AS = msp430-gcc
-AR = msp430-ar
+ASFLAGS = $(COMMON)
+ASFLAGS += -Wa,-g
-OBJECTS = ${CSOURCES:.c=.o} ${ASOURCES:.S=.o}
+CFLAGS = $(COMMON)
+CFLAGS += -Wall -Os -g
+CFLAGS += -std=gnu99
-.PHONY: all FORCE clean
+GEN_DEPENDENCIES = -MD -MP -MT $@ -MF $(BUILDDIR)/$(@F).d
-#all should be the first target. it's built when make is run without args
-all: lib$(LIBRARYNAME).a lib$(LIBRARYNAME).lst dependencies.d
+#switch the compiler (for the internal make rules)
+CC = $(PREFIX)/bin/msp430-gcc
+AS = $(PREFIX)/bin/msp430-gcc -x assembler-with-cpp
+AR = $(PREFIX)/bin/msp430-ar
-lib$(LIBRARYNAME).a: $(OBJECTS)
- $(AR) rcf $@ $^
+BUILD_ROOT = ./Build
+BUILDDIR = $(BUILD_ROOT)/$(MULTILIB_DIR)
+OBJECTS = $(addprefix $(BUILDDIR)/,$(CSOURCES:.c=.o) $(ASOURCES:.S=.o))
+LIB = $(BUILDDIR)/lib$(LIBRARYNAME)
+.PHONY: all clean install uninstall
-lib$(LIBRARYNAME).lst: lib$(LIBRARYNAME).a
- msp430-objdump -dSt $^ >$@
- @echo "----- RAM/Flash Usage -----"
- msp430-size $^
+#all should be the first target. it's built when make is run without args
+all:
+ for i in `$(CC) --print-multi-lib 2>/dev/null`; do \
+ dir=`echo $$i | sed -e 's/;.*$$//'` ; \
+ options=`echo $$i | sed -e 's/[^@]*//' -e 's/@/ -/g'`; \
+ echo "=== building $$dir ===" ; \
+ $(MAKE) --no-print-directory "MULTILIB_DIR=$$dir" "LIB_OPTIONS=$$options" build ; \
+ done;
-download: install
-install: lib$(LIBRARYNAME).a
- INSTALLDIR=$(dir $(shell which msp430-gcc))../msp430/lib ;\
- cp lib$(LIBRARYNAME).a $$INSTALLDIR ;\
- cp -r ../include/commandline.h $$INSTALLDIR/include
+download: install #???
+install:
+# target directories for *.a are created by msp430-libc installation
+ INSTALLDIR=$(dir $(shell which $(CC)))../msp430 ;\
+ cp ../include/$(LIBRARYNAME).h $$INSTALLDIR/include ; \
+ for i in `$(CC) --print-multi-lib 2>/dev/null`; do \
+ dir=`echo $$i | sed -e 's/;.*$$//'` ; \
+ echo "=== installing $$INSTALLDIR/lib/$$dir/lib$(LIBRARYNAME).a ===" ; \
+ cp $(BUILD_ROOT)/$$dir/lib$(LIBRARYNAME).a $$INSTALLDIR/lib/$$dir ; \
+ done;
+
+uninstall:
+ INSTALLDIR=$(dir $(shell which $(CC)))../msp430 ;\
+ rm -f $$INSTALLDIR/include/$(LIBRARYNAME).h ; \
+ for i in `$(CC) --print-multi-lib 2>/dev/null`; do \
+ dir=`echo $$i | sed -e 's/;.*$$//'` ; \
+ echo "=== uninstalling $$INSTALLDIR/lib/$$dir/lib$(LIBRARYNAME).a ===" ; \
+ rm $$INSTALLDIR/lib/$$dir/lib$(LIBRARYNAME).a ; \
+ done;
clean:
- rm -f lib$(LIBRARYNAME).a lib$(LIBRARYNAME).lst ${OBJECTS} dependencies.d
+ ${RM} -rf $(BUILD_ROOT)
+#------------------------------------------------------------
+PHONY: build
+build: $(LIB).a $(LIB).lst
+$(BUILDDIR)/%.o: %.c
+ $(CC) -c $(CFLAGS) $(GEN_DEPENDENCIES) $< -o $@
-#dummy target as dependecy if something has to be build everytime
-FORCE:
+$(BUILDDIR)/%.o: %.S
+ $(AS) -c $(ASFLAGS) $(GEN_DEPENDENCIES) $< -o $@
-#project dependencies
-dependencies.d:
- $(CC) -MM ${CFLAGS} ${CSOURCES} > dependencies.d
-ifdef ASOURCES
- $(CC) -MM ${ASFLAGS} ${ASOURCES} >> dependencies.d
-endif
+$(BUILDDIR)/%.o: %.s
+ $(AS) -c $(ASFLAGS) $(GEN_DEPENDENCIES) $< -o $@
--include dependencies.d
\ No newline at end of file
+$(LIB).a: $(OBJECTS)
+ $(AR) rcf $@ $^
+
+$(LIB).lst: $(LIB).a
+ msp430-objdump -dSt $^ >$@
+ @echo "----- RAM/Flash Usage -----"
+ msp430-size $^
+#------------------------------------------------------------
+
+# dependencies inclusion
+# if make target list not contain this targets - include dependencies
+ifeq (,$(findstring clean,$(MAKECMDGOALS)))
+ ifeq (,$(findstring install,$(MAKECMDGOALS)))
+ ifeq (,$(findstring all,$(MAKECMDGOALS)))
+-include $(shell mkdir -p $(BUILDDIR) 2>/dev/null) $(wildcard $(BUILDDIR)/*.d)
+ endif
+ endif
+endif
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H