summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2008-12-18 16:05:18 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-12-22 10:13:37 +0200
commit96a4f76f2e9dad7fdbd6fd7740de44bc90d5769e (patch)
tree9367832bd2a5df10897fa7f2835cc4b24f468c87 /Makefile
parentef1e909207cd901871d60a916e4b7ff7b3e97d7d (diff)
Unify all common build system parts
Rather than duplicating the same thing over and over in every Makefile, move it all to common.mk. Other things fixed here: - doing subdirs in parallel - fix src!=build compiling in subdirs Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile79
1 files changed, 21 insertions, 58 deletions
diff --git a/Makefile b/Makefile
index 8319599..969ab87 100644
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,15 @@
# -*- sh -*-
-PREFIX=/usr
-EXEC_PREFIX=$(PREFIX)
-SBINDIR=$(EXEC_PREFIX)/sbin
-MANDIR=$(PREFIX)/share/man
-INCLUDEDIR=$(PREFIX)/include
-
-#CROSS=arm-linux-
-CC := $(CROSS)gcc
-CFLAGS ?= -O2 -g
-CFLAGS += -Wall
CPPFLAGS += -I./include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS)
-ifeq ($(origin CROSS),undefined)
- BUILDDIR := .
-else
-# Remove the trailing slash to make the directory name
- BUILDDIR := $(CROSS:-=)
-endif
-
ifeq ($(WITHOUT_XATTR), 1)
CPPFLAGS += -DWITHOUT_XATTR
endif
-RAWTARGETS = ftl_format flash_erase flash_eraseall nanddump doc_loadbios \
+SUBDIRS = mkfs.ubifs ubi-utils
+
+TARGETS = ftl_format flash_erase flash_eraseall nanddump doc_loadbios \
ftl_check mkfs.jffs2 flash_lock flash_unlock flash_info \
flash_otp_info flash_otp_dump mtd_debug flashcp nandwrite nandtest \
jffs2dump \
@@ -33,71 +18,49 @@ RAWTARGETS = ftl_format flash_erase flash_eraseall nanddump doc_loadbios \
serve_image recv_image \
sumtool #jffs2reader
-TARGETS = $(foreach target,$(RAWTARGETS),$(BUILDDIR)/$(target))
-
SYMLINKS =
-%: %.o
- $(CC) $(CFLAGS) $(LDFLAGS) -g -o $@ $^
-
-$(BUILDDIR)/%.o: %.c
- mkdir -p $(BUILDDIR)
- $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< -g -Wp,-MD,$(BUILDDIR)/.$(<F).dep
-
-.SUFFIXES:
+include common.mk
-all: $(TARGETS)
- $(MAKE) -C $(BUILDDIR)/ubi-utils
- $(MAKE) -C $(BUILDDIR)/mkfs.ubifs
-
-IGNORE=${wildcard $(BUILDDIR)/.*.c.dep}
--include ${IGNORE}
-
-clean:
- rm -f $(BUILDDIR)/*.o $(TARGETS) $(BUILDDIR)/.*.c.dep $(SYMLINKS)
- if [ "$(BUILDDIR)x" != ".x" ]; then rm -rf $(BUILDDIR); fi
- $(MAKE) -C $(BUILDDIR)/ubi-utils clean
- $(MAKE) -C $(BUILDDIR)/mkfs.ubifs clean
+clean::
+ -rm -f $(SYMLINKS)
+ifneq ($(BUILDDIR)/.git,)
+ifneq ($(BUILDDIR),.)
+ifneq ($(BUILDDIR),$(PWD))
+ rm -rf $(BUILDDIR)
+endif
+endif
+endif
$(SYMLINKS):
ln -sf ../fs/jffs2/$@ $@
-$(BUILDDIR)/mkfs.jffs2: $(BUILDDIR)/crc32.o \
- $(BUILDDIR)/compr_rtime.o \
- $(BUILDDIR)/mkfs.jffs2.o \
- $(BUILDDIR)/compr_zlib.o \
- $(BUILDDIR)/compr_lzo.o \
- $(BUILDDIR)/compr.o \
- $(BUILDDIR)/rbtree.o
- $(CC) $(LDFLAGS) -o $@ $^ $(ZLIBLDFLAGS) -lz $(LZOLDFLAGS) -llzo2
+$(BUILDDIR)/mkfs.jffs2: $(addprefix $(BUILDDIR)/,\
+ crc32.o compr_rtime.o mkfs.jffs2.o compr_zlib.o compr_lzo.o \
+ compr.o rbtree.o)
+LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
+LDLIBS_mkfs.jffs2 = -lz -llzo2
$(BUILDDIR)/flash_eraseall: $(BUILDDIR)/crc32.o $(BUILDDIR)/flash_eraseall.o
- $(CC) $(LDFLAGS) -o $@ $^
$(BUILDDIR)/jffs2reader: $(BUILDDIR)/jffs2reader.o
- $(CC) $(LDFLAGS) -o $@ $^ $(ZLIBLDFLAGS) -lz
+LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
+LDLIBS_jffs2reader = -lz -llzo2
$(BUILDDIR)/jffs2dump: $(BUILDDIR)/jffs2dump.o $(BUILDDIR)/crc32.o
- $(CC) $(LDFLAGS) -o $@ $^
$(BUILDDIR)/sumtool: $(BUILDDIR)/sumtool.o $(BUILDDIR)/crc32.o
- $(CC) $(LDFLAGS) -o $@ $^
$(BUILDDIR)/serve_image: $(BUILDDIR)/serve_image.o $(BUILDDIR)/crc32.o $(BUILDDIR)/fec.o
- $(CC) $(LDFLAGS) -o $@ $^
$(BUILDDIR)/recv_image: $(BUILDDIR)/recv_image.o $(BUILDDIR)/crc32.o $(BUILDDIR)/fec.o
- $(CC) $(LDFLAGS) -o $@ $^
$(BUILDDIR)/fectest: $(BUILDDIR)/fectest.o $(BUILDDIR)/crc32.o $(BUILDDIR)/fec.o
- $(CC) $(LDFLAGS) -o $@ $^
-install: ${TARGETS}
+install:: ${TARGETS}
mkdir -p ${DESTDIR}/${SBINDIR}
install -m 0755 ${TARGETS} ${DESTDIR}/${SBINDIR}/
mkdir -p ${DESTDIR}/${MANDIR}/man1
gzip -9c mkfs.jffs2.1 > ${DESTDIR}/${MANDIR}/man1/mkfs.jffs2.1.gz
- $(MAKE) -C $(BUILDDIR)/ubi-utils install
- $(MAKE) -C $(BUILDDIR)/mkfs.ubifs install