diff options
-rw-r--r-- | firmware/test/makefile-rules | 118 | ||||
-rw-r--r-- | firmware/test/makefile-vars | 79 |
2 files changed, 197 insertions, 0 deletions
diff --git a/firmware/test/makefile-rules b/firmware/test/makefile-rules new file mode 100644 index 0000000000..94e779082c --- /dev/null +++ b/firmware/test/makefile-rules | |||
@@ -0,0 +1,118 @@ | |||
1 | ############################################################################# | ||
2 | ## __________ __ ___. | ||
3 | ## Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | ## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | ## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | ## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | ## \/ \/ \/ \/ \/ | ||
8 | ## Copyright Alan Korr, 2002. All rights reserved. | ||
9 | ## | ||
10 | ## Permission to use, copy, modify, and distribute this software for any | ||
11 | ## purpose is hereby granted without fee, provided that this copyright and | ||
12 | ## permissions notice appear in all copies and derivatives, and that no | ||
13 | ## charge may be made for the software and its documentation except to cover | ||
14 | ## cost of distribution. | ||
15 | ## | ||
16 | ## This software is provided "as is" without express or implied warranty. | ||
17 | ############################################################################# | ||
18 | |||
19 | ####################################################################### | ||
20 | ## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES | ||
21 | ## SINCE THERE ARE COMMON FOR ALL LIBRARY | ||
22 | ## | ||
23 | |||
24 | .SUFFIXES : .o .c .s | ||
25 | |||
26 | %.o: %.c | ||
27 | @echo "Compiling" $<... | ||
28 | @$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $< | ||
29 | @$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d | ||
30 | |||
31 | %.o: %.s | ||
32 | @echo "Assembling" $<... | ||
33 | @$(CC) -o $(@) $(CFLAGS) $(INCLUDES) -c $< | ||
34 | @$(CC) -M $< $(CFLAGS) $(INCLUDES) > $(*F).d | ||
35 | |||
36 | .PHONY: splash all clean backup restore dist install | ||
37 | |||
38 | all: splash $(LIBRARY) test | ||
39 | |||
40 | splash: | ||
41 | @echo "<<< " $(PACKAGE) "-" $(VERSION) ">>>" | ||
42 | |||
43 | #################################################### | ||
44 | # LIBRAY PART : | ||
45 | |||
46 | $(LIBRARY): $(OBJECTS) | ||
47 | @echo "Creating library" $(LIBRARY)... | ||
48 | @$(AR) cru $(@) $(OBJECTS) | ||
49 | @$(RL) $(@) | ||
50 | |||
51 | #################################################### | ||
52 | # TEST PART : | ||
53 | |||
54 | test: test.tab.o test.lex.o $(LIBRARY) | ||
55 | @echo "Creating executable" $@... | ||
56 | @$(CC) -g -o $(@) $(INCLUDES) $(+) -lfl -lreadline | ||
57 | |||
58 | test.tab.o: test.tab.c | ||
59 | @echo "Compiling" $<... | ||
60 | @$(CC) $(INCLUDES) -g -o $(@) -O3 -fomit-frame-pointer -c test.tab.c | ||
61 | |||
62 | test.lex.o: test.lex.c | ||
63 | @echo "Compiling" $<... | ||
64 | @$(CC) $(INCLUDES) -g -o $(@) -O3 -fomit-frame-pointer -c test.lex.c | ||
65 | |||
66 | test.tab.h: test.tab.c | ||
67 | |||
68 | test.lex.c: test.l test.tab.h | ||
69 | @echo "Flex:" $< | ||
70 | @flex -otest.lex.c test.l | ||
71 | |||
72 | test.tab.c: test.y | ||
73 | @echo "Bison:" $< | ||
74 | @bison -d test.y | ||
75 | |||
76 | |||
77 | #################################################### | ||
78 | # MISCELLANOUS PART : | ||
79 | |||
80 | clean: | ||
81 | @rm -f $(LIBRARY) | ||
82 | @rm -f $(OBJECTS) test.lex.o test.tab.o | ||
83 | @rm -f $(DEPENDENCIES) | ||
84 | @rm -f *~ test test.exe | ||
85 | @rm -f test.tab.h test.tab.c test.lex.c | ||
86 | @rm -f core | ||
87 | |||
88 | backup: | ||
89 | @mkdir -p ./backup | ||
90 | @cp -f makefile ./backup | ||
91 | @cp -f test.l ./backup | ||
92 | @cp -f test.y ./backup | ||
93 | @cp -f $(SOURCES:.c=.txt) ./backup | ||
94 | @for header in $(HEADERS) ; do cp -f $$header ./backup ; done | ||
95 | @for source in $(SOURCES) ; do cp -f $$source ./backup ; done | ||
96 | |||
97 | restore: | ||
98 | @cp -f ./backup/makefile . | ||
99 | @cp -f ./backup/test.l . | ||
100 | @cp -f ./backup/test.y . | ||
101 | @cp -f ./backup/$(SOURCES:.c=.txt) | ||
102 | @for header in $(HEADERS) ; do cp -f ./backup/$$header . ; done | ||
103 | @for source in $(SOURCES) ; do cp -f ./backup/$$source . ; done | ||
104 | |||
105 | dist: backup | ||
106 | @mv backup $(PACKAGE) | ||
107 | @tar czvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)/* | ||
108 | @rm -f $(PACKAGE)/* | ||
109 | @rmdir $(PACKAGE) | ||
110 | |||
111 | install: all | ||
112 | @mkdir -p $(PREFIX)/libraries | ||
113 | @cp $(LIBRARY) $(PREFIX)/libraries | ||
114 | @mkdir -p $(PREFIX)/headers/$(PACKAGE) | ||
115 | @for header in $(HEADERS) ; do cp $$header $(PREFIX)/headers/$(PACKAGE) ; done | ||
116 | |||
117 | -include $(DEPENDENCIES) | ||
118 | |||
diff --git a/firmware/test/makefile-vars b/firmware/test/makefile-vars new file mode 100644 index 0000000000..719f01dd98 --- /dev/null +++ b/firmware/test/makefile-vars | |||
@@ -0,0 +1,79 @@ | |||
1 | ############################################################################# | ||
2 | ## __________ __ ___. | ||
3 | ## Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | ## Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | ## Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | ## Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | ## \/ \/ \/ \/ \/ | ||
8 | ## Copyright Alan Korr, 2002. All rights reserved. | ||
9 | ## | ||
10 | ## Permission to use, copy, modify, and distribute this software for any | ||
11 | ## purpose is hereby granted without fee, provided that this copyright and | ||
12 | ## permissions notice appear in all copies and derivatives, and that no | ||
13 | ## charge may be made for the software and its documentation except to cover | ||
14 | ## cost of distribution. | ||
15 | ## | ||
16 | ## This software is provided "as is" without express or implied warranty. | ||
17 | ############################################################################# | ||
18 | |||
19 | ####################################################################### | ||
20 | ## PLEASE CONSIDER THERE IS NOTHING TO CHANGE IN THE FOLLOWING LINES | ||
21 | ## SINCE THERE ARE COMMON FOR ALL LIBRARY | ||
22 | ## | ||
23 | |||
24 | ARCH=test | ||
25 | |||
26 | CC = gcc | ||
27 | AS = as | ||
28 | LD = ld | ||
29 | AR = ar | ||
30 | RL = ranlib | ||
31 | OC = objcopy | ||
32 | GZ = gzip -f | ||
33 | |||
34 | PREFIX = ~/rockbox/$(ARCH) | ||
35 | DEFINES = -DTEST | ||
36 | |||
37 | CFLAGS = -g | ||
38 | #CFLAGS += -save-temps | ||
39 | CFLAGS += -Wall \ | ||
40 | -W \ | ||
41 | -Wshadow \ | ||
42 | -Wpointer-arith \ | ||
43 | -Waggregate-return \ | ||
44 | -Wstrict-prototypes \ | ||
45 | -Wredundant-decls \ | ||
46 | -Winline \ | ||
47 | -Wmissing-prototypes \ | ||
48 | -Werror \ | ||
49 | -Wsign-compare \ | ||
50 | -Wmissing-declarations \ | ||
51 | -Wmissing-noreturns \ | ||
52 | -Wnested-externs | ||
53 | CFLAGS += -pipe -O3 | ||
54 | CFLAGS += -fomit-frame-pointer \ | ||
55 | -fschedule-insns | ||
56 | CFLAGS += $(EXTRA_CFLAGS) | ||
57 | CFLAGS += $(DEFINES) | ||
58 | |||
59 | INCLUDES = -I.. \ | ||
60 | -I. \ | ||
61 | -I$(PREFIX)/headers | ||
62 | |||
63 | LIBRARY = lib$(PACKAGE).a | ||
64 | |||
65 | HEADERS = $(PACKAGE).h \ | ||
66 | config.h \ | ||
67 | defines.h \ | ||
68 | types.h \ | ||
69 | return_values.h \ | ||
70 | inlines.h \ | ||
71 | functions.h | ||
72 | |||
73 | SOURCES = $(wildcard $(PACKAGE)-*.c) | ||
74 | |||
75 | OBJECTS = $(SOURCES:.c=.o) | ||
76 | |||
77 | DEPENDENCIES = $(SOURCES:.c=.d) | ||
78 | |||
79 | HEADER_PATH = $(PREFIX)/headers/$(PACKAGE)/. | ||