Subversion Repositories HelenOS

Rev

Rev 3811 | Rev 4168 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3811 Rev 3882
1
# Copyright (c) 2005,  Martin Decky
1
# Copyright (c) 2005,  Martin Decky
2
# All rights reserved.
2
# All rights reserved.
3
# Copyright (c) 2008, Tim Post <tinkertim@gmail.com>
3
# Copyright (c) 2008, Tim Post <tinkertim@gmail.com>
4
# All rights reserved.
4
# All rights reserved.
5
#
5
#
6
# Redistribution and use in source and binary forms, with or without
6
# Redistribution and use in source and binary forms, with or without
7
# modification, are permitted provided that the following conditions are met:
7
# modification, are permitted provided that the following conditions are met:
8
#
8
#
9
# Redistributions of source code must retain the above copyright notice, this
9
# Redistributions of source code must retain the above copyright notice, this
10
# list of conditions and the following disclaimer.
10
# list of conditions and the following disclaimer.
11
#
11
#
12
# Redistributions in binary form must reproduce the above copyright notice,
12
# Redistributions in binary form must reproduce the above copyright notice,
13
# this list of conditions and the following disclaimer in the documentation
13
# this list of conditions and the following disclaimer in the documentation
14
# and/or other materials provided with the distribution.
14
# and/or other materials provided with the distribution.
15
#
15
#
16
# Neither the name of the original program's authors nor the names of its
16
# Neither the name of the original program's authors nor the names of its
17
# contributors may be used to endorse or promote products derived from this
17
# contributors may be used to endorse or promote products derived from this
18
# software without specific prior written permission.
18
# software without specific prior written permission.
19
#
19
#
20
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
# POSSIBILITY OF SUCH DAMAGE.
30
# POSSIBILITY OF SUCH DAMAGE.
31
 
31
 
32
include ../../../version
32
include ../../../version
33
-include ../../../Makefile.config
-
 
34
 
33
 
35
LIBC_PREFIX = ../../lib/libc
34
LIBC_PREFIX = ../../lib/libc
36
SOFTINT_PREFIX = ../../lib/softint
35
SOFTINT_PREFIX = ../../lib/softint
-
 
36
 
37
include $(LIBC_PREFIX)/Makefile.toolchain
37
include $(LIBC_PREFIX)/Makefile.toolchain
38
 
38
 
39
CFLAGS += -I../../srv/kbd/include
39
CFLAGS += -I../../srv/kbd/include
40
 
40
 
41
LIBS = $(LIBC_PREFIX)/libc.a
41
LIBS = $(LIBC_PREFIX)/libc.a
42
DEFS += -DRELEASE=\"$(RELEASE)\"
42
DEFS += -DRELEASE=$(RELEASE)
43
 
-
 
44
ifdef REVISION
-
 
45
	DEFS += "-DREVISION=\"$(TIMESTAMP)\""
-
 
46
endif
-
 
47
 
-
 
48
ifdef TIMESTAMP
-
 
49
	DEFS += "-DTIMESTAMP=\"$(TIMESTAMP)\""
-
 
50
endif
-
 
51
 
43
 
52
PROGRAM = bdsh
44
PROGRAM = bdsh
53
 
45
 
54
# Any directory that cleaning targets should know about
46
# Any directory that cleaning targets should know about
55
SUBDIRS = \
47
SUBDIRS = \
56
	./ \
48
	./ \
57
	cmds/ \
49
	cmds/ \
58
	cmds/modules/ \
50
	cmds/modules/ \
59
	cmds/modules/help/ \
51
	cmds/modules/help/ \
60
	cmds/modules/mkdir/ \
52
	cmds/modules/mkdir/ \
61
	cmds/modules/rm/ \
53
	cmds/modules/rm/ \
62
	cmds/modules/cat/ \
54
	cmds/modules/cat/ \
63
	cmds/modules/touch/ \
55
	cmds/modules/touch/ \
64
	cmds/modules/ls/ \
56
	cmds/modules/ls/ \
65
	cmds/modules/pwd/ \
57
	cmds/modules/pwd/ \
66
	cmds/modules/sleep/ \
58
	cmds/modules/sleep/ \
67
	cmds/modules/cp/ \
59
	cmds/modules/cp/ \
68
	cmds/builtins/ \
60
	cmds/builtins/ \
69
	cmds/builtins/exit/\
61
	cmds/builtins/exit/\
70
	cmds/builtins/cd/
62
	cmds/builtins/cd/
71
 
63
 
72
SOURCES = \
64
SOURCES = \
73
	cmds/modules/help/help.c \
65
	cmds/modules/help/help.c \
74
	cmds/modules/mkdir/mkdir.c \
66
	cmds/modules/mkdir/mkdir.c \
75
	cmds/modules/rm/rm.c \
67
	cmds/modules/rm/rm.c \
76
	cmds/modules/cat/cat.c \
68
	cmds/modules/cat/cat.c \
