Date:2010-11-20 11:14:52 (13 years 4 months ago)
Author:Werner Almesberger
Commit:9481934c9ae3813f3c47f026c70c18f894f2989c
Message: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
Files: qpkg/Makefile (1 diff)
qpkg/gobble.c (2 diffs)

Change Details

qpkg/Makefile
1SHELL = /bin/bash
2
3OBJS_qpkg = gobble.o id.o prereq.o qpkg.o jrb.o
4OBJS_rbtest = rbtest.o jrb.o
5OBJS = $(OBJS_qpkg) $(OBJS_rbtest)
6
17CFLAGS = -Wall -Wshadow -Wmissing-prototypes -g -O
28# -O, so that we get data flow analysis, which helps to find more bugs
39#LDFLAGS=-pg
410
5OBJS = gobble.o id.o prereq.o qpkg.o jrb.o
6OBJS_rbtest = rbtest.o jrb.o
11# ----- Verbosity control -----------------------------------------------------
12
13CC_normal := $(CC)
14DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG
15
16CC_quiet = @echo " CC " $@ && $(CC_normal)
17DEPEND_quiet = @$(DEPEND_normal)
18
19ifeq ($(V),1)
20    CC = $(CC_normal)
21    DEPEND = $(DEPEND_normal)
22else
23    CC = $(CC_quiet)
24    DEPEND = $(DEPEND_quiet)
25endif
26
27# ----- Rules -----------------------------------------------------------------
28
29.PHONY: all jlime openwrt clean spotless
730
8all: qpkg rbtest
31all: qpkg rbtest
932
1033jlime:
11    $(MAKE) clean
12    $(MAKE) CC=mipsel-linux-gcc
34        $(MAKE) clean
35        $(MAKE) CC_normal=mipsel-linux-gcc
1336
14qpkg: $(OBJS)
37#
38# OpenWRT uses mipsel-openwrt-linux-* and mipsel-openwrt-linux-uclibc-*.
39# They should both be available, but just in case, let's improve our odds
40# of picking a compiler that actualy exists.
41#
1542
16rbtest: $(OBJS_rbtest)
43openwrt:
44        $(MAKE) clean
45        $(MAKE) CC_normal=$(shell \
46          n=`which mipsel-openwrt-linux-gcc`; \
47          echo "$${n:-`which mipsel-openwrt-linux-uclibc-gcc`}")
48
49qpkg: $(OBJS_qpkg)
50
51rbtest: $(OBJS_rbtest)
52
53# ----- Cleanup ---------------------------------------------------------------
1754
1855clean:
19    rm -f $(OBJS) $(OBJS_rbtest)
56        rm -f $(OBJS) $(OBJS:.o=.d)
57
58spotless: clean
59        rm -f qpkg rbtest
60
61# ----- Dependencies ----------------------------------------------------------
62
63# compile and generate dependencies, from fped, based on
64# http://scottmcpeak.com/autodepend/autodepend.html
65
66%.o: %.c
67        $(CC) -c $(CFLAGS) $*.c -o $*.o
68        $(DEPEND) $*.c | \
69          sed -e \
70            '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \
71            -e '$${g;p;}' -e d >$*.d; \
72          [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; }
73
74-include $(OBJS:.o=.d)
qpkg/gobble.c
403403}
404404
405405
406/*
407 * We should be able to test for __UCLIBC_HAS_ADVANCED_REALTIME__ specifically,
408 * but that doesn't work for some reason. So let's just omit posix_madvise on
409 * __UCLIBC__ in general.
410 */
411
412
413#if !defined(__UCLIBC__)
414
415static int do_madvise(void *addr, size_t len, int advice)
416{
417    return posix_madvise(addr, len, advice);
418}
419
420#else /* __UCLIBC__ */
421
422#define do_madvise(addr, len, advice) 0
423
424#endif /* __UCLIBC__ */
425
426
406427void gobble(const char *name)
407428{
408429    int fd;
...... 
423444        perror("mmap");
424445        exit(1);
425446    }
426    if (posix_madvise(map, st.st_size, POSIX_MADV_WILLNEED) < 0) {
447    if (do_madvise(map, st.st_size, POSIX_MADV_WILLNEED) < 0) {
427448        perror("posix_madvise(POSIX_MADV_WILLNEED)");
428449        exit(1);
429450    }
430451    gobble_buf(name, map, st.st_size);
431    if (posix_madvise(map, st.st_size, POSIX_MADV_RANDOM) < 0) {
452    if (do_madvise(map, st.st_size, POSIX_MADV_RANDOM) < 0) {
432453        perror("posix_madvise(POSIX_MADV_RANDOM)");
433454        exit(1);
434455    }

Archive Download the corresponding diff file

Branches:
master



interactive