1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-14 19:33:44 +02:00

qpkg: Makefile cleanup and added OpenWRT target

- Makefile: added automatic dependenceies (needs SHELL = /bin/bash)
- Makefile: added non-verbose builds
- Makefile (jlime): set CC_normal instead of CC, so that also cross-builds
  can be non-verbose
- Makefile (openwrt): new target to cross-compile for OpenWRT with uClibc
- Makefile (spotless): added "spotless" target
- gobble.c: uClibc may not have posix_madvise, so replace it with a dummy
  if building for uClibc
This commit is contained in:
Werner Almesberger 2010-11-20 07:14:52 -03:00
parent 78006c51cc
commit 9481934c9a
2 changed files with 86 additions and 10 deletions

View File

@ -1,19 +1,74 @@
SHELL = /bin/bash
OBJS_qpkg = gobble.o id.o prereq.o qpkg.o jrb.o
OBJS_rbtest = rbtest.o jrb.o
OBJS = $(OBJS_qpkg) $(OBJS_rbtest)
CFLAGS = -Wall -Wshadow -Wmissing-prototypes -g -O
# -O, so that we get data flow analysis, which helps to find more bugs
#LDFLAGS=-pg
OBJS = gobble.o id.o prereq.o qpkg.o jrb.o
OBJS_rbtest = rbtest.o jrb.o
# ----- Verbosity control -----------------------------------------------------
CC_normal := $(CC)
DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
CC_quiet = @echo " CC " $@ && $(CC_normal)
DEPEND_quiet = @$(DEPEND_normal)
ifeq ($(V),1)
CC = $(CC_normal)
DEPEND = $(DEPEND_normal)
else
CC = $(CC_quiet)
DEPEND = $(DEPEND_quiet)
endif
# ----- Rules -----------------------------------------------------------------
.PHONY: all jlime openwrt clean spotless
all: qpkg rbtest
jlime:
$(MAKE) clean
$(MAKE) CC=mipsel-linux-gcc
$(MAKE) CC_normal=mipsel-linux-gcc
qpkg: $(OBJS)
#
# OpenWRT uses mipsel-openwrt-linux-* and mipsel-openwrt-linux-uclibc-*.
# They should both be available, but just in case, let's improve our odds
# of picking a compiler that actualy exists.
#
openwrt:
$(MAKE) clean
$(MAKE) CC_normal=$(shell \
n=`which mipsel-openwrt-linux-gcc`; \
echo "$${n:-`which mipsel-openwrt-linux-uclibc-gcc`}")
qpkg: $(OBJS_qpkg)
rbtest: $(OBJS_rbtest)
# ----- Cleanup ---------------------------------------------------------------
clean:
rm -f $(OBJS) $(OBJS_rbtest)
rm -f $(OBJS) $(OBJS:.o=.d)
spotless: clean
rm -f qpkg rbtest
# ----- Dependencies ----------------------------------------------------------
# compile and generate dependencies, from fped, based on
# http://scottmcpeak.com/autodepend/autodepend.html
%.o: %.c
$(CC) -c $(CFLAGS) $*.c -o $*.o
$(DEPEND) $*.c | \
sed -e \
'/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
-e '$${g;p;}' -e d >$*.d; \
[ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }
-include $(OBJS:.o=.d)

View File

@ -403,6 +403,27 @@ fail:
}
/*
* We should be able to test for __UCLIBC_HAS_ADVANCED_REALTIME__ specifically,
* but that doesn't work for some reason. So let's just omit posix_madvise on
* __UCLIBC__ in general.
*/
#if !defined(__UCLIBC__)
static int do_madvise(void *addr, size_t len, int advice)
{
return posix_madvise(addr, len, advice);
}
#else /* __UCLIBC__ */
#define do_madvise(addr, len, advice) 0
#endif /* __UCLIBC__ */
void gobble(const char *name)
{
int fd;
@ -423,12 +444,12 @@ void gobble(const char *name)
perror("mmap");
exit(1);
}
if (posix_madvise(map, st.st_size, POSIX_MADV_WILLNEED) < 0) {
if (do_madvise(map, st.st_size, POSIX_MADV_WILLNEED) < 0) {
perror("posix_madvise(POSIX_MADV_WILLNEED)");
exit(1);
}
gobble_buf(name, map, st.st_size);
if (posix_madvise(map, st.st_size, POSIX_MADV_RANDOM) < 0) {
if (do_madvise(map, st.st_size, POSIX_MADV_RANDOM) < 0) {
perror("posix_madvise(POSIX_MADV_RANDOM)");
exit(1);
}