77
	cmds/modules/touch/touch.c \
69
	cmds/modules/touch/touch.c \
78
	cmds/modules/ls/ls.c \
70
	cmds/modules/ls/ls.c \
79
	cmds/modules/pwd/pwd.c \
71
	cmds/modules/pwd/pwd.c \
80
	cmds/modules/sleep/sleep.c \
72
	cmds/modules/sleep/sleep.c \
81
	cmds/modules/cp/cp.c \
73
	cmds/modules/cp/cp.c \
82
	cmds/builtins/exit/exit.c \
74
	cmds/builtins/exit/exit.c \
83
	cmds/builtins/cd/cd.c \
75
	cmds/builtins/cd/cd.c \
84
	cmds/mod_cmds.c \
76
	cmds/mod_cmds.c \
85
	cmds/builtin_cmds.c \
77
	cmds/builtin_cmds.c \
86
	errors.c \
78
	errors.c \
87
	input.c \
79
	input.c \
88
	util.c \
80
	util.c \
89
	exec.c \
81
	exec.c \
90
	scli.c
82
	scli.c
91
 
83
 
92
CFLAGS += -I. -Icmds/ -Icmds/builtins -Icmds/modules
84
CFLAGS += -I. -Icmds/ -Icmds/builtins -Icmds/modules
93
 
85
 
94
OBJECTS = $(SOURCES:.c=.o)
86
OBJECTS = $(SOURCES:.c=.o)
95
 
87
 
96
# For easy cleaning, *.o is already handled
88
# For easy cleaning, *.o is already handled
97
CLEANDIRS := $(addsuffix *~,$(SUBDIRS))
89
CLEANDIRS := $(addsuffix *~,$(SUBDIRS))
98
CLEANDIRS += $(addsuffix *.bak,$(SUBDIRS))
90
CLEANDIRS += $(addsuffix *.bak,$(SUBDIRS))
99
CLEANDIRS += $(addsuffix *.tmp,$(SUBDIRS))
91
CLEANDIRS += $(addsuffix *.tmp,$(SUBDIRS))
100
CLEANDIRS += $(addsuffix *.out,$(SUBDIRS))
92
CLEANDIRS += $(addsuffix *.out,$(SUBDIRS))
101
CLEANDIRS += $(addsuffix *.d,$(SUBDIRS))
93
CLEANDIRS += $(addsuffix *.d,$(SUBDIRS))
102
CLEANDIRS += $(addsuffix *.gch,$(SUBDIRS) )
94
CLEANDIRS += $(addsuffix *.gch,$(SUBDIRS) )
103
 
95
 
104
%.o: %.S
96
%.o: %.S
105
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
97
	$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@
106
 
98
 
107
%.o: %.s
99
%.o: %.s
108
	$(AS) $(AFLAGS) $< -o $@
100
	$(AS) $(AFLAGS) $< -o $@
109
 
101
 
110
%.o: %.c
102
%.o: %.c
111
	$(CC) $(CFLAGS) $(INC) -c $< -o $@
103
	$(CC) $(CFLAGS) $(INC) -c $< -o $@
112
	@$(CC) -M $(CFLAGS) $(INC) $*.c > $*.d
104
	@$(CC) -M $(CFLAGS) $(INC) $*.c > $*.d
113
 
105
 
114
$(PROGRAM): $(OBJECTS) $(LIBS)
106
$(PROGRAM): $(OBJECTS) $(LIBS)
115
	$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(PROGRAM).map
107
	$(LD) -T $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(PROGRAM).map
116
 
108
 
117
# Everything else is a phony target
109
# Everything else is a phony target
118
.PHONY: all clean distclean depend disasm
110
.PHONY: all clean distclean depend disasm
119
 
111
 
120
all: $(PROGRAM) disasm
112
all: $(PROGRAM) disasm
121
 
113
 
122
clean:
114
clean:
123
	@-rm -f $(OBJECTS)
115
	@-rm -f $(OBJECTS)
124
	@-rm -f $(PROGRAM)
116
	@-rm -f $(PROGRAM)
125
	@-rm -f $(PROGRAM).map
117
	@-rm -f $(PROGRAM).map
126
	@-rm -f $(PROGRAM).disasm
118
	@-rm -f $(PROGRAM).disasm
127
	@-rm -f $(CLEANDIRS)
119
	@-rm -f $(CLEANDIRS)
128
 
120
 
129
depend:
121
depend:
130
	@echo ''
122
	@echo ''
131
 
123
 
132
disasm:
124
disasm:
133
	$(OBJDUMP) -d $(PROGRAM) >$(PROGRAM).disasm
125
	$(OBJDUMP) -d $(PROGRAM) >$(PROGRAM).disasm
134
 
126
 
135
distclean: clean
127
distclean: clean
136
 
128
 
137
# Do not delete - dependencies
129
# Do not delete - dependencies
138
-include $(OBJECTS:.o=.d)
130
-include $(OBJECTS:.o=.d)
139
 
131