Rev 2715 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2714 | cejka | 1 | # |
2 | # Copyright (c) 2005 Martin Decky |
||
3 | # All rights reserved. |
||
4 | # |
||
5 | # Redistribution and use in source and binary forms, with or without |
||
6 | # modification, are permitted provided that the following conditions |
||
7 | # are met: |
||
8 | # |
||
9 | # - Redistributions of source code must retain the above copyright |
||
10 | # notice, this list of conditions and the following disclaimer. |
||
11 | # - Redistributions in binary form must reproduce the above copyright |
||
12 | # notice, this list of conditions and the following disclaimer in the |
||
13 | # documentation and/or other materials provided with the distribution. |
||
14 | # - The name of the author may not be used to endorse or promote products |
||
15 | # derived from this software without specific prior written permission. |
||
16 | # |
||
17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||
18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||
26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
27 | # |
||
28 | |||
29 | include ../../../version |
||
30 | include ../../Makefile.config |
||
31 | |||
32 | ## Setup toolchain |
||
33 | # |
||
34 | |||
35 | LIBC_PREFIX = ../../lib/libc |
||
36 | SOFTINT_PREFIX = ../../lib/softint |
||
37 | include $(LIBC_PREFIX)/Makefile.toolchain |
||
38 | |||
39 | CFLAGS += \ |
||
40 | -DSHELL \ |
||
41 | -I. \ |
||
42 | -DNO_HISTORY \ |
||
43 | -DBSD=1 \ |
||
44 | -DSMALL \ |
||
45 | -D_GNU_SOURCE \ |
||
46 | -DGLOB_BROKEN \ |
||
47 | -D__COPYRIGHT\(x\)= \ |
||
48 | -D__RCSID\(x\)= |
||
49 | # -D_DIAGASSERT\(x\)= \ |
||
50 | # -DHETIO |
||
51 | |||
52 | LIBS = $(LIBC_PREFIX)/libc.a |
||
53 | DEFS += -DRELEASE=\"$(RELEASE)\" |
||
54 | |||
55 | ifdef REVISION |
||
56 | DEFS += "-DREVISION=\"$(REVISION)\"" |
||
57 | endif |
||
58 | |||
59 | ifdef TIMESTAMP |
||
60 | DEFS += "-DTIMESTAMP=\"$(TIMESTAMP)\"" |
||
61 | endif |
||
62 | |||
63 | ## Sources |
||
64 | # |
||
65 | |||
66 | OUTPUT = sh |
||
67 | SHSRCS = \ |
||
68 | fake.c \ |
||
69 | alias.c \ |
||
70 | cd.c \ |
||
71 | bltin/echo.c \ |
||
72 | error.c \ |
||
73 | eval.c \ |
||
74 | exec.c \ |
||
75 | expand.c \ |
||
76 | hetio.c \ |
||
77 | histedit.c \ |
||
78 | input.c \ |
||
79 | jobs.c \ |
||
80 | mail.c \ |
||
81 | main.c \ |
||
82 | memalloc.c \ |
||
83 | miscbltin.c \ |
||
84 | mystring.c \ |
||
85 | options.c \ |
||
86 | output.c \ |
||
87 | parser.c \ |
||
88 | redir.c \ |
||
89 | show.c \ |
||
90 | setmode.c \ |
||
91 | bltin/test.c \ |
||
92 | bltin/times.c \ |
||
93 | trap.c \ |
||
94 | var.c |
||
95 | |||
96 | GENSRCS = \ |
||
97 | builtins.c \ |
||
98 | init.c \ |
||
99 | nodes.c \ |
||
100 | syntax.c \ |
||
101 | signames.c |
||
102 | # lex.yy.c \ |
||
103 | # arith.c \ |
||
104 | # arith.h \ |
||
105 | |||
106 | GENHEADERS = \ |
||
107 | token.h \ |
||
108 | nodes.h \ |
||
109 | syntax.h \ |
||
110 | builtins.h |
||
111 | |||
2715 | cejka | 112 | SOURCES = ${SHSRCS} ${GENSRCS} |
113 | SUBDIRS = tools |
||
2714 | cejka | 114 | |
115 | OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
||
116 | |||
2715 | cejka | 117 | .PHONY: all clean depend disasm all-subdirs |
2714 | cejka | 118 | |
2715 | cejka | 119 | all: all-subdirs $(OUTPUT) disasm |
2714 | cejka | 120 | |
2715 | cejka | 121 | all-subdirs: |
122 | for i in $(SUBDIRS); do \ |
||
123 | echo "make all in $$i..."; \ |
||
124 | make -C $$i all; \ |
||
125 | done |
||
126 | |||
2714 | cejka | 127 | -include Makefile.depend |
128 | |||
129 | .ORDER: builtins.c builtins.h |
||
130 | builtins.c builtins.h: mkbuiltins builtins.def |
||
131 | sh mkbuiltins shell.h builtins.def `pwd` |
||
132 | |||
133 | INIT_DEPS = alias.c eval.c exec.c input.c jobs.c options.c parser.c \ |
||
134 | redir.c trap.c var.c output.c |
||
135 | |||
136 | init.c: mkinit $(INIT_DEPS) |
||
137 | ./mkinit $(INIT_DEPS) |
||
138 | |||
139 | signames.c: mksignames |
||
140 | ./mksignames |
||
141 | |||
142 | nodes.c nodes.h: mknodes nodetypes nodes.c.pat |
||
143 | ./mknodes ./nodetypes ./nodes.c.pat |
||
144 | |||
145 | syntax.c syntax.h: mksyntax |
||
146 | ./mksyntax |
||
147 | |||
148 | #arith.c arith.h: arith.y |
||
149 | # yacc -d arith.y |
||
150 | # mv y.tab.h arith.h |
||
151 | # mv y.tab.c arith.c |
||
152 | |||
153 | token.h: mktokens |
||
154 | sh ./mktokens |
||
155 | |||
156 | clean: |
||
157 | -rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend |
||
2715 | cejka | 158 | -rm -f $(GENSRCS) $(GENHEADERS) $(OBJECTS) |
159 | for i in $(SUBDIRS); do \ |
||
160 | echo "make clean in $$i..."; \ |
||
161 | make -C $$i clean; \ |
||
162 | done |
||
2714 | cejka | 163 | |
164 | depend: |
||
165 | $(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) $(GENHEADERS) > Makefile.depend |
||
166 | |||
167 | $(OUTPUT): $(GENSRCS) $(GENHEADERS) $(OBJECTS) $(LIBS) |
||
168 | $(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
||
169 | |||
170 | disasm: |
||
171 | $(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm |
||
172 | |||
173 | %.o: %.S |
||
174 | $(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
||
175 | |||
176 | %.o: %.s |
||
177 | $(AS) $(AFLAGS) $< -o $@ |
||
178 | |||
179 | %.o: %.c |
||
180 | $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ |