Subversion Repositories HelenOS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3265 post 1
# Copyright (c) 2008, Tim Post <tinkertim@gmail.com>
2
# All rights reserved.
3
#
4
# Redistribution and use in source and binary forms, with or without
5
# modification, are permitted provided that the following conditions are met:
6
#
7
# Redistributions of source code must retain the above copyright notice, this
8
# list of conditions and the following disclaimer.
9
#
10
# Redistributions in binary form must reproduce the above copyright notice,
11
# this list of conditions and the following disclaimer in the documentation
12
# and/or other materials provided with the distribution.
13
#
14
# Neither the name of the original program's authors nor the names of its
15
# contributors may be used to endorse or promote products derived from this
16
# software without specific prior written permission.
17
#
18
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
# POSSIBILITY OF SUCH DAMAGE.
29
 
30
CC = gcc
31
CFLAGS = -Wall -Wstrict-prototypes -Wmissing-prototypes -fno-strict-aliasing
32
PROGRAM = scli
33
 
34
# Any directory that cleaning targets should know about
35
SUBDIRS = \
36
	./ \
37
	cmds/ \
38
	cmds/modules/ \
39
	cmds/modules/help/ \
40
	cmds/modules/quit/ \
41
	cmds/builtins/ \
42
	cmds/builtins/pwd/ \
43
	cmds/builtins/cd/ \
44
	lib/
45
 
46
# Commands
47
MODULES = \
48
	cmds/modules/help/help.c \
49
	cmds/modules/quit/quit.c
50
 
51
BUILTINS = \
52
	cmds/builtins/pwd/pwd.c \
53
	cmds/builtins/cd/cd.c
54
 
55
# Non-commands and command loaders
56
SOURCES = \
57
	cmds/mod_cmds.c \
58
	cmds/builtin_cmds.c \
59
	errors.c \
60
	input.c \
61
	util.c \
62
	exec.c \
63
	scli.c
64
 
65
# Included Libs, stuff we build and include (not link against)
66
LIBS =
67
 
68
# Add included libs to include path
69
INC = -I. -Icmds/ -Icmds/builtins -Icmds/modules -Ilib -Ilib/ustr
70
 
71
# All your sources are belong to us, !!! Order Matters Here !!!
72
SRC = $(LIBS) $(MODULES) $(BUILTINS) $(SOURCES)
73
 
74
# Every .c file in $(SRC) will be built to file.o
75
OBJECTS = $(SRC:.c=.o)
76
 
77
# For easy cleaning, *.o is already handled
78
CLEANDIRS := $(addsuffix *~,$(SUBDIRS))
79
CLEANDIRS += $(addsuffix *.bak,$(SUBDIRS))
80
CLEANDIRS += $(addsuffix *.tmp,$(SUBDIRS))
81
CLEANDIRS += $(addsuffix *.out,$(SUBDIRS))
82
CLEANDIRS += $(addsuffix *.d,$(SUBDIRS))
83
CLEANDIRS += $(addsuffix *.gch,$(SUBDIRS))
84
 
85
%.o: %.c
86
	$(CC) $(CFLAGS) $(INC) -c $< -o $@
87
	@$(CC) -M $(CFLAGS) $(INC) $*.c > $*.d
88
 
89
$(PROGRAM): $(OBJECTS)
90
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
91
 
92
# Everything else is a phony target
93
.PHONY: all clean distclean
94
 
95
all: $(PROGRAM)
96
 
97
clean:
98
	@-rm -f $(OBJECTS)
99
	@-rm -f $(PROGRAM)
100
	@-rm -f $(CLEANDIRS)
101
 
102
distclean: clean
103
 
104
# Do not delete - header dependencies
105
-include $(OBJECTS:.o=.d)