Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Commit Details
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 | ||
---|---|---|
1 | SHELL = /bin/bash | |
2 | ||
3 | OBJS_qpkg = gobble.o id.o prereq.o qpkg.o jrb.o | |
4 | OBJS_rbtest = rbtest.o jrb.o | |
5 | OBJS = $(OBJS_qpkg) $(OBJS_rbtest) | |
6 | ||
1 | 7 | CFLAGS = -Wall -Wshadow -Wmissing-prototypes -g -O |
2 | 8 | # -O, so that we get data flow analysis, which helps to find more bugs |
3 | 9 | #LDFLAGS=-pg |
4 | 10 | |
5 | OBJS = gobble.o id.o prereq.o qpkg.o jrb.o | |
6 | OBJS_rbtest = rbtest.o jrb.o | |
11 | # ----- Verbosity control ----------------------------------------------------- | |
12 | ||
13 | CC_normal := $(CC) | |
14 | DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG | |
15 | ||
16 | CC_quiet = @echo " CC " $@ && $(CC_normal) | |
17 | DEPEND_quiet = @$(DEPEND_normal) | |
18 | ||
19 | ifeq ($(V),1) | |
20 | CC = $(CC_normal) | |
21 | DEPEND = $(DEPEND_normal) | |
22 | else | |
23 | CC = $(CC_quiet) | |
24 | DEPEND = $(DEPEND_quiet) | |
25 | endif | |
26 | ||
27 | # ----- Rules ----------------------------------------------------------------- | |
28 | ||
29 | .PHONY: all jlime openwrt clean spotless | |
7 | 30 | |
8 | all: qpkg rbtest | |
31 | all: qpkg rbtest | |
9 | 32 | |
10 | 33 | jlime: |
11 | $(MAKE) clean | |
12 | $(MAKE) CC=mipsel-linux-gcc | |
34 | $(MAKE) clean | |
35 | $(MAKE) CC_normal=mipsel-linux-gcc | |
13 | 36 | |
14 | qpkg: $(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 | # | |
15 | 42 | |
16 | rbtest: $(OBJS_rbtest) | |
43 | openwrt: | |
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 | ||
49 | qpkg: $(OBJS_qpkg) | |
50 | ||
51 | rbtest: $(OBJS_rbtest) | |
52 | ||
53 | # ----- Cleanup --------------------------------------------------------------- | |
17 | 54 | |
18 | 55 | clean: |
19 | rm -f $(OBJS) $(OBJS_rbtest) | |
56 | rm -f $(OBJS) $(OBJS:.o=.d) | |
57 | ||
58 | spotless: 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 | ||
---|---|---|
403 | 403 | } |
404 | 404 | |
405 | 405 | |
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 | ||
415 | static 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 | ||
406 | 427 | void gobble(const char *name) |
407 | 428 | { |
408 | 429 | int fd; |
... | ... | |
423 | 444 | perror("mmap"); |
424 | 445 | exit(1); |
425 | 446 | } |
426 | if (posix_madvise(map, st.st_size, POSIX_MADV_WILLNEED) < 0) { | |
447 | if (do_madvise(map, st.st_size, POSIX_MADV_WILLNEED) < 0) { | |
427 | 448 | perror("posix_madvise(POSIX_MADV_WILLNEED)"); |
428 | 449 | exit(1); |
429 | 450 | } |
430 | 451 | 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) { | |
432 | 453 | perror("posix_madvise(POSIX_MADV_RANDOM)"); |
433 | 454 | exit(1); |
434 | 455 | } |
Branches:
